Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!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>
<!-- rel=compression-dictionary does not have a default type, so it should
always fetch the link when the type is omitted. When the type is specified
the same is true if "UA does support the given MIME type for the given link
relationship" and "even if that is not a valid MIME type string". Details
don't seem to be specified but this test assumes UAs support any type for
rel=compression-dictionary. -->
<link id="defaultType" rel="compression-dictionary" href="./resources/register-dictionary.py?defaultType"> <!-- type attribute omitted -->
<link id="emptyType" rel="compression-dictionary" href="./resources/register-dictionary.py?emptyType" type="">
<link id="invalidType" rel="compression-dictionary" href="./resources/register-dictionary.py?invalidType" type="invalid|type">
<link id="unsupportedType" rel="compression-dictionary" href="./resources/register-dictionary.py?unsupportedType" type="not/supported">
<link id="cssType" rel="compression-dictionary" href="./resources/register-dictionary.py?cssType" type="text/css">
<link id="htmlType" rel="compression-dictionary" href="./resources/register-dictionary.py?htmlType" type="text/html">
<link id="javascriptType" rel="compression-dictionary" href="./resources/register-dictionary.py?javascriptType" type="text/javascript">
<body>
<script>
let fetchedDictionaries = [];
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach(entry => {
const url = new URL(entry.name);
if (url.pathname == "/fetch/compression-dictionary/resources/register-dictionary.py") {
fetchedDictionaries.push(url.search);
}
});
});
observer.observe({ type: "resource", buffered: true });
compression_dictionary_promise_test(async t => {
// Initially fetched dictionaries.
let expectedEntries = [
"?cssType",
"?defaultType",
"?emptyType",
"?htmlType",
"?invalidType",
"?javascriptType",
"?unsupportedType",
];
await t.step_wait(_ => fetchedDictionaries.length >= expectedEntries.length, "All <link rel=compression-dictionary> elements should trigger dictionary fetches regardless of their type attribute", 5000);
assert_array_equals(fetchedDictionaries.toSorted(), expectedEntries, "All <link rel=compression-dictionary> elements should trigger dictionary fetches regardless of their type attribute.");
fetchedDictionaries = [];
await new Promise(resolve => step_timeout(resolve, 1000));
assert_equals(fetchedDictionaries.length, 0, "no more dictionary fetched.");
}, "<link rel=compression-dictionary> are fetched independently of the type.");
</script>
</body>