Automatic update from web-platform-tests Fire error events for invalid speculation rules This CL introduces error handling for <script type=speculationrules>, mirroring the behavior of <script type=importmap>. Specifically, it adds error events for two cases: - Inline speculation rules with unparsable JSON. - External speculation rules, which are not yet supported. This is verified by new web platform tests. This follows the spec change at https://github.com/whatwg/html/pull/11426. Change-Id: I9b0776b86059f6c8734d57c17f50ed26e89215da Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6758353 Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Commit-Queue: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1488632} -- wpt-commits: 1d91c36a40b59a975a869f4d5749ff3004839dab wpt-pr: 53821
37 lines
1.5 KiB
HTML
37 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
window.markupErrored = false;
|
|
window.markupLoaded = false;
|
|
</script>
|
|
<script src="resources/empty.json" type="speculationrules" onload="window.markupLoaded = true;" onerror="window.markupErrored = true;"></script>
|
|
<script>
|
|
promise_test(async () => {
|
|
await new Promise((resolve, reject) => {
|
|
const element = document.createElement("script");
|
|
element.onload = () => { reject("Got an unexpected load event"); };
|
|
element.onerror = () => { resolve("Got an error event"); };
|
|
element.src = "resources/empty.json";
|
|
element.type = "speculationrules";
|
|
document.head.appendChild(element);
|
|
})
|
|
}, "Test that an external speculation rules script fires an error event");
|
|
|
|
promise_test(async () => {
|
|
await new Promise((resolve, reject) => {
|
|
const element = document.createElement("script");
|
|
element.type = "speculationrules";
|
|
element.onload = () => { reject("Got an unexpected load event"); };
|
|
element.onerror = () => { resolve("Got an error event"); };
|
|
element.src = "resources/empty.json";
|
|
document.head.appendChild(element);
|
|
})
|
|
}, "Test that an external speculation rules script fires an error event, regardless of attribute order");
|
|
|
|
promise_test(async () => {
|
|
assert_true(window.markupErrored, "error");
|
|
assert_false(window.markupLoaded, "load");
|
|
}, "Test that an external speculation rules script in markup fires an error event");
|
|
</script>
|