diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html | |
parent | Initial commit. (diff) | |
download | thunderbird-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 'testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html')
-rw-r--r-- | testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html b/testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html new file mode 100644 index 0000000000..39126de58f --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_double_policy_honor_source_expressions.sub.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> + +<head> + <title>Source expressions in a separate policy are honored with `strict-dynamic` in the script-src directive.</title> + <script src='/resources/testharness.js' nonce='dummy'></script> + <script src='/resources/testharnessreport.js' nonce='dummy'></script> + + <!-- CSP served: + 1) Content-Security-Policy: script-src 'strict-dynamic' 'nonce-dummy' + 2) Content-Security-Policy: script-src 'self' 'nonce-dummy' + --> +</head> + +<body> + <h1>Source expressions in a separate policy are honored with `strict-dynamic` in the script-src directive.</h1> + <div id='log'></div> + + <script nonce='dummy'> + async_test(function(t) { + window.addEventListener('message', t.step_func(function(e) { + if (e.data === 'allowed-appendChild') { + t.done(); + } + })); + window.addEventListener('securitypolicyviolation', t.step_func(function(violation) { + if (violation.blockedURI.split('?')[1] !== 'allowed-appendChild') { + return; + } + assert_unreached('Script injected via `appendChild` is permitted with `strict-dynamic` + a nonce+allowed double policy.'); + })); + + var e = document.createElement('script'); + e.id = 'allowed-appendChild'; + e.src = 'simpleSourcedScript.js?' + e.id; + e.onerror = t.unreached_func('Error should not be triggered.'); + document.body.appendChild(e); + }, 'Script injected via `appendChild` is permitted with `strict-dynamic` + a nonce+allowed double policy.'); + </script> + + <script nonce='dummy'> + async_test(function(t) { + window.addEventListener('securitypolicyviolation', t.step_func(function(violation) { + if (violation.blockedURI.split('?')[1] !== 'nonAllowed-appendChild') { + return; + } + assert_equals(violation.effectiveDirective, 'script-src-elem'); + assert_equals(violation.originalPolicy, "script-src 'self' 'nonce-dummy'"); + t.done(); + })); + + var e = document.createElement('script'); + e.id = 'nonAllowed-appendChild'; + e.src = '{{location[scheme]}}://{{domains[www2]}}:{{ports[http][0]}}/nonexisting.js?' + e.id; + e.onload = t.unreached_func('OnLoad should not be triggered.'); + document.body.appendChild(e); + }, 'Non-allowed script injected via `appendChild` is not permitted with `strict-dynamic` + a nonce+allowed double policy.'); + </script> +</body> + +</html> |