summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html')
-rw-r--r--testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html b/testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html
new file mode 100644
index 0000000000..cb460d161e
--- /dev/null
+++ b/testing/web-platform/tests/fenced-frame/serviceWorker-push.https.html
@@ -0,0 +1,62 @@
+<!doctype html>
+<html>
+<head>
+<title>Service Worker: Push Messaging Test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/common/utils.js"></script>
+<script src="/common/dispatcher/dispatcher.js"></script>
+<script src="resources/utils.js"></script>
+</head>
+<body>
+<script>
+ promise_test(async () => {
+ const frame = attachFencedFrameContext();
+ try {
+ await frame.execute(async () => {
+ await navigator.serviceWorker.register(
+ 'empty-worker.js', { scope: location.href });
+ const registration= await navigator.serviceWorker.ready;
+ return await registration.pushManager.subscribe({
+ userVisibleOnly: true
+ });
+ });
+ assert_unreached('subscribe() executed without error; want error');
+ } catch(e) {
+ assert_equals(e.message,
+ "Failed to execute 'subscribe' on 'PushManager': subscribe() is not " +
+ "allowed in fenced frames.");
+ }
+ }, 'subscribe() should fail inside a fenced frame');
+
+ promise_test(async () => {
+ const frame = attachFencedFrameContext();
+ const message = await frame.execute(async () => {
+ const getController = () => {
+ if (navigator.serviceWorker.controller) {
+ return navigator.serviceWorker.controller;
+ }
+ return new Promise(resolve => {
+ navigator.serviceWorker.addEventListener('controllerchange', () => {
+ resolve(navigator.serviceWorker.controller);
+ });
+ });
+ };
+ await navigator.serviceWorker.register(
+ 'serviceWorker-push-sw.js', { scope: location.href });
+ return new Promise(async resolve => {
+ const ctrl = await getController();
+ ctrl.postMessage('subscribe');
+ navigator.serviceWorker.onmessage = e => {
+ resolve(e.data);
+ }
+ });
+ });
+ assert_equals(message, "Failed to execute 'subscribe' on " +
+ "'PushManager': subscribe() is not allowed in fenced frames.");
+ }, 'subscribe() should fail from the service worker inside a fenced frame');
+</script>
+</body>
+</html>