1 if (self.importScripts) {
2 importScripts('../../resources/helpers.js');
3 importScripts('testrunner-helpers.js');
5 if (get_current_scope() == 'ServiceWorker')
6 importScripts('../../../serviceworker/resources/worker-testharness.js');
8 importScripts('../../../resources/testharness.js');
11 async_test(function(t) {
12 setPermission('geolocation', 'granted', location.origin, location.origin).then(t.step_func(function() {
13 navigator.permissions.query({name:'geolocation'}).then(t.step_func(function(p) {
14 assert_equals(p.state, 'granted');
16 p.onchange = t.step_func(function() {
17 assert_equals(p.state, 'denied');
19 p.onchange = t.step_func(function() {
20 assert_unreached('the permission should not change again.');
23 setPermission('geolocation', 'prompt', 'https://example.com', 'https://example.com');
24 setPermission('geolocation', 'prompt', 'https://example.com', location.origin);
25 setPermission('geolocation', 'prompt', location.origin, 'https://example.com');
27 navigator.permissions.query({name:'geolocation'}).then(t.step_func(function(p) {
28 assert_equals(p.state, 'denied');
33 setPermission('geolocation', 'denied', location.origin, location.origin);
36 }, 'Testing that the change event is correctly sent. Scope: ' + get_current_scope());