Files
sousa-gecko/testing/web-platform/tests/fetch/compression-dictionary/dictionary-fetch-with-link-header-in-subresources.tentative.https.html
Frédéric Wang Nélar d4c7c30e56 Bug 2057586 [wpt PR 61516] - Fix flakiness in dictionary-fetch-with-link-header-in-subresources.tentative.https.html, a=testonly
Automatic update from web-platform-tests
Fix flakiness in dictionary-fetch-with-link-header-in-subresources.tentative.https.html

That's currently easy to reproduce with `run_wpt_tests.py --repeat=10`.
Use `token()` to work around race conditions between dictionary
registrations and cache clearing between
`compression_dictionary_promise_test`s. Also replace the use of
`registerAltDictionaryAndWait` with actual dictionary ID check to
make waiting for dictionary availability more reliable.

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

--

wpt-commits: 74cfea54b2a74d8ad599e01885a6bdfea7515306
wpt-pr: 61516
2026-07-28 08:20:10 +00:00

106 lines
4.5 KiB
HTML

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="timeout" content="long"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="./resources/compression-dictionary-util.sub.js"></script>
<link rel="help" href="https://github.com/whatwg/html/issues/11619">
<link rel="help" href="https://github.com/whatwg/fetch/pull/1409">
</head>
<body>
<script>
let fetchedDictionaries = [];
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach(entry => {
const url = new URL(entry.name);
if (url.pathname.endsWith("register-dictionary.py")) {
fetchedDictionaries.push(url.searchParams.get("subresource"));
}
});
});
observer.observe({ type: "resource", buffered: true});
function createSubresourceURL(absolute_path, subresource, dictionary_id) {
const dict_url = new URL(
`${kRegisterDictionaryPath}?subresource=${subresource}&id=${dictionary_id}`, location.href);
return `${absolute_path}?pipe=header(link,<${encodeURIComponent(dict_url.href)}>; rel="compression-dictionary")`;
}
compression_dictionary_promise_test(async t => {
const subresource = "image";
const dictionary_id = `${subresource}_${token()}`;
const url = createSubresourceURL("/common/square.png", subresource, dictionary_id);
let element = document.createElement("img");
element.src = url;
t.add_cleanup(() => {
element.remove();
fetchedDictionaries = [];
});
await new Promise(resolve => {
element.onload = resolve;
element.onerror = resolve;
document.body.appendChild(element);
});
await waitUntilHeader(t, "dictionary-id", {expected_header: `"${dictionary_id}"`});
assert_false(fetchedDictionaries.includes(subresource), `dictionary not fetched from ${subresource} subresource.`);
}, `Link rel=compression-dictionary headers on <img> subresource do not trigger any fetch request.`);
compression_dictionary_promise_test(async t => {
const subresource = "script";
const dictionary_id = `${subresource}_${token()}`;
const url = createSubresourceURL("/common/empty.js", subresource, dictionary_id);
let element = document.createElement("script");
element.src = url;
t.add_cleanup(() => {
element.remove();
fetchedDictionaries = [];
});
await new Promise(resolve => {
element.onload = resolve;
element.onerror = resolve;
document.head.appendChild(element);
});
await waitUntilHeader(t, "dictionary-id", {expected_header: `"${dictionary_id}"`});
assert_false(fetchedDictionaries.includes(subresource), `dictionary not fetched from ${subresource} subresource.`);
}, `Link rel=compression-dictionary headers on <script> subresource do not trigger any fetch request.`);
compression_dictionary_promise_test(async t => {
const subresource = "stylesheet";
const dictionary_id = `${subresource}_${token()}`;
const url = createSubresourceURL("/common/empty.css", subresource, dictionary_id);
let element = document.createElement("link");
element.rel = "stylesheet";
element.href = url;
t.add_cleanup(() => {
element.remove();
fetchedDictionaries = [];
});
await new Promise(resolve => {
element.onload = resolve;
element.onerror = resolve;
document.head.appendChild(element);
});
await waitUntilHeader(t, "dictionary-id", {expected_header: `"${dictionary_id}"`});
assert_false(fetchedDictionaries.includes(subresource), `dictionary not fetched from ${subresource} subresource.`);
}, `Link rel=compression-dictionary headers on <link rel="stylesheet"> subresource do not trigger any fetch request.`);
compression_dictionary_promise_test(async t => {
const subresource = "font";
const dictionary_id = `${subresource}_${token()}`;
const url = createSubresourceURL("/fonts/Ahem.ttf", subresource, dictionary_id);
const font = new FontFace("my-font", `url('${url}')`);
document.fonts.add(font);
t.add_cleanup(() => {
document.fonts.delete(font);
fetchedDictionaries = [];
});
await font.load();
await waitUntilHeader(t, "dictionary-id", {expected_header: `"${dictionary_id}"`});
assert_false(fetchedDictionaries.includes(subresource), `dictionary not fetched from ${subresource} subresource.`);
}, `Link rel=compression-dictionary headers on FontFace subresource do not trigger any fetch request.`);
</script>
</body>