diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/push/test/test_permission_granted.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/push/test/test_permission_granted.html')
-rw-r--r-- | dom/push/test/test_permission_granted.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dom/push/test/test_permission_granted.html b/dom/push/test/test_permission_granted.html new file mode 100644 index 0000000000..418b17aada --- /dev/null +++ b/dom/push/test/test_permission_granted.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- +Tests PushManager.subscribe behavior based on permission state. +https://bugzilla.mozilla.org/show_bug.cgi?id=1847217 +TODO: Move this to WPT when we get test_driver.set_permission (bug 1524074) and Push testing infra in WPT. +--> +<meta charset="utf-8"> +<title>Push permission granted test</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/dom/push/test/test_utils.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<script> + let registration; + add_task(async function start() { + const url = "worker.js?" + Math.random(); + registration = await navigator.serviceWorker.register(url, { scope: "." }); + await waitForActive(registration); + }); + + add_task(async function test_notifications_permission_error() { + await setPushPermission(false); + + try { + await registration.pushManager.subscribe(); + ok(false, "No permission, should never proceed"); + } catch (err) { + is(err.name, "NotAllowedError", "A permission error should occur"); + } + }); + + add_task(async function test_notifications_permission_granted() { + await setPushPermission(true); + + try { + await registration.pushManager.subscribe(); + ok(false, "For now this should not proceed because of dom.push.connection.enabled=false (default for all tests)"); + } catch (err) { + is(err.name, "AbortError", "For now a connection error should occur"); + } + }); + + add_task(async function unregister() { + const result = await registration.unregister(); + ok(result, "Unregister should return true."); + }); +</script> |