Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /preload/modulepreload-style.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
function attachAndWaitForLoad(element) {
return new Promise((resolve, reject) => {
element.onload = resolve;
element.onerror = reject;
document.body.appendChild(element);
});
}
promise_test(function(t) {
const link = document.createElement('link');
link.rel = 'modulepreload';
link.as = 'style';
link.href = 'resources/dummy.css';
return attachAndWaitForLoad(link).then(() => {
const absoluteURL = new URL(link.href, location.href).href;
assert_equals(performance.getEntriesByName(absoluteURL).length, 1, absoluteURL);
});
}, 'link rel=modulepreload with as=style should preload CSS module');
</script>