diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html | |
parent | Initial commit. (diff) | |
download | firefox-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 'testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html')
-rw-r--r-- | testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html b/testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html new file mode 100644 index 0000000000..53b6ee232d --- /dev/null +++ b/testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="early-hints-helpers.sub.js"></script> +<body> +<script> +const SEARCH_PARAMS = new URLSearchParams(window.location.search); +const POLICY = SEARCH_PARAMS.get("early-hints-policy"); + +promise_test(async (t) => { + const resource_url = SEARCH_PARAMS.get("resource-url"); + + // Resume the delayed preload. + const resume_url = SEARCH_PARAMS.get("resume-url"); + await fetch(resume_url); + + // Wait for the preload to finish. + await new Promise(resolve => t.step_timeout(resolve, 300)); + + // The preload should be denied by CSP. + await promise_rejects_js(t, Error, fetchScript(resource_url)); +}, `Early hints preload CSP = ${POLICY}, document disallowed the preload later.`); +</script> +</body> |