summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html
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 /testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html')
-rw-r--r--testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html44
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html b/testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html
new file mode 100644
index 0000000000..675cd95ea4
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/child-src/child-src-worker-blocked.sub.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <title>child-src-worker-blocked</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <meta http-equiv="Content-Security-Policy" content="child-src 'none'; script-src 'unsafe-inline'; connect-src 'self';">
+</head>
+
+<body>
+ <p> This test used to check the child-src csp controlling worker creation. This behaviour has been deprecated but it's still supported
+ until the transition is done. This still tests that behaviour but we need to go through extra hoops to make sure 'script-src'
+ does not affect the result in any way (for instance by allowing 'self').
+ </p>
+ <script>
+ async_test(function(t) {
+ document.addEventListener("securitypolicyviolation", t.step_func(function(e) {
+ if (e.blockedURI != "{{location[scheme]}}://{{location[host]}}/content-security-policy/support/post-message.js")
+ return;
+
+ assert_equals(e.violatedDirective, "worker-src");
+ t.done();
+ }));
+ }, "Should throw a securitypolicyviolation event");
+
+ async_test(function(t) {
+ try {
+ var foo = new Worker('{{location[scheme]}}://{{location[host]}}/content-security-policy/support/post-message.js');
+ foo.onerror = function(event) {
+ event.preventDefault();
+ t.done();
+ }
+ foo.onmessage = function(event) {
+ assert_unreached("Should not be able to start worker");
+ };
+ } catch (e) {
+ t.done();
+ }
+ }, "Should block worker because it does not match any directive including the deprecated 'child-src'");
+ </script>
+ <div id="log"></div>
+</body>
+</html>