Automatic update from web-platform-tests [compression dictionary] Add WPT test to check fetch timing for Link header and <link> element. This is currently not specified but there some discussions happening at https://github.com/whatwg/html/pull/11620 and this is important for performance reasons. Bug: 522338661, 40255884 Change-Id: Id1494aa3693b24afaf75dae4e0f5ef5909fce9e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7922747 Commit-Queue: Frédéric Wang Nélar <fwang@igalia.com> Reviewed-by: Patrick Meenan <pmeenan@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/main@{#1655866} -- wpt-commits: b62d7567fd2df9b5a40788a2e9a42f9de756fc21 wpt-pr: 61030
47 lines
2.5 KiB
HTML
47 lines
2.5 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://github.com/whatwg/html/pull/11620#discussion_r3385960016">
|
|
<body>
|
|
<script>
|
|
compression_dictionary_promise_test(async t => {
|
|
let sortedEvents = await new Promise(resolve => {
|
|
const iframe = document.createElement("iframe");
|
|
iframe.src = "resources/dictionary-fetch-timing-001-subframe.https.html";
|
|
window.addEventListener("message", message => resolve(message.data.sortedEvents));
|
|
document.body.appendChild(iframe);
|
|
t.add_cleanup(() => iframe.remove());
|
|
});
|
|
|
|
// First verify observed fetches and load event...
|
|
const fetchedNonDictionaryResources = [
|
|
"/common/utils.js",
|
|
"/html/semantics/document-metadata/interactions-of-styling-and-scripting/stylesheet.py?delay=1",
|
|
"/images/wide-gamut-pattern.png",
|
|
];
|
|
const fetchedLinkElement = "/fetch/compression-dictionary/resources/register-dictionary.py?linkElement";
|
|
const fetchedLinkHeader = "/fetch/compression-dictionary/resources/register-dictionary.py?linkHeader";
|
|
const loadEvent = "load event";
|
|
let expectedEvents = fetchedNonDictionaryResources.concat([fetchedLinkElement, fetchedLinkHeader, loadEvent]);
|
|
assert_array_equals(sortedEvents.toSorted(), expectedEvents.toSorted(), "Expected fetches and loaded events observed.");
|
|
|
|
// Non-dictionary resources are fetched before dictionary resources.
|
|
let indexOfLinkElement = sortedEvents.indexOf(fetchedLinkElement);
|
|
let indexOfLinkHeader = sortedEvents.indexOf(fetchedLinkHeader);
|
|
for (const resource of fetchedNonDictionaryResources) {
|
|
let indexOfResource = sortedEvents.indexOf(resource);
|
|
assert_less_than(indexOfResource, indexOfLinkElement, `${resource} fetched before link element with rel=compression-dictionary.`);
|
|
assert_less_than(indexOfResource, indexOfLinkHeader, `${resource} fetched before Link header with rel=compression-dictionary.`);
|
|
};
|
|
|
|
// Fetching link header is postponed after page load.
|
|
let indexOfLoadEvent = sortedEvents.indexOf(loadEvent);
|
|
assert_less_than(indexOfLoadEvent, indexOfLinkHeader, `Link header with rel=compression-dictionary is fetched after page load.`);
|
|
}, "Timing of compression dictionary fetches for <link> element and Link header.");
|
|
</script>
|
|
</body>
|