summaryrefslogtreecommitdiffstats
path: root/dom/security/test/csp/test_csp_frame_ancestors_about_blank.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 /dom/security/test/csp/test_csp_frame_ancestors_about_blank.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 'dom/security/test/csp/test_csp_frame_ancestors_about_blank.html')
-rw-r--r--dom/security/test/csp/test_csp_frame_ancestors_about_blank.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/security/test/csp/test_csp_frame_ancestors_about_blank.html b/dom/security/test/csp/test_csp_frame_ancestors_about_blank.html
new file mode 100644
index 0000000000..8f57d9e133
--- /dev/null
+++ b/dom/security/test/csp/test_csp_frame_ancestors_about_blank.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Bug 1668071 - CSP frame-ancestors in about:blank</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<script class="testbody" type="text/javascript">
+
+/* Description of the test:
+ * We dynamically load an about:blank iframe which then loads a testframe
+ * including a CSP frame-ancestors directive which matches the including
+ * security context. We make sure that we not incorrectly block on
+ * about:blank which should inherit the security context.
+ */
+
+SimpleTest.waitForExplicitFinish();
+
+let aboutBlankFrame = document.createElement("iframe");
+document.body.appendChild(aboutBlankFrame);
+
+aboutBlankFrame.onload = function() {
+ ok(true, "aboutBlankFrame onload should fire");
+ let aboutBlankDoc = aboutBlankFrame.contentDocument;
+ is(aboutBlankDoc.documentURI, "about:blank",
+ "sanity: aboutBlankFrame URI should be about:blank");
+
+ let testframe = aboutBlankDoc.createElement("iframe");
+ aboutBlankDoc.body.appendChild(testframe);
+ testframe.onload = function() {
+ ok(true, "testframe onload should fire");
+ let testDoc = SpecialPowers.wrap(testframe.contentDocument);
+ ok(testDoc.documentURI.endsWith("file_csp_frame_ancestors_about_blank.html"),
+ "sanity: document in testframe should be the testfile");
+
+ let cspJSON = testDoc.cspJSON;
+ ok(cspJSON.includes("frame-ancestors"), "found frame-ancestors directive");
+ ok(cspJSON.includes("http://mochi.test:8888"), "found frame-ancestors value");
+
+ SimpleTest.finish();
+ }
+
+ testframe.onerror = function() {
+ ok(false, "testframe onerror should not fire");
+ }
+ testframe.src = "file_csp_frame_ancestors_about_blank.html";
+}
+
+aboutBlankFrame.onerror = function() {
+ ok(false, "aboutBlankFrame onerror should not be called");
+}
+aboutBlankFrame.src = "about:blank";
+
+</script>
+</body>
+</html>