Automatic update from web-platform-tests EarlyHints preload - support the integrity attribute Bug: 532843494 Change-Id: I87ed0271dbe1d9fb108729e7f26b7048f8f243e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8073744 Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> Commit-Queue: Yoav Weiss (@Shopify) <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/main@{#1660992} -- wpt-commits: e76b0677ed7663634fe894a552e51e7579c8e85e wpt-pr: 61245
33 lines
1.2 KiB
HTML
33 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset=utf-8>
|
|
<title>Early Hints preload with a matching integrity attribute</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="early-hints-helpers.sub.js"></script>
|
|
<body>
|
|
<script>
|
|
const preloads = getPreloadsFromSearchParams();
|
|
preloads.forEach((preload, i) => {
|
|
promise_test(() => {
|
|
return new Promise((resolve, reject) => {
|
|
assert_greater_than(preloads.length, i);
|
|
const el = document.createElement("script");
|
|
el.src = preload.url;
|
|
el.integrity = preload.integrity_attr;
|
|
el.onload = () => {
|
|
const name = new URL(preload.url, window.location);
|
|
assert_true(
|
|
isPreloadedByEarlyHints(name),
|
|
"resource should be preloaded via Early Hints");
|
|
resolve();
|
|
};
|
|
el.onerror =
|
|
() => reject(new Error("Failed to load " + preload.url));
|
|
document.body.appendChild(el);
|
|
});
|
|
}, `A preload with integrity='${preloads[i].integrity_attr}' in the ` +
|
|
`Early Hints Link header is preloaded and passes integrity checks`);
|
|
});
|
|
</script>
|
|
</body>
|