summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/loading/early-hints/resources/csp-document-disallow.html
diff options
context:
space:
mode:
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.html26
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>