custom-state-set-strong-ref.html (1171B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="timeout" content="long"> 6 <meta name="author" title="Keith Cirkel" href="mailto:wpt@keithcirkel.co.uk" /> 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/custom-elements.html#custom-state-pseudo-class" /> 8 <title>CustomStateSet doesn't crash after GC on detached node</title> 9 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script src="/common/gc.js"></script> 13 </head> 14 <body> 15 <custom-state id="myCE"></custom-state> 16 <script> 17 customElements.define('custom-state', class extends HTMLElement { 18 connectedCallback() { 19 this.elementInternals = this.attachInternals(); 20 } 21 }); 22 23 promise_test(async function() { 24 const states = myCE.elementInternals.states; 25 myCE.remove(); 26 await garbageCollect(); 27 states.add('still-works'); 28 assert_equals(states.size, 1); 29 assert_true(states.delete('still-works')); 30 assert_equals(states.size, 0); 31 }, "customstateset doesn't crash after GC on detached node"); 32 </script> 33 </body> 34 </html>