Automatic update from web-platform-tests Fix flakiness in compression-dictionary/compressed-large-*.https.html Use UUIDs in URLs to prevent potential race conditions with dictionary registration, resource loading and cache clearing between `compression_dictionary_promise_test`s. Even with `run_wpt_tests.py --repeat=20`, I was enable to reproduce any failure with compressed-large-resources-002.tentative.https.html, but let's tentatively remove the failure annotation. A similar issue was however observable in WebKit with equivalent command `run-webkit-tests --repeat=4` and is fixed by this change. Bug: 538228192, 40255884 Change-Id: Ib72f80f02a7a9b539cdb4c3627c1d4cabee684e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8341989 Commit-Queue: Frédéric Wang Nélar <fwang@igalia.com> Reviewed-by: Patrick Meenan <pmeenan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1691847} -- wpt-commits: 9298d21d24c022a57b8c0b60b9a609fe6b684c62 wpt-pr: 62427
115 lines
4.8 KiB
HTML
115 lines
4.8 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/get-host-info.sub.js"></script>
|
|
<script src="/common/utils.js"></script>
|
|
<script src="./resources/compression-dictionary-util.sub.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
[
|
|
"dcb",
|
|
"dcz",
|
|
].forEach(format => {
|
|
const image_dictionary = "image-001.png";
|
|
const image_compressed = `self-compressed-image-001.png.${format}`;
|
|
compression_dictionary_promise_test(async t => {
|
|
const test_id = token();
|
|
// Load the non-compressed image to register it as a dictionary for itself.
|
|
await fetchStaticResourceWithUseAsDictionaryHeader(`${image_dictionary}?id=${test_id}`, `${image_compressed}?id=${test_id}`, "image");
|
|
|
|
// Wait for another dictionary to register to give a chance for the
|
|
// previous registration to complete. That registration was not done via
|
|
// register-dictionary.py, so we can't use waitUntilPreviousRequestHeaders.
|
|
// It also uses a specific match and match-dest, so we cannot use
|
|
// checkHeaders/checkHeader because echo-headers.py won't use the registered
|
|
// dictionary (specifically we can't add echo-headers.py as an alternative
|
|
// to image_compressed, because match does not accept Regexp groups).
|
|
await registerAltDictionaryAndWait(t, `alt_${token()}`);
|
|
|
|
// Append the compressed image.
|
|
const img = document.createElement("img");
|
|
img.src = `./resources/static/${image_compressed}?id=${test_id}`;
|
|
t.add_cleanup(_ => img.remove());
|
|
await new Promise((resolve, reject) => {
|
|
img.onload = resolve;
|
|
img.onerror = _ => reject("load failed");
|
|
document.body.appendChild(img);
|
|
});
|
|
|
|
// Verify it has expected size.
|
|
const epsilon = 0.1;
|
|
assert_approx_equals(img.clientWidth, 100, epsilon);
|
|
assert_approx_equals(img.clientHeight, 100, epsilon);
|
|
}, `Loading ${image_compressed} using ${image_dictionary} as a dictionary works`);
|
|
|
|
const script_dictionary = "script-001.js";
|
|
const script_compressed = `self-compressed-script-001.js.${format}`;
|
|
compression_dictionary_promise_test(async t => {
|
|
const test_id = token();
|
|
// Load the non-compressed script to register it as a dictionary for itself.
|
|
await fetchStaticResourceWithUseAsDictionaryHeader(`${script_dictionary}?id=${test_id}`, `${script_compressed}?id=${test_id}`, "script");
|
|
|
|
// Wait for another dictionary to register to give a chance for the
|
|
// previous registration to complete. See comment above about why we can't
|
|
// use waitUntilPreviousRequestHeaders, checkHeaders or checkHeader.
|
|
await registerAltDictionaryAndWait(t, `alt_${token()}`);
|
|
|
|
// Append the compressed script.
|
|
const script = document.createElement("script");
|
|
script.src = `./resources/static/${script_compressed}?id=${test_id}`;
|
|
window.compressionDictionaryScriptLoaded = false;
|
|
t.add_cleanup(_ => {
|
|
script.remove();
|
|
window.compressionDictionaryScriptLoaded = undefined;
|
|
});
|
|
await new Promise((resolve, reject) => {
|
|
script.onload = resolve;
|
|
script.onerror = _ => reject("load failed");
|
|
document.body.appendChild(script);
|
|
});
|
|
|
|
// Verify script was executed.
|
|
assert_true(window.compressionDictionaryScriptLoaded);
|
|
}, `Loading ${script_compressed} using ${script_dictionary} as a dictionary works`);
|
|
|
|
const style_dictionary = "style-001.css";
|
|
const style_compressed = `self-compressed-style-001.css.${format}`;
|
|
compression_dictionary_promise_test(async t => {
|
|
const test_id = token();
|
|
// Load the non-compressed style to register it as a dictionary for itself.
|
|
await fetchStaticResourceWithUseAsDictionaryHeader(`${style_dictionary}?id=${test_id}`, `${style_compressed}?id=${test_id}`, "style");
|
|
|
|
// Wait for another dictionary to register to give a chance for the
|
|
// previous registration to complete. See comment above about why we can't
|
|
// use waitUntilPreviousRequestHeaders, checkHeaders or checkHeader.
|
|
await registerAltDictionaryAndWait(t, `alt_${token()}`);
|
|
|
|
// Append the compressed style and test div.
|
|
const link = document.createElement("link");
|
|
link.rel = "stylesheet";
|
|
link.href = `./resources/static/${style_compressed}?id=${test_id}`;
|
|
const div = document.createElement("div");
|
|
div.className = "green_square";
|
|
t.add_cleanup(_ => {
|
|
div.remove();
|
|
link.remove();
|
|
});
|
|
await new Promise((resolve, reject) => {
|
|
link.onload = resolve;
|
|
link.onerror = _ => reject("load failed");
|
|
document.body.appendChild(div);
|
|
document.head.appendChild(link);
|
|
});
|
|
|
|
// Verify style was applied.
|
|
assert_equals(window.getComputedStyle(div).getPropertyValue("background-color"), "rgb(0, 128, 0)");
|
|
}, `Loading ${style_compressed} using ${style_dictionary} as a dictionary works`);
|
|
});
|
|
</script>
|
|
</body>
|