| Index: LayoutTests/http/tests/permissions/chromium/resources/test-revoke.js
|
| diff --git a/LayoutTests/http/tests/permissions/chromium/resources/test-revoke.js b/LayoutTests/http/tests/permissions/chromium/resources/test-revoke.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..884f817ea82c177e60cae9e729b02e263ab87b1f
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/permissions/chromium/resources/test-revoke.js
|
| @@ -0,0 +1,102 @@
|
| +if (self.importScripts) {
|
| + importScripts('../../resources/helpers.js');
|
| + importScripts('testrunner-helpers.js');
|
| +
|
| + if (get_current_scope() == 'ServiceWorker')
|
| + importScripts('../../../serviceworker/resources/worker-testharness.js');
|
| + else
|
| + importScripts('../../../resources/testharness.js');
|
| +}
|
| +
|
| +async_test(function(test) {
|
| + // Revoking a random permission name should fail.
|
| + navigator.permissions.revoke({name:'foobar'}).then(function(result) {
|
| + assert_unreached('revocing a random permission should fail');
|
| + }, function(error) {
|
| + assert_equals(error.name, 'TypeError');
|
| +
|
| + // Querying a permission without a name should fail.
|
| + return navigator.permissions.query({});
|
| + }).then(function(result) {
|
| + assert_unreached('revoking a permission without a name should fail');
|
| + }, function(error) {
|
| + assert_equals(error.name, 'TypeError');
|
| + test.done();
|
| + });
|
| +}, 'Test PermissionDescription WebIDL rules in ' + get_current_scope() + ' scope.');
|
| +
|
| +async_test(function(test) {
|
| + setPermission('geolocation', 'granted', location.origin, location.origin).then(test.step_func(function() {
|
| + navigator.permissions.revoke({name:'geolocation'}).then(function(result) {
|
| + assert_true(result instanceof PermissionStatus);
|
| + assert_equals(result.status, 'denied');
|
| + test.done();
|
| + }).catch(function() {
|
| + assert_unreached('revoking geolocation permission should not fail.')
|
| + });
|
| + }));
|
| +}, 'Test geolocation permission in ' + get_current_scope() + ' scope.');
|
| +
|
| +/*
|
| +async_test(function(test) {
|
| + setPermission('midi-sysex', 'granted', location.origin, location.origin).then(test.step_func(function() {
|
| + navigator.permissions.revoke({name:'midi'}).then(function(result) {
|
| + // By default, the permission is granted if "sysex" option isn't set or
|
| + // set to false even if we try to explictly revoke.
|
| + assert_equals(result.status, "granted");
|
| +
|
| + // Test for sysex=false.
|
| + return navigator.permissions.revoke({name:'midi', sysex: false});
|
| + }).then(function(result) {
|
| + // By default, the permission is granted if "sysex" option isn't set or
|
| + // set to false even if we try to explictly revoke.
|
| + assert_equals(result.status, "granted");
|
| +
|
| + // Test for sysex=true.
|
| + return navigator.permissions.revoke({name:'midi', sysex: true});
|
| + }).then(function(result) {
|
| + assert_true(result instanceof PermissionStatus);
|
| + assert_equals(result.status, 'denied');
|
| + test.done();
|
| + }).catch(function() {
|
| + assert_unreached('revoking midi permission should not fail.')
|
| + });
|
| + }));
|
| +}, 'Test midi permission in ' + get_current_scope() + ' scope.');
|
| +*/
|
| +
|
| +async_test(function(test) {
|
| + navigator.permissions.revoke({name:'notifications'}).then(function(result) {
|
| + assert_true(result instanceof PermissionStatus);
|
| + assert_equals(result.status, 'denied');
|
| + test.done();
|
| + }).catch(function() {
|
| + assert_unreached('querying notifications permission should not fail.')
|
| + });
|
| +}, 'Test notifications permission in ' + get_current_scope() + ' scope.');
|
| +
|
| +async_test(function(test) {
|
| + navigator.permissions.revoke({name:'push'}).catch(function(e) {
|
| + // By default, the permission query is rejected if "userVisibleOnly" option
|
| + // isn't set or set to true.
|
| + assert_equals(e.name, "NotSupportedError");
|
| +
|
| + // Test for userVisibleOnly=false.
|
| + return navigator.permissions.revoke({name:'push', userVisibleOnly: false});
|
| + }).catch(function(e) {
|
| + // By default, the permission query is rejected if "userVisibleOnly" option
|
| + // isn't set or set to true.
|
| + assert_equals(e.name, "NotSupportedError");
|
| +
|
| + // Test for userVisibleOnly=true.
|
| + return navigator.permissions.revoke({name:'push', userVisibleOnly: true});
|
| + }).then(function(result) {
|
| + assert_true(result instanceof PermissionStatus);
|
| + assert_equals(result.status, 'denied');
|
| + test.done();
|
| + }).catch(function() {
|
| + assert_unreached('querying push permission should not fail.')
|
| + });
|
| +}, 'Test push permission in ' + get_current_scope() + ' scope.');
|
| +
|
| +done();
|
|
|