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 navigator.permissions.query('geolocation').then(function(result) { | 11 navigator.permissions.query({name:'geolocation'}).then(function(result) { |
12 // TODO(mlamouri): test values when some instrumentation are done. | 12 // TODO(mlamouri): test values when some instrumentation are available. |
13 assert_true(result instanceof PermissionStatus); | 13 assert_true(result instanceof PermissionStatus); |
14 test.done(); | 14 test.done(); |
15 }).catch(function() { | 15 }).catch(function() { |
16 assert_unreached('navigator.permissions.query() should not fail.') | 16 assert_unreached('querying geolocation permission should not fail.') |
17 }); | 17 }); |
18 }, 'Check the navigator.permissions.query() normal behavior in ' + get_current_s
cope() + ' scope.'); | 18 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); |
19 | 19 |
20 async_test(function(test) { | 20 async_test(function(test) { |
21 navigator.permissions.query('unknown-keyword').then(function() { | 21 navigator.permissions.query({name:'midi'}).then(function(result) { |
22 assert_unreached('navigator.permissions.query() should not succeed (for
now).') | 22 // By default, the permission is granted if "sysex" option isn't set or |
23 }, function(e) { | 23 // set to false. |
24 assert_true(e instanceof TypeError); | 24 assert_equals(result.status, "granted"); |
25 assert_equals('TypeError', e.name); | 25 |
26 }).then(function() { | 26 // Test for sysex=false. |
| 27 return navigator.permissions.query({name:'midi', sysex: false}); |
| 28 }).then(function(result) { |
| 29 // By default, the permission is granted if "sysex" option isn't set or |
| 30 // set to false. |
| 31 assert_equals(result.status, "granted"); |
| 32 |
| 33 // Test for sysex=true. |
| 34 return navigator.permissions.query({name:'midi', sysex: true}); |
| 35 }).then(function(result) { |
| 36 // TODO(mlamouri): test values when some instrumentation are available. |
| 37 assert_true(result instanceof PermissionStatus); |
27 test.done(); | 38 test.done(); |
| 39 }).catch(function() { |
| 40 assert_unreached('querying midi permission should not fail.') |
28 }); | 41 }); |
29 }, 'Check the navigator.permissions.query() with wrong keyword in ' + get_curren
t_scope() + ' scope.'); | 42 }, 'Test midi permission in ' + get_current_scope() + ' scope.'); |
| 43 |
| 44 async_test(function(test) { |
| 45 navigator.permissions.query({name:'notifications'}).then(function(result) { |
| 46 // TODO(mlamouri): test values when some instrumentation are available. |
| 47 assert_true(result instanceof PermissionStatus); |
| 48 test.done(); |
| 49 }).catch(function() { |
| 50 assert_unreached('querying notifications permission should not fail.') |
| 51 }); |
| 52 }, 'Test notifications permission in ' + get_current_scope() + ' scope.'); |
| 53 |
| 54 async_test(function(test) { |
| 55 navigator.permissions.query({name:'push'}).then(function(result) { |
| 56 // By default, the permission is rejected if "userVisible" option isn't |
| 57 // set or set to true. |
| 58 assert_equals(result.status, "denied"); |
| 59 |
| 60 // Test for userVisible=true. |
| 61 return navigator.permissions.query({name:'push', userVisible: false}); |
| 62 }).then(function(result) { |
| 63 // By default, the permission is rejected if "userVisible" option isn't |
| 64 // set or set to true. |
| 65 assert_equals(result.status, "denied"); |
| 66 |
| 67 // Test for userVisible=true. |
| 68 return navigator.permissions.query({name:'push', userVisible: true}); |
| 69 }).then(function(result) { |
| 70 // TODO(mlamouri): test values when some instrumentation are available. |
| 71 assert_true(result instanceof PermissionStatus); |
| 72 test.done(); |
| 73 }).catch(function() { |
| 74 assert_unreached('querying push permission should not fail.') |
| 75 }); |
| 76 }, 'Test push permission in ' + get_current_scope() + ' scope.'); |
30 | 77 |
31 done(); | 78 done(); |
OLD | NEW |