beforematch-infinite-loop.html (1166B)
1 <!DOCTYPE html> 2 <link rel=author href="mailto:jarhar@chromium.org"> 3 <link rel=help href="https://html.spec.whatwg.org/#ancestor-revealing-algorithm"> 4 <link rel=help href="https://github.com/whatwg/html/issues/11436"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <div id=h1 hidden=until-found> 9 <div id=h1child>hidden 1</div> 10 </div> 11 <div id=h2 hidden=until-found>hidden 2</div> 12 13 <script> 14 test(() => { 15 let beforematchFired1 = false; 16 let beforematchFired2 = false; 17 h1.addEventListener('beforematch', () => { 18 beforematchFired1 = true; 19 h2.appendChild(h1); 20 }); 21 h2.addEventListener('beforematch', () => { 22 beforematchFired2 = true; 23 }); 24 25 window.location.hash = '#h1child'; 26 assert_true(beforematchFired1, 'beforematch should have been fired on h1.'); 27 assert_false(beforematchFired2, 'beforematch should not have been fired on h2.'); 28 assert_false(h1.hasAttribute('hidden'), 'h1 should not be hidden.'); 29 assert_true(h2.hasAttribute('hidden'), 'h2 should be hidden.'); 30 }, 'hidden=until-found revealing algorithm should collect elements to reveal before revealing them.'); 31 </script>