summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_csp_json.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/client/jsonview/test/browser_jsonview_csp_json.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/jsonview/test/browser_jsonview_csp_json.js')
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_csp_json.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/browser_jsonview_csp_json.js b/devtools/client/jsonview/test/browser_jsonview_csp_json.js
new file mode 100644
index 0000000000..418ffcd3dd
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_csp_json.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "csp_json.json";
+
+add_task(async function() {
+ info("Test CSP JSON started");
+
+ const tab = await addJsonViewTab(TEST_JSON_URL);
+
+ const count = await getElementCount(".jsonPanelBox .treeTable .treeRow");
+ is(count, 1, "There must be one row");
+
+ // The JSON Viewer alters the CSP, but the displayed header should be the original one
+ await selectJsonViewContentTab("headers");
+ await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
+ const responseHeaders = content.document.querySelector(".netHeadersGroup");
+ const names = responseHeaders.querySelectorAll(".netInfoParamName");
+ let found = false;
+ for (const name of names) {
+ if (name.textContent.toLowerCase() == "content-security-policy") {
+ ok(!found, "The CSP header only appears once");
+ found = true;
+ const value = name.nextElementSibling.textContent;
+ const expected = "default-src 'none'; base-uri 'none';";
+ is(value, expected, "The CSP value has not been altered");
+ }
+ }
+ ok(found, "The CSP header is present");
+ });
+});