Skip to content

Commit d064974

Browse files
mikewestchromium-wpt-export-bot
authored andcommitted
CSP: Add a test for * in pattern's host-part.
This tests the change made in w3c/webappsec-csp#657. Bug: 334278797 Change-Id: I7ecab785ac44456af00d0ec1af3f6d09aac02782 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5471523 Reviewed-by: Antonio Sartori <[email protected]> Commit-Queue: Mike West <[email protected]> Cr-Commit-Position: refs/heads/main@{#1291742}
1 parent 040954d commit d064974

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
setup(_ => {
2+
const meta = document.createElement("meta");
3+
meta.httpEquiv = "content-security-policy";
4+
meta.content = "img-src http://*:{{ports[http][0]}}";
5+
document.head.appendChild(meta);
6+
});
7+
8+
async_test((t) => {
9+
const img = document.createElement("img");
10+
img.onerror = t.step_func_done();
11+
img.onload = t.unreached_func("`data:` image should have been blocked.");
12+
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
13+
}, "Host wildcard doesn't affect scheme matching.");
14+
15+
async_test((t) => {
16+
const img = document.createElement("img");
17+
img.onload = t.step_func_done();
18+
img.onerror = t.unreached_func("Image from www2 host should have loaded.");
19+
img.src = "http://{{domains[www1]}}:{{ports[http][0]}}/content-security-policy/support/pass.png";
20+
}, "Host wildcard allows arbitrary hosts (www1).");
21+
22+
async_test((t) => {
23+
const img = document.createElement("img");
24+
img.onload = t.step_func_done();
25+
img.onerror = t.unreached_func("Image from www2 host should have loaded.");
26+
img.src = "http://{{domains[www2]}}:{{ports[http][0]}}/content-security-policy/support/pass.png";
27+
}, "Host wildcard allows arbitrary hosts (www2).");

0 commit comments

Comments
 (0)