summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html
parentInitial commit. (diff)
downloadfirefox-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 'testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html')
-rw-r--r--testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html b/testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html
new file mode 100644
index 0000000000..92fe2dd431
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/embedded-enforcement/required-csp-header-cascade.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Embedded Enforcement: Sec-Required-CSP header.</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="support/testharness-helper.sub.js"></script>
+</head>
+<body>
+ <script>
+ var tests = [
+ { "name": "Test same policy for both iframes",
+ "csp1": "script-src 'unsafe-inline';",
+ "csp2": "script-src 'unsafe-inline';",
+ "expected1": "script-src 'unsafe-inline';",
+ "expected2": "script-src 'unsafe-inline';"},
+ { "name": "Test more restrictive policy on second iframe",
+ "csp1": "script-src 'unsafe-inline';",
+ "csp2": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected1": "script-src 'unsafe-inline';",
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test less restrictive policy on second iframe",
+ "csp1": "script-src 'unsafe-inline'; style-src 'self';",
+ "csp2": "script-src 'unsafe-inline';",
+ "expected1": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test no policy on second iframe",
+ "csp1": "script-src 'unsafe-inline'; style-src 'self';",
+ "csp2": "",
+ "expected1": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test no policy on first iframe",
+ "csp1": "",
+ "csp2": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected1": null,
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test invalid policy on first iframe (bad directive name)",
+ "csp1": "default-src http://example.com; i//nvalid-policy-name http://example.com",
+ "csp2": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected1": null,
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test invalid policy on first iframe (report directive)",
+ "csp1": "script-src 'unsafe-inline'; report-uri resources/dummy-report.php",
+ "csp2": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected1": null,
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test invalid policy on second iframe (bad directive name)",
+ "csp1": "script-src 'unsafe-inline'; style-src 'self';",
+ "csp2": "default-src http://example.com; i//nvalid-policy-name http://example.com",
+ "expected1": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ { "name": "Test invalid policy on second iframe (report directive)",
+ "csp1": "script-src 'unsafe-inline'; style-src 'self';",
+ "csp2": "script-src 'unsafe-inline'; report-uri resources/dummy-report.php",
+ "expected1": "script-src 'unsafe-inline'; style-src 'self';",
+ "expected2": "script-src 'unsafe-inline'; style-src 'self';"},
+ ];
+
+ tests.forEach(test => {
+ async_test(t => {
+ var url = generateURLStringWithSecondIframeParams(Host.SAME_ORIGIN, PolicyHeader.REQUIRED_CSP, test.csp2);
+ assert_required_csp(t, url, test.csp1, [test.expected1, test.expected2]);
+ }, "Test same origin: " + test.name);
+ });
+ </script>
+</body>
+</html>