find-range-from-text-directive-target.html (2644B)
1 <!doctype html> 2 <title>Tests find-a-range-from-a-text-directive algorithm</title> 3 <script src="stash.js"></script> 4 <script> 5 window.didScroll = false; 6 7 function checkScroll() { 8 let results = { 9 didScroll: window.scrollY != 0 10 }; 11 12 let key = (new URL(document.location)).searchParams.get("key"); 13 stashResultsThenClose(key, results); 14 } 15 16 // Ensure two animation frames on load to test the fallback to element anchor, 17 // which gets queued for the next frame if the text fragment is not found. 18 window.onload = function() { 19 window.requestAnimationFrame(function() { 20 window.requestAnimationFrame(checkScroll); 21 }); 22 } 23 </script> 24 <style> 25 .spacer { 26 width: 50vw; 27 height: 200vh; 28 } 29 </style> 30 <body> 31 Won't scroll if matched: 32 match suffix 33 match suffix3 34 <div class="spacer"></div> 35 <p> 36 The quick brown fox jumped over the lazy dog. 37 a a b b b c 38 </p> 39 <p> 40 foo foo foo bar bar bar 41 </p> 42 <p> 43 match suffix2 44 prefix match suffix3 matchEnd suffix4 matchEnd suffix5 45 </p> 46 <p> 47 Lorem 48 49 <br> <i> </i> 50 <div>   </div> 51 <!-- This <p> puts lots of non textual stuff between words --> 52 <div style="display: none">This isn't rendered</div> 53 <div style="visibility: hidden">This also isn't visible</div> 54 <iframe srcdoc="Inner Iframe"></iframe> 55 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mNk+M+AARiHsiAAcCIKAYwFoQ8AAAAASUVORK5CYII="> 56 57   Ipsum 58 59 Whitespace 60 61 <br> <i> </i> 62 <div>   </div> 63 <!-- This <p> puts lots of non textual stuff between words --> 64 <div style="display: none">This isn't rendered</div> 65 <div style="visibility: hidden">This also isn't visible</div> 66 <iframe srcdoc="Inner Iframe"></iframe> 67 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mNk+M+AARiHsiAAcCIKAYwFoQ8AAAAASUVORK5CYII="> 68   69 70 Dipsum 71 72 <div>Text 73 <div style="display: none">This isn't rendered</div> 74 with display: none 75 </div> 76 <div>Text 77 <div style="visibility: hidden">This also isn't visible</div> 78 with visibility: hidden as block boundary 79 </div> 80 <div>Text 81 <span style="visibility: hidden">This also isn't visible</span> 82 with visibility: hidden as inline 83 </div> 84 <div>Text 85 <iframe srcdoc="Inner Iframe"></iframe> 86 with Iframe 87 </div> 88 <div>Text 89 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mNk+M+AARiHsiAAcCIKAYwFoQ8AAAAASUVORK5CYII="> 90 with image 91 </div> 92 93 </p> 94 <p> 95 This text appears at the end of the document 96 </p 97 </body>