OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('helpers.js'); | 2 importScripts('helpers.js'); |
3 | 3 |
4 if (get_current_scope() == 'ServiceWorker') | 4 if (get_current_scope() == 'ServiceWorker') |
5 importScripts('../../serviceworker/resources/worker-testharness.js'); | 5 importScripts('../../serviceworker/resources/worker-testharness.js'); |
6 else | 6 else |
7 importScripts('../../resources/testharness.js'); | 7 importScripts('../../resources/testharness.js'); |
8 } | 8 } |
9 | 9 |
10 async_test(function(test) { | 10 async_test(function(test) { |
11 // Querying a random permission name should fail. | 11 // Querying a random permission name should fail. |
12 navigator.permissions.query({name:'foobar'}).then(function(result) { | 12 navigator.permissions.query({name:'foobar'}).then(function(result) { |
13 assert_unreached('querying a random permission should fail'); | 13 assert_unreached('querying a random permission should fail'); |
14 }, function(error) { | 14 }, function(error) { |
15 assert_equals(error.name, 'TypeError'); | 15 assert_equals(error.name, 'TypeError'); |
16 | 16 |
17 // Querying a permission without a name should fail. | 17 // Querying a permission without a name should fail. |
18 return navigator.permissions.query({}); | 18 return navigator.permissions.query({}); |
19 }).then(function(result) { | 19 }).then(function(result) { |
20 assert_unreached('querying a permission without a name should fail'); | 20 assert_unreached('querying a permission without a name should fail'); |
21 }, function(error) { | 21 }, function(error) { |
22 assert_equals(error.name, 'TypeError'); | 22 assert_equals(error.name, 'TypeError'); |
23 test.done(); | 23 test.done(); |
24 }); | 24 }); |
25 }, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope
.'); | 25 }, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope
.'); |
26 | 26 |
27 async_test(function(test) { | 27 async_test(function(test) { |
| 28 navigator.permissions.query({name:'ambient-light-sensor'}).then(function(res
ult) { |
| 29 assert_true(result instanceof PermissionStatus); |
| 30 test.done(); |
| 31 }).catch(function() { |
| 32 assert_unreached('querying ambient-light-sensor permission should not fa
il.') |
| 33 }); |
| 34 }, 'Test ambient-light-sensor permission in ' + get_current_scope() + ' scope.')
; |
| 35 |
| 36 async_test(function(test) { |
| 37 navigator.permissions.query({name:'accelerometer'}).then(function(result) { |
| 38 assert_true(result instanceof PermissionStatus); |
| 39 test.done(); |
| 40 }).catch(function() { |
| 41 assert_unreached('querying accelerometer permission should not fail.') |
| 42 }); |
| 43 }, 'Test accelerometer permission in ' + get_current_scope() + ' scope.'); |
| 44 |
| 45 async_test(function(test) { |
| 46 navigator.permissions.query({name:'gyroscope'}).then(function(result) { |
| 47 assert_true(result instanceof PermissionStatus); |
| 48 test.done(); |
| 49 }).catch(function() { |
| 50 assert_unreached('querying gyroscope permission should not fail.') |
| 51 }); |
| 52 }, 'Test gyroscope permission in ' + get_current_scope() + ' scope.'); |
| 53 |
| 54 async_test(function(test) { |
| 55 navigator.permissions.query({name:'magnetometer'}).then(function(result) { |
| 56 assert_true(result instanceof PermissionStatus); |
| 57 test.done(); |
| 58 }).catch(function() { |
| 59 assert_unreached('querying magnetometer permission should not fail.') |
| 60 }); |
| 61 }, 'Test magnetometer permission in ' + get_current_scope() + ' scope.'); |
| 62 |
| 63 async_test(function(test) { |
28 navigator.permissions.query({name:'geolocation'}).then(function(result) { | 64 navigator.permissions.query({name:'geolocation'}).then(function(result) { |
29 assert_true(result instanceof PermissionStatus); | 65 assert_true(result instanceof PermissionStatus); |
30 assert_equals(result.state, 'denied'); | 66 assert_equals(result.state, 'denied'); |
31 test.done(); | 67 test.done(); |
32 }).catch(function() { | 68 }).catch(function() { |
33 assert_unreached('querying geolocation permission should not fail.') | 69 assert_unreached('querying geolocation permission should not fail.') |
34 }); | 70 }); |
35 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); | 71 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); |
36 | 72 |
37 async_test(function(test) { | 73 async_test(function(test) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 }).then(function(result) { | 120 }).then(function(result) { |
85 assert_true(result instanceof PermissionStatus); | 121 assert_true(result instanceof PermissionStatus); |
86 assert_equals(result.state, 'denied'); | 122 assert_equals(result.state, 'denied'); |
87 test.done(); | 123 test.done(); |
88 }).catch(function() { | 124 }).catch(function() { |
89 assert_unreached('querying push permission should not fail.') | 125 assert_unreached('querying push permission should not fail.') |
90 }); | 126 }); |
91 }, 'Test push permission in ' + get_current_scope() + ' scope.'); | 127 }, 'Test push permission in ' + get_current_scope() + ' scope.'); |
92 | 128 |
93 done(); | 129 done(); |
OLD | NEW |