Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions content-security-policy/meta/meta-append-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="img-src 'none'">
<script nonce="abc" src="/resources/testharness.js"></script>
<script nonce="abc" src="/resources/testharnessreport.js"></script>

<body>
<script nonce="abc">
promise_test(t => {
return new Promise((resolve, reject) => {
const img = document.createElement("img");
img.src = "/content-security-policy/support/fail.png";

img.onload = () => reject("Image loaded unexpectedly");
img.onerror = (e) => resolve()

document.body.appendChild(img);
});
}, "dynamic img-src is blocked by meta CSP");

promise_test(t => {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = "../resources/ran.js";

script.onload = () => reject("Script executed unexpectedly");
script.onerror = () => resolve();

document.body.appendChild(script);
});
}, "script without `abc` nonce is blocked by header CSP");
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Security-Policy: script-src 'nonce-abc'
33 changes: 33 additions & 0 deletions content-security-policy/meta/meta-multiple-csp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="script-src 'nonce-abc'">
<meta http-equiv="Content-Security-Policy" content="img-src 'none'">
<script nonce="abc" src="/resources/testharness.js"></script>
<script nonce="abc" src="/resources/testharnessreport.js"></script>

<body>
<script nonce="abc">
promise_test(t => {
return new Promise((resolve, reject) => {
const img = document.createElement("img");
img.src = "/content-security-policy/support/fail.png";

img.onload = () => reject("Image loaded unexpectedly");
img.onerror = (e) => resolve()

document.body.appendChild(img);
});
}, "dynamic img-src is blocked by meta CSP");

promise_test(t => {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = "../resources/ran.js";

script.onload = () => reject("Script executed unexpectedly");
script.onerror = () => resolve();

document.body.appendChild(script);
});
}, "script without `abc` nonce is blocked by meta CSP");
</script>
</body>