diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/serviceworkers/test/open_window | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/serviceworkers/test/open_window')
-rw-r--r-- | dom/serviceworkers/test/open_window/client.sjs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/open_window/client.sjs b/dom/serviceworkers/test/open_window/client.sjs new file mode 100644 index 0000000000..236a4a1226 --- /dev/null +++ b/dom/serviceworkers/test/open_window/client.sjs @@ -0,0 +1,69 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const RESPONSE = ` +<!DOCTYPE HTML> +<html> +<head> + <title>Bug 1172870 - page opened by ServiceWorkerClients.OpenWindow</title> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"></div> +<pre id="test"></pre> +<h1>client.sjs</h1> +<script class="testbody" type="text/javascript"> + + window.onload = function() { + if (document.domain === "mochi.test") { + navigator.serviceWorker.ready.then(function(result) { + navigator.serviceWorker.onmessage = function(event) { + if (event.data !== "CLOSE") { + dump("ERROR: unexepected reply from the service worker.\\n"); + } + if (parent) { + parent.postMessage("CLOSE", "*"); + } + window.close(); + } + + let message = window.crossOriginIsolated ? "NEW_ISOLATED_WINDOW" : "NEW_WINDOW"; + navigator.serviceWorker.controller.postMessage(message); + }) + } else { + window.onmessage = function(event) { + if (event.data !== "CLOSE") { + dump("ERROR: unexepected reply from the iframe.\\n"); + } + window.close(); + } + + var iframe = document.createElement('iframe'); + iframe.src = "http://mochi.test:8888/tests/dom/serviceworkers/test/open_window/client.sjs"; + document.body.appendChild(iframe); + } + } + +</script> +</pre> +</body> +</html> +`; + +function handleRequest(request, response) { + Components.utils.importGlobalProperties(["URLSearchParams"]); + let query = new URLSearchParams(request.queryString); + + // If the request has been marked to be isolated with COOP+COEP, set the appropriate headers. + if (query.get("crossOriginIsolated") == "true") { + response.setHeader("Cross-Origin-Opener-Policy", "same-origin", false); + } + + // Always set the COEP and CORP headers, so that this document can be framed + // by a document which has also set COEP to require-corp. + response.setHeader("Cross-Origin-Embedder-Policy", "require-corp", false); + response.setHeader("Cross-Origin-Resource-Policy", "cross-origin", false); + + response.setHeader("Content-Type", "text/html", false); + response.write(RESPONSE); +} |