summaryrefslogtreecommitdiffstats
path: root/dom/security/test/csp/file_navigate_to.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/security/test/csp/file_navigate_to.sjs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/security/test/csp/file_navigate_to.sjs')
-rw-r--r--dom/security/test/csp/file_navigate_to.sjs49
1 files changed, 49 insertions, 0 deletions
diff --git a/dom/security/test/csp/file_navigate_to.sjs b/dom/security/test/csp/file_navigate_to.sjs
new file mode 100644
index 0000000000..d3b3b1c2b1
--- /dev/null
+++ b/dom/security/test/csp/file_navigate_to.sjs
@@ -0,0 +1,49 @@
+// Custom *.sjs file specifically for the needs of
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1529068
+
+"use strict";
+Components.utils.importGlobalProperties(["URLSearchParams"]);
+
+const TEST_NAVIGATION_HEAD = `
+ <!DOCTYPE HTML>
+ <html>
+ <head>
+ <title>Bug 1529068 Implement CSP 'navigate-to' directive</title>`;
+
+const TEST_NAVIGATION_AFTER_META = `
+ </head>
+ <body>
+ <script type="text/javascript">
+ window.location = "`;
+
+const TEST_NAVIGATION_FOOT = `";
+ </script>
+ </body>
+ </html>
+ `;
+
+function handleRequest(request, response) {
+ const query = new URLSearchParams(request.queryString);
+
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "text/html", false);
+
+ if (query.get("redir")) {
+ response.setStatusLine(request.httpVersion, "302", "Found");
+ response.setHeader("Location", query.get("redir"), false);
+ return;
+ }
+
+ response.write(TEST_NAVIGATION_HEAD);
+
+ // We need meta to set multiple CSP headers.
+ if (query.get("csp")) {
+ response.write("<meta http-equiv=\"Content-Security-Policy\" content=\""+query.get("csp")+"\">");
+ }
+ if (query.get("csp2")) {
+ response.write("<meta http-equiv=\"Content-Security-Policy\" content=\""+query.get("csp2")+"\">");
+ }
+
+ response.write(TEST_NAVIGATION_AFTER_META + query.get("target") + TEST_NAVIGATION_FOOT);
+
+}