find-range-from-text-directive-no-reveal.html (1367B)
1 <!doctype html> 2 <title>Finding the text directive range must not reveal other hidden elements</title> 3 <meta charset=utf-8> 4 <link rel="help" href="https://bugzil.la/1970909"> 5 <link rel="help" href="https://wicg.github.io/ScrollToTextFragment/"> 6 <link rel="author" title="Jan-Niklas Jaeschke" href="mailto:jjaschke@mozilla.com"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <body> 10 11 <div id="hidden1" hidden="until-found">abc</div> 12 <details id="details1"> 13 <summary>First Section</summary> 14 <div>abc</div> 15 </details> 16 <details id="details2"> 17 <summary>Second Section</summary> 18 <div>abc def</div> 19 </details> 20 21 <script> 22 // Test that navigating to a text fragment does not open hidden=until-found or 23 // closed <details> elements that contain an invalid match for the text fragment. 24 promise_test(async t => { 25 26 window.location.hash = ':~:text=abc,-def'; 27 28 await new Promise(resolve => details2.addEventListener('toggle', resolve)); 29 30 assert_equals(hidden1.hidden, 'until-found', 'hidden=until-found element should remain hidden'); 31 assert_false(details1.open, 'closed <details> element should remain closed'); 32 assert_true(details2.open, '<details> element containing the match should be opened'); 33 }, 'Text fragment with suffix should only reveal the matching details element'); 34 </script> 35 </body> 36 </html>