diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /testing/web-platform/tests/notifications/resources/helpers.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-upstream/125.0.1.tar.xz firefox-upstream/125.0.1.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/notifications/resources/helpers.js')
-rw-r--r-- | testing/web-platform/tests/notifications/resources/helpers.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/testing/web-platform/tests/notifications/resources/helpers.js b/testing/web-platform/tests/notifications/resources/helpers.js index 8c30173336..ca44e32f7f 100644 --- a/testing/web-platform/tests/notifications/resources/helpers.js +++ b/testing/web-platform/tests/notifications/resources/helpers.js @@ -12,9 +12,24 @@ async function getActiveServiceWorker(script) { return reg; } - async function closeAllNotifications() { for (const n of await registration.getNotifications()) { n.close(); } } + +async function trySettingPermission(perm) { + try { + await test_driver.set_permission({ name: "notifications" }, perm); + } catch { + // Not all implementations support this yet, but the permission may already be set to be able to continue + } + + // Using Notification.permission instead of permissions.query() as + // some implementation without set_permission support overrides + // Notification.permission. + const permission = Notification.permission === "default" ? "prompt" : Notification.permission; + if (permission !== perm) { + throw new Error(`Should have the permission ${perm} to continue`); + } +} |