Skip to content

Commit f8a77c5

Browse files
fred-wangChromium LUCI CQ
authored andcommitted
[compression dictionary] Add WPT test to check fetch timing for <link> element and DOM operations.
This is currently not specified but there some discussions happening at whatwg/html#11620 crossorigin mutation will be handled in a follow-up CL. Bug: 522338661, 40255884 Change-Id: I6e473e56b7b2b79d3a037001644ac89b598cd4ae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8029960 Reviewed-by: Patrick Meenan <pmeenan@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Commit-Queue: Frédéric Wang Nélar <fwang@igalia.com> Cr-Commit-Position: refs/heads/main@{#1656392}
1 parent 2d03bcd commit f8a77c5

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

third_party/blink/web_tests/VirtualTestSuites

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,6 +3645,7 @@
36453645
"external/wpt/css/cssom-view/overflow-hidden-smooth-scroll-crash.html",
36463646
"external/wpt/css/cssom-view/scroll-behavior-smooth-after-hiding-iframe.html",
36473647
"external/wpt/fetch/compression-dictionary/dictionary-fetch-timing-001.tentative.https.html",
3648+
"external/wpt/fetch/compression-dictionary/dictionary-fetch-timing-002.tentative.https.html",
36483649
"external/wpt/fetch/compression-dictionary/dictionary-fetch-with-link-element.tentative.https.html",
36493650
"external/wpt/fetch/compression-dictionary/dictionary-fetch-with-link-header.tentative.https.html",
36503651
"external/wpt/html/canvas/element/manual/draw-element-image",
@@ -3690,6 +3691,7 @@
36903691
],
36913692
"exclusive_tests": [
36923693
"external/wpt/fetch/compression-dictionary/dictionary-fetch-timing-001.tentative.https.html",
3694+
"external/wpt/fetch/compression-dictionary/dictionary-fetch-timing-002.tentative.https.html",
36933695
"external/wpt/fetch/compression-dictionary/dictionary-fetch-with-link-element.tentative.https.html",
36943696
"external/wpt/fetch/compression-dictionary/dictionary-fetch-with-link-header.tentative.https.html",
36953697
"external/wpt/permissions-policy/experimental-features/vertical-scroll-touch-block-manual.tentative.html",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<meta charset="utf-8">
4+
<meta name="timeout" content="long"/>
5+
<script src="./resources/compression-dictionary-util.sub.js"></script>
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<link rel="help" href="https://github.com/whatwg/html/pull/11620">
9+
<link id="alreadyBrowsingContextConnected" rel="compression-dictionary" href="./resources/register-dictionary.py?alreadyBrowsingContextConnected"></link>
10+
<script>
11+
const dynamicallyConnected = document.createElement('link');
12+
dynamicallyConnected.rel = 'compression-dictionary';
13+
dynamicallyConnected.href = `${kRegisterDictionaryPath}?linkDynamicallyBrowsingContextConnected`;
14+
</script>
15+
<link id="hrefDynamicallySet" rel="compression-dictionary"></link>
16+
<link id="hrefDynamicallyChanged" rel="compression-dictionary" href="./resources/register-dictionary.py?hrefDynamicallyChanged"></link>
17+
<body>
18+
<script>
19+
let fetchedDictionaries = [];
20+
const observer = new PerformanceObserver((list) => {
21+
list.getEntries().forEach(entry => {
22+
const url = new URL(entry.name);
23+
if (url.pathname == "/fetch/compression-dictionary/resources/register-dictionary.py") {
24+
fetchedDictionaries.push(url.search);
25+
}
26+
});
27+
});
28+
observer.observe({ type: "resource", buffered: true});
29+
30+
compression_dictionary_promise_test(async t => {
31+
// Initially fetched dictionaries.
32+
let expectedEntries = [
33+
"?alreadyBrowsingContextConnected",
34+
"?hrefDynamicallyChanged",
35+
];
36+
await t.step_wait(_ => fetchedDictionaries.length >= expectedEntries.length, "initially browsing-context connected <link> should trigger fetch", 5000);
37+
assert_array_equals(fetchedDictionaries.toSorted(), expectedEntries, "dictionaries fetched for initially browsing-context connected <link>.");
38+
fetchedDictionaries = [];
39+
await new Promise(resolve => step_timeout(resolve, 1000));
40+
assert_equals(fetchedDictionaries.length, 0, "no more dictionary fetched.");
41+
42+
// browsing-context connected change.
43+
expectedEntries = [
44+
"?linkDynamicallyBrowsingContextConnected",
45+
];
46+
document.head.appendChild(dynamicallyConnected);
47+
await t.step_wait(_ => fetchedDictionaries.length >= expectedEntries.length, "browsing-context connecting a link should trigger fetch", 5000);
48+
assert_array_equals(fetchedDictionaries.toSorted(), expectedEntries, "dictionary fetched after <link> becomes browsing-context connected.");
49+
fetchedDictionaries = [];
50+
51+
// Dynamic changes to href.
52+
expectedEntries = [
53+
"?hrefDynamicallyChangedBis",
54+
"?hrefDynamicallySet",
55+
];
56+
hrefDynamicallySet.setAttribute("href", `${kRegisterDictionaryPath}?hrefDynamicallySet`);
57+
hrefDynamicallyChanged.setAttribute("href", `${kRegisterDictionaryPath}?hrefDynamicallyChangedBis`);
58+
await t.step_wait(_ => fetchedDictionaries.length >= expectedEntries.length, "modifying href should trigger fetch", 5000);
59+
assert_array_equals(fetchedDictionaries.toSorted(), expectedEntries, "dictionaries fetched after dynamic changes to href attribute.");
60+
fetchedDictionaries = [];
61+
62+
}, "<link rel=compression-dictionary> are fetched after DOM operations.");
63+
</script>
64+
</body>

0 commit comments

Comments
 (0)