with-exceptions.html (1353B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Custom Elements: CEReactions interaction with exceptions</title> 4 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> 5 <meta name="help" content="https://html.spec.whatwg.org/multipage/#cereactions"> 6 <meta name="help" content="https://github.com/whatwg/html/pull/3235"> 7 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="../resources/custom-elements-helpers.js"></script> 11 12 <div id="log"></div> 13 14 <script> 15 "use strict"; 16 // Basically from https://github.com/whatwg/html/issues/3217#issuecomment-343633273 17 test_with_window((contentWindow, contentDocument) => { 18 let reactionRan = false; 19 contentWindow.customElements.define("custom-element", class extends contentWindow.HTMLElement { 20 disconnectedCallback() { 21 reactionRan = true; 22 } 23 }); 24 const text = contentDocument.createTextNode(""); 25 contentDocument.documentElement.appendChild(text); 26 const element = contentDocument.createElement("custom-element"); 27 contentDocument.documentElement.appendChild(element); 28 assert_throws_dom( 29 "HierarchyRequestError", 30 contentWindow.DOMException, 31 () => text.before("", contentDocument.documentElement) 32 ); 33 assert_true(reactionRan); 34 }, "Reaction must run even after the exception is thrown"); 35 </script>