Automatic update from web-platform-tests [CSS Modules] Support JSON and CSS in <link type=modulepreload> Adds support for preloading JSON and CSS modules via the "as" parameter using the same fetching mechanism that script module preloads use. Basic tests are added in this CL, and more detailed tests are coming straight to WPT via https://github.com/web-platform-tests/wpt/pull/56617. Bug: 466888680 Change-Id: I3f08d7a1c48d4e46e500538b5fab32f2b4f41b02 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7216960 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Reviewed-by: Yoav Weiss (@Shopify) <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/main@{#1577402} -- wpt-commits: f0705a47664fcbabfc0410431d5e40efdccd65e7 wpt-pr: 57436
26 lines
831 B
HTML
26 lines
831 B
HTML
<!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 = 'json';
|
|
link.href = 'resources/dummy.json';
|
|
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=json should preload JSON module');
|
|
</script>
|