summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html')
-rw-r--r--testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html b/testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html
new file mode 100644
index 0000000000..a0656a97a7
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/frame-ancestors/frame-ancestors-from-serviceworker.https.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
+</head>
+<body>
+ <script>
+ var t = async_test("A 'frame-ancestors' CSP directive set from a serviceworker response with a value 'none' should block rendering.");
+
+ // Register service worker.
+ var worker = 'support/service-worker.js';
+ var scope = 'support/service-worker/';
+ service_worker_unregister_and_register(t, worker, scope)
+ .then(registration => wait_for_state(t, registration.installing, 'activated'))
+ .then(() => {
+ // Load iframe.
+ var iframe = document.createElement("iframe");
+ let timer;
+ function pollForLoadCompletion() {
+ timer = t.step_timeout(() => iframeMayBeLoaded({isPoll: true}), 10);
+ }
+ function iframeMayBeLoaded({isPoll}) {
+ var failed = false;
+ clearTimeout(timer);
+ try {
+ let href = iframe.contentWindow.location.href;
+ if (isPoll && (href === "about:blank" || iframe.contentDocument.readyState !== "complete")) {
+ pollForLoadCompletion();
+ return;
+ }
+ failed = true;
+ } catch (ex) {}
+ t.step_func_done(() => assert_false(failed, "The IFrame should have been blocked. It wasn't."))();
+ };
+ iframe.addEventListener("load", () => iframeMayBeLoaded({isPoll: false}));
+ iframe.addEventListener("error", () => iframeMayBeLoaded({isPoll: false}));
+ iframe.src = "/content-security-policy/frame-ancestors/support/service-worker/frame-ancestors-none.html";
+ document.body.appendChild(iframe);
+ pollForLoadCompletion();
+ });
+ </script>
+</body>
+</html>
+