| 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 async_test(function(test) { |
| 12 // Revoking a random permission name should fail. |
| 13 navigator.permissions.revoke({name:'foobar'}).then(function(result) { |
| 14 assert_unreached('revocing a random permission should fail'); |
| 15 }, function(error) { |
| 16 assert_equals(error.name, 'TypeError'); |
| 17 |
| 18 // Querying a permission without a name should fail. |
| 19 return navigator.permissions.query({}); |
| 20 }).then(function(result) { |
| 21 assert_unreached('revoking a permission without a name should fail'); |
| 22 }, function(error) { |
| 23 assert_equals(error.name, 'TypeError'); |
| 24 test.done(); |
| 25 }); |
| 26 }, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope
.'); |
| 27 |
| 28 async_test(function(test) { |
| 29 setPermission('geolocation', 'granted', location.origin, location.origin).th
en(test.step_func(function() { |
| 30 navigator.permissions.revoke({name:'geolocation'}).then(function(result)
{ |
| 31 assert_true(result instanceof PermissionStatus); |
| 32 assert_equals(result.status, 'denied'); |
| 33 test.done(); |
| 34 }).catch(function() { |
| 35 assert_unreached('revoking geolocation permission should not fail.') |
| 36 }); |
| 37 })); |
| 38 }, 'Test geolocation permission in ' + get_current_scope() + ' scope.'); |
| 39 |
| 40 /* |
| 41 async_test(function(test) { |
| 42 setPermission('midi-sysex', 'granted', location.origin, location.origin).the
n(test.step_func(function() { |
| 43 navigator.permissions.revoke({name:'midi'}).then(function(result) { |
| 44 // By default, the permission is granted if "sysex" option isn't set
or |
| 45 // set to false even if we try to explictly revoke. |
| 46 assert_equals(result.status, "granted"); |
| 47 |
| 48 // Test for sysex=false. |
| 49 return navigator.permissions.revoke({name:'midi', sysex: false}); |
| 50 }).then(function(result) { |
| 51 // By default, the permission is granted if "sysex" option isn't set
or |
| 52 // set to false even if we try to explictly revoke. |
| 53 assert_equals(result.status, "granted"); |
| 54 |
| 55 // Test for sysex=true. |
| 56 return navigator.permissions.revoke({name:'midi', sysex: true}); |
| 57 }).then(function(result) { |
| 58 assert_true(result instanceof PermissionStatus); |
| 59 assert_equals(result.status, 'denied'); |
| 60 test.done(); |
| 61 }).catch(function() { |
| 62 assert_unreached('revoking midi permission should not fail.') |
| 63 }); |
| 64 })); |
| 65 }, 'Test midi permission in ' + get_current_scope() + ' scope.'); |
| 66 */ |
| 67 |
| 68 async_test(function(test) { |
| 69 navigator.permissions.revoke({name:'notifications'}).then(function(result) { |
| 70 assert_true(result instanceof PermissionStatus); |
| 71 assert_equals(result.status, 'denied'); |
| 72 test.done(); |
| 73 }).catch(function() { |
| 74 assert_unreached('querying notifications permission should not fail.') |
| 75 }); |
| 76 }, 'Test notifications permission in ' + get_current_scope() + ' scope.'); |
| 77 |
| 78 async_test(function(test) { |
| 79 navigator.permissions.revoke({name:'push'}).catch(function(e) { |
| 80 // By default, the permission query is rejected if "userVisibleOnly" opt
ion |
| 81 // isn't set or set to true. |
| 82 assert_equals(e.name, "NotSupportedError"); |
| 83 |
| 84 // Test for userVisibleOnly=false. |
| 85 return navigator.permissions.revoke({name:'push', userVisibleOnly: false
}); |
| 86 }).catch(function(e) { |
| 87 // By default, the permission query is rejected if "userVisibleOnly" opt
ion |
| 88 // isn't set or set to true. |
| 89 assert_equals(e.name, "NotSupportedError"); |
| 90 |
| 91 // Test for userVisibleOnly=true. |
| 92 return navigator.permissions.revoke({name:'push', userVisibleOnly: true}
); |
| 93 }).then(function(result) { |
| 94 assert_true(result instanceof PermissionStatus); |
| 95 assert_equals(result.status, 'denied'); |
| 96 test.done(); |
| 97 }).catch(function() { |
| 98 assert_unreached('querying push permission should not fail.') |
| 99 }); |
| 100 }, 'Test push permission in ' + get_current_scope() + ' scope.'); |
| 101 |
| 102 done(); |
| OLD | NEW |