mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1197461 - Tests for Permissions.revoke. r=poiru,baku
This commit is contained in:
parent
451498e95b
commit
963f9156d9
@ -42,6 +42,28 @@ function setPermissions(action) {
|
||||
});
|
||||
}
|
||||
|
||||
function revokePermissions(action) {
|
||||
return Promise.all(PERMISSIONS.map(x =>
|
||||
navigator.permissions.revoke({ name: x.name }).then(
|
||||
result => is(result.state, "prompt", `correct state for '${x.name}'`),
|
||||
error => ok(false, `query should not have rejected for '${x.name}'`))
|
||||
));
|
||||
}
|
||||
|
||||
function revokeUnsupportedPermissions() {
|
||||
return Promise.all(UNSUPPORTED_PERMISSIONS.map(name =>
|
||||
navigator.permissions.revoke({ name: name }).then(
|
||||
result => ok(false, `revoke should not have resolved for '${name}'`),
|
||||
error => is(error.name, 'TypeError', `revoke should have thrown TypeError for '${name}'`))
|
||||
));
|
||||
}
|
||||
|
||||
function revokeUserVisiblePushPermission() {
|
||||
return navigator.permissions.revoke({ name: 'push', userVisible: true }).then(
|
||||
result => ok(false, `revoke should not have resolved for userVisible push`),
|
||||
error => ok(true, `revoke should have rejected for userVisible push`));
|
||||
}
|
||||
|
||||
function checkPermissions(state) {
|
||||
return Promise.all(PERMISSIONS.map(x => {
|
||||
return navigator.permissions.query({ name: x.name }).then(
|
||||
@ -52,7 +74,7 @@ function checkPermissions(state) {
|
||||
|
||||
function checkUnsupportedPermissions() {
|
||||
return Promise.all(UNSUPPORTED_PERMISSIONS.map(name => {
|
||||
return navigator.permissions.query({ name }).then(
|
||||
return navigator.permissions.query({ name: name }).then(
|
||||
result => ok(false, `query should not have resolved for '${name}'`),
|
||||
error => {
|
||||
is(error.name, 'TypeError',
|
||||
@ -102,6 +124,12 @@ function testInvalidQuery() {
|
||||
error => ok(true, 'invalid query should have rejected'));
|
||||
}
|
||||
|
||||
function testInvalidRevoke() {
|
||||
navigator.permissions.revoke({ name: 'invalid' }).then(
|
||||
result => ok(false, 'invalid revoke should not have resolved'),
|
||||
error => ok(true, 'invalid revoke should have rejected'));
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
checkUnsupportedPermissions()
|
||||
.then(checkUserVisiblePushPermission)
|
||||
@ -115,6 +143,11 @@ function runTests() {
|
||||
.then(() => checkPermissions('denied'))
|
||||
.then(testStatusOnChange)
|
||||
.then(testInvalidQuery)
|
||||
.then(revokeUnsupportedPermissions)
|
||||
.then(revokeUserVisiblePushPermission)
|
||||
.then(revokePermissions)
|
||||
.then(() => checkPermissions('prompt'))
|
||||
.then(testInvalidRevoke)
|
||||
.then(SimpleTest.finish)
|
||||
.catch ((e) => {
|
||||
ok(false, 'Unexpected error ' + e);
|
||||
|
Loading…
Reference in New Issue
Block a user