mirror of
https://github.com/mozilla-firefox/firefox
synced 2026-08-12 20:45:22 +00:00
Automatic update from web-platform-tests [CSS Modules] Fix CHECK when styles are preloaded from the cache When style modules are preloaded from the cache, there's a ScriptForbiddenScope deep in the stack that gets hit. This change fixes the CHECK by allowing user agent scripts for this scenario. A test was added that hits the DCHECK without this fix. Bug: 466888680 Change-Id: Idd58b9a672c2f73eb913745fdf1390de55a9e3ba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7536427 Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Reviewed-by: Yoav Weiss (@Shopify) <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/main@{#1587277} -- wpt-commits: 0a629eb83adb02e0883c869a6ba7a36a4236c988 wpt-pr: 57887
72 lines
2.7 KiB
HTML
72 lines
2.7 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<link rel="modulepreload" as="style" href="resources/dummy.css">
|
|
<link rel="modulepreload" as="style" href="resources/dummy.css">
|
|
<link rel="modulepreload" as="json" href="resources/dummy.json">
|
|
<link rel="modulepreload" as="json" href="resources/dummy.json">
|
|
<link rel="modulepreload" href="resources/dummy.js">
|
|
<link rel="modulepreload" href="resources/dummy.js">
|
|
<body>
|
|
<script>
|
|
function createModulePreload(type) {
|
|
const link = document.createElement('link');
|
|
link.rel = 'modulepreload';
|
|
|
|
if(type === 'style') {
|
|
link.as = 'style';
|
|
link.href = 'resources/dummy.css';
|
|
} else if (type === 'json') {
|
|
link.as = 'json';
|
|
link.href = 'resources/dummy.json';
|
|
} else {
|
|
link.href = 'resources/dummy.js';
|
|
}
|
|
return link;
|
|
}
|
|
|
|
function attachAndWaitForLoad(element) {
|
|
return new Promise((resolve, reject) => {
|
|
element.onload = resolve;
|
|
element.onerror = reject;
|
|
document.body.appendChild(element);
|
|
});
|
|
}
|
|
|
|
promise_test(function(t) {
|
|
const first_preload = createModulePreload('style');
|
|
return attachAndWaitForLoad(first_preload).then(() => {
|
|
const second_preload = createModulePreload('style');
|
|
return attachAndWaitForLoad(second_preload).then(() => {
|
|
const absoluteURL = new URL(second_preload.href, second_preload.href).href;
|
|
assert_equals(performance.getEntriesByName(absoluteURL).length, 1, absoluteURL);
|
|
});
|
|
});
|
|
}, 'multiple style preloads of the same file do not cause errors');
|
|
|
|
|
|
promise_test(function(t) {
|
|
const first_preload = createModulePreload('json');
|
|
return attachAndWaitForLoad(first_preload).then(() => {
|
|
const second_preload = createModulePreload('json');
|
|
return attachAndWaitForLoad(second_preload).then(() => {
|
|
const absoluteURL = new URL(second_preload.href, second_preload.href).href;
|
|
assert_equals(performance.getEntriesByName(absoluteURL).length, 1, absoluteURL);
|
|
});
|
|
});
|
|
}, 'multiple json preloads of the same file do not cause errors');
|
|
|
|
|
|
promise_test(function(t) {
|
|
const first_preload = createModulePreload();
|
|
return attachAndWaitForLoad(first_preload).then(() => {
|
|
const second_preload = createModulePreload();
|
|
return attachAndWaitForLoad(second_preload).then(() => {
|
|
const absoluteURL = new URL(second_preload.href, second_preload.href).href;
|
|
assert_equals(performance.getEntriesByName(absoluteURL).length, 1, absoluteURL);
|
|
});
|
|
});
|
|
}, 'multiple script preloads of the same file do not cause errors');
|
|
</script>
|