OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('../../resources/helpers.js'); | 2 importScripts('../../resources/helpers.js'); |
3 importScripts('testrunner-helpers.js'); | 3 importScripts('testrunner-helpers.js'); |
4 | 4 |
5 if (get_current_scope() == 'ServiceWorker') | 5 if (get_current_scope() == 'ServiceWorker') |
6 importScripts('../../../serviceworker/resources/worker-testharness.js'); | 6 importScripts('../../../serviceworker/resources/worker-testharness.js'); |
7 else | 7 else |
8 importScripts('../../../resources/testharness.js'); | 8 importScripts('../../../resources/testharness.js'); |
9 } | 9 } |
10 | 10 |
11 async_test(function(t) { | 11 async_test(function(t) { |
12 setPermission('geolocation', 'granted', location.origin, location.origin).th
en(t.step_func(function() { | 12 setPermission('geolocation', 'granted', location.origin, location.origin).th
en(t.step_func(function() { |
13 navigator.permissions.query({name:'geolocation'}).then(t.step_func(funct
ion(p) { | 13 navigator.permissions.query({name:'geolocation'}).then(t.step_func(funct
ion(p) { |
14 assert_equals(p.status, 'granted'); | 14 assert_equals(p.state, 'granted'); |
15 | 15 |
16 p.onchange = t.step_func(function() { | 16 p.onchange = t.step_func(function() { |
17 assert_equals(p.status, 'denied'); | 17 assert_equals(p.state, 'denied'); |
18 | 18 |
19 p.onchange = t.step_func(function() { | 19 p.onchange = t.step_func(function() { |
20 assert_unreached('the permission should not change again.'); | 20 assert_unreached('the permission should not change again.'); |
21 }); | 21 }); |
22 | 22 |
23 setPermission('geolocation', 'prompt', 'https://example.com', 'h
ttps://example.com'); | 23 setPermission('geolocation', 'prompt', 'https://example.com', 'h
ttps://example.com'); |
24 setPermission('geolocation', 'prompt', 'https://example.com', lo
cation.origin); | 24 setPermission('geolocation', 'prompt', 'https://example.com', lo
cation.origin); |
25 setPermission('geolocation', 'prompt', location.origin, 'https:/
/example.com'); | 25 setPermission('geolocation', 'prompt', location.origin, 'https:/
/example.com'); |
26 | 26 |
27 navigator.permissions.query({name:'geolocation'}).then(t.step_fu
nc(function(p) { | 27 navigator.permissions.query({name:'geolocation'}).then(t.step_fu
nc(function(p) { |
28 assert_equals(p.status, 'denied'); | 28 assert_equals(p.state, 'denied'); |
29 t.done(); | 29 t.done(); |
30 })); | 30 })); |
31 }); | 31 }); |
32 | 32 |
33 setPermission('geolocation', 'denied', location.origin, location.ori
gin); | 33 setPermission('geolocation', 'denied', location.origin, location.ori
gin); |
34 })); | 34 })); |
35 })); | 35 })); |
36 }, 'Testing that the change event is correctly sent. Scope: ' + get_current_scop
e()); | 36 }, 'Testing that the change event is correctly sent. Scope: ' + get_current_scop
e()); |
37 | 37 |
38 done(); | 38 done(); |
OLD | NEW |