Skip to content

Commit 5fed9e8

Browse files
fred-wangchromium-wpt-export-bot
authored andcommitted
[compression-dictionary] Add WPT test to ensure integrity attribute is ignored.
See https://html.spec.whatwg.org/#attr-link-integrity Bug: 522338661, 40255884 Change-Id: I2454f5305b855b21ca40c2177fabb7ecbf2e9a2e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8117450 Commit-Queue: Frédéric Wang Nélar <fwang@igalia.com> Reviewed-by: Patrick Meenan <pmeenan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1664905}
1 parent 6e795c4 commit 5fed9e8

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<title>link rel=compression-dictionary, integrity attribute</title>
3+
<meta name="timeout" content="long"/>
4+
<link rel="help" href="https://github.com/whatwg/html/pull/11620">
5+
<link rel="help" href="https://html.spec.whatwg.org/#create-link-options-from-element">
6+
<link rel="help" href="https://html.spec.whatwg.org/#attr-link-integrity">
7+
<link rel="help" href="https://fetch.spec.whatwg.org/#concept-request-integrity-metadata">
8+
<script src="/resources/testharness.js"></script>
9+
<script src="/resources/testharnessreport.js"></script>
10+
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
11+
<script src="./resources/compression-dictionary-util.sub.js"></script>
12+
<script>
13+
let frame;
14+
15+
// Set up the service worker and the frame.
16+
promise_test(t => {
17+
const kScope = 'resources/empty.https.html';
18+
const kScript = 'resources/fetch-options-worker.js';
19+
return service_worker_unregister_and_register(t, kScript, kScope)
20+
.then(registration => {
21+
add_completion_callback(() => {
22+
registration.unregister();
23+
});
24+
25+
return wait_for_state(t, registration.installing, 'activated');
26+
})
27+
.then(() => {
28+
return with_iframe(kScope);
29+
})
30+
.then(f => {
31+
frame = f;
32+
add_completion_callback(() => { f.remove(); });
33+
});
34+
}, 'Initialize global state');
35+
36+
compression_dictionary_promise_test(async t => {
37+
await new Promise((resolve, reject) => {
38+
let node = frame.contentWindow.document.createElement("link");
39+
node.rel = "compression-dictionary";
40+
node.onload = resolve;
41+
node.onerror = reject;
42+
node.setAttribute("integrity", "sha256-abc123");
43+
node.href = "dummy?integrity=";
44+
frame.contentWindow.document.body.appendChild(node);
45+
}).catch(() => {
46+
assert_unreached("Fetch errored.");
47+
});
48+
}, 'HTMLLinkElement rel=compression-dictionary, integrity attribute is ignored.');
49+
50+
</script>

fetch/compression-dictionary/resources/fetch-options-worker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ self.addEventListener('fetch', function(event) {
33
const params = new URL(event.request.url).searchParams;
44
const credentials = params.get("credentials");
55
const mode = params.get("mode");
6+
const integrity = params.get('integrity');
67
const referrer = params.get('referrer');
78
const referrerPolicy = params.get('referrerPolicy');
89
if ((credentials === null || credentials == event.request.credentials) &&
910
(mode === null || mode == event.request.mode) &&
11+
(integrity === null || integrity == event.request.integrity) &&
1012
(referrer === null || referrer == event.request.referrer) &&
1113
(referrerPolicy === null ||
1214
referrerPolicy == event.request.referrerPolicy)) {

0 commit comments

Comments
 (0)