Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /custom-elements/reactions/with-exceptions.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Custom Elements: CEReactions interaction with exceptions</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/custom-elements-helpers.js"></script>
<div id="log"></div>
<script>
"use strict";
test_with_window((contentWindow, contentDocument) => {
let reactionRan = false;
contentWindow.customElements.define("custom-element", class extends contentWindow.HTMLElement {
disconnectedCallback() {
reactionRan = true;
}
});
const text = contentDocument.createTextNode("");
contentDocument.documentElement.appendChild(text);
const element = contentDocument.createElement("custom-element");
contentDocument.documentElement.appendChild(element);
assert_throws_dom(
"HierarchyRequestError",
contentWindow.DOMException,
() => text.before("", contentDocument.documentElement)
);
assert_true(reactionRan);
}, "Reaction must run even after the exception is thrown");
</script>