OLD | NEW |
---|---|
(Empty) | |
1 if (self.importScripts) { | |
2 importScripts('../../resources/helpers.js'); | |
3 importScripts('testrunner-helpers.js'); | |
4 | |
5 if (get_current_scope() == 'ServiceWorker') | |
6 importScripts('../../../serviceworker/resources/worker-testharness.js'); | |
7 else | |
8 importScripts('../../../resources/testharness.js'); | |
9 } | |
10 | |
11 var DEFAULT_PERMISSION_STATE = 'denied'; | |
12 var tests = [ | |
13 { | |
14 test: async_test('Test PermissionDescription WebIDL rules in ' + get_current _scope() + ' scope.'), | |
15 fn: function(callback) { | |
16 // Revoking a random permission name should fail. | |
17 navigator.permissions.revoke({name:'foobar'}).then(function(result) { | |
18 assert_unreached('revoking a random permission should fail'); | |
19 }, function(error) { | |
20 assert_equals(error.name, 'TypeError'); | |
21 | |
22 // Querying a permission without a name should fail. | |
23 return navigator.permissions.query({}); | |
24 }).then(function(result) { | |
25 assert_unreached('revoking a permission without a name should fail') ; | |
26 }, function(error) { | |
27 assert_equals(error.name, 'TypeError'); | |
28 callback(); | |
29 }); | |
30 } | |
31 }, | |
32 { | |
33 test: async_test('Test geolocation permission in ' + get_current_scope() + ' scope.'), | |
34 fn: function(callback) { | |
35 setPermission('geolocation', 'granted', location.origin, location.origin). then(function() { | |
36 navigator.permissions.revoke({name:'geolocation'}).then(function(resul t) { | |
37 assert_true(result instanceof PermissionStatus); | |
38 assert_equals(result.state, DEFAULT_PERMISSION_STATE); | |
39 callback(); | |
40 }).catch(function() { | |
41 assert_unreached('revoking geolocation permission should not fail. ') | |
42 }); | |
43 }); | |
44 } | |
45 }, | |
46 { | |
47 test: async_test('Test midi permission in ' + get_current_scope() + ' scope. '), | |
48 fn: function(callback) { | |
49 setPermission('midi-sysex', 'granted', location.origin, location.origin) .then(function() { | |
50 navigator.permissions.revoke({name:'midi'}).then(function(result) { | |
mlamouri (slow - plz ping)
2015/07/21 23:29:36
{name:'midi',sysex:true}
I wasn't able to check w
| |
51 assert_true(result instanceof PermissionStatus); | |
52 assert_equals(result.state, DEFAULT_PERMISSION_STATE); | |
53 callback(); | |
54 }).catch(function() { | |
55 assert_unreached('revoking geolocation permission should not fai l.') | |
56 }); | |
57 }); | |
58 } | |
59 }, | |
60 { | |
61 test: async_test('Test push permission in ' + get_current_scope() + ' scope. '), | |
62 fn: function(callback) { | |
63 setPermission('push-messaging', 'granted', location.origin, location.ori gin).then(function() { | |
64 navigator.permissions.revoke({name:'push'}).catch(function(e) { | |
65 // By default, the permission query is rejected if "userVisibleO nly" option | |
66 // isn't set or set to true. | |
67 assert_equals(e.name, "NotSupportedError"); | |
68 | |
69 // Test for userVisibleOnly=false. | |
70 return navigator.permissions.revoke({name:'push', userVisibleOnl y: false}); | |
71 }).catch(function(e) { | |
72 // By default, the permission query is rejected if "userVisibleO nly" option | |
mlamouri (slow - plz ping)
2015/07/21 23:29:36
s/query/revocation/
| |
73 // isn't set or set to true. | |
74 assert_equals(e.name, "NotSupportedError"); | |
75 | |
76 // Test for userVisibleOnly=true. | |
77 return navigator.permissions.revoke({name:'push', userVisibleOnl y: true}); | |
78 }).then(function(result) { | |
79 assert_true(result instanceof PermissionStatus); | |
80 assert_equals(result.state, DEFAULT_PERMISSION_STATE); | |
81 callback(); | |
82 }).catch(function() { | |
83 assert_unreached('querying push permission should not fail.') | |
84 }); | |
85 }); | |
86 } | |
87 }, | |
88 { | |
89 test: async_test('Test notifications permission in ' + get_current_scope() + ' scope.'), | |
90 fn: function(callback) { | |
91 setPermission('notifications', 'granted', location.origin, location.orig in).then(function() { | |
92 navigator.permissions.revoke({name:'notifications'}).then(function(r esult) { | |
93 assert_true(result instanceof PermissionStatus); | |
94 assert_equals(result.state, DEFAULT_PERMISSION_STATE); | |
95 callback(); | |
96 }).catch(function() { | |
97 assert_unreached('querying notifications permission should not f ail.') | |
98 }); | |
99 }); | |
100 } | |
101 }]; | |
102 | |
103 function runTest(i) { | |
104 tests[i].test.step(function() { | |
105 tests[i].fn(function() { | |
106 tests[i].test.done(); | |
107 if (i + 1 < tests.length) { | |
108 runTest(i + 1); | |
109 } else { | |
110 done(); | |
111 } | |
112 }); | |
113 }); | |
114 } | |
115 runTest(0); | |
OLD | NEW |