diff options
Diffstat (limited to 'testing/web-platform/tests/notifications/resources')
-rw-r--r-- | testing/web-platform/tests/notifications/resources/helpers.js | 17 | ||||
-rw-r--r-- | testing/web-platform/tests/notifications/resources/shownotification-window-iframe.html | 8 |
2 files changed, 24 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`); + } +} diff --git a/testing/web-platform/tests/notifications/resources/shownotification-window-iframe.html b/testing/web-platform/tests/notifications/resources/shownotification-window-iframe.html new file mode 100644 index 0000000000..2a45e79465 --- /dev/null +++ b/testing/web-platform/tests/notifications/resources/shownotification-window-iframe.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<script> + async function showNotification() { + const registration = await navigator.serviceWorker.ready; + await registration.showNotification('foo'); + } +</script> |