Files
sousa-gecko/testing/web-platform/tests/fetch/compression-dictionary/dictionary-fetch-with-link-connect-src-nonce.tentative.https.html
Frédéric Wang Nélar 29af790369 Bug 2056279 [wpt PR 61415] - [compression-dictionary] Use nonce attribute as a fetch parameter., a=testonly
Automatic update from web-platform-tests
[compression-dictionary] Use nonce attribute as a fetch parameter.

Bug: 522338661, 40255884
Change-Id: I46785fd36a4ec78df54bbb462a92a32ec923aab5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8098863
Commit-Queue: Frédéric Wang Nélar <fwang@igalia.com>
Reviewed-by: Patrick Meenan <pmeenan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1664828}

--

wpt-commits: 6f4b88171a950b6088e92446a51d0b3087226243
wpt-pr: 61415
2026-07-22 04:31:06 +00:00

49 lines
2.0 KiB
HTML

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="timeout" content="long"/>
<script src="./resources/compression-dictionary-util.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://w3c.github.io/webappsec-csp/#directive-connect-src">
<link rel="help" href="https://github.com/whatwg/fetch/pull/1854">
<link rel="help" href="https://github.com/whatwg/html/pull/11620">
<link nonce="abc" rel="compression-dictionary" href="/registration?matchingNonceFromElement">
<link nonce="def" rel="compression-dictionary" href="/registration?mismatchingNonceFromElement">
<link rel="compression-dictionary" href="/registration?missingNonceFromElement">
<script>
let blocked = [];
const observer = new ReportingObserver(reports => {
for (const report of reports) {
if (report.body.effectiveDirective === "connect-src") {
const url = new URL(report.body.blockedURL);
if (url.pathname.endsWith("registration")) {
blocked.push(url.search);
}
}
}
}, {types:["csp-violation"], buffered: true});
observer.observe();
// Link from HTTP headers are only loaded after page, so don't ever try to
// run the test before.
promise_setup(() => new Promise(resolve => {
if (document.readyState === 'complete') {
resolve();
} else {
addEventListener("load", resolve);
}
}));
promise_test(async t => {
let expectedBlocked = [
"?matchingNonceFromElement",
"?mismatchingNonceFromElement",
"?missingNonceFromElement",
"?missingNonceFromHeader",
];
await t.step_wait(_ => blocked.length >= expectedBlocked.length, "<link> violating connect-src should trigger CSP violations", 3000);
assert_array_equals(blocked.toSorted(), expectedBlocked);
}, "All <link rel=compression-dictionary> are blocked via CSP rule connect-src 'nonce-abc', even when they have a matching cryptographic nonce.");
</script>