Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /speculation-rules/prefetch/document-rules-pending-stylesheet.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Document rules registered while a stylesheet is still loading</title>
<link rel="stylesheet" href="/common/empty.css?pipe=trickle(d2)">
<script type="speculationrules">
{
"prefetch": [{
"source": "document",
"where": { "href_matches": "*prefetch.py*" },
"eagerness": "immediate"
}]
}
</script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="../resources/utils.js"></script>
<script src="resources/utils.sub.js"></script>
<body>
<script>
setup(() => assertSpeculationRulesIsSupported());
promise_test(async t => {
const url = getPrefetchUrl();
addLink(url);
await new Promise(resolve => t.step_timeout(resolve, 2000));
assert_equals(await isUrlPrefetched(url), 1, 'URL should be prefetched');
}, 'Document rules registered before a pending stylesheet loads should match links');
</script>
</body>