tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug66619.html (2026B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=66619
      5 -->
      6 <head>
      7  <title>Test for Bug 66619</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body onload="run()">
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=66619">Mozilla Bug 66619</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15  
     16 </div>
     17 <pre id="test">
     18 <script class="testbody" type="text/javascript">
     19 
     20 /** Test for Bug 66619 */
     21 
     22 SimpleTest.waitForExplicitFinish();
     23 
     24 function assert_fully_in_view(element) {
     25  let rect = element.getBoundingClientRect();
     26  ok(rect.top >= 0, `${element.id} top`);
     27  ok(rect.bottom <= window.innerHeight, `${element.id} bottom`);
     28 }
     29 
     30 function run() {
     31  is(window.scrollY, 0, "window should initially be at top");
     32  let first = document.getElementById("first");
     33  let second = document.getElementById("second");
     34  let third = document.getElementById("third");
     35 
     36  first.focus();
     37  let firstOffset = window.scrollY;
     38  isnot(firstOffset, 0, "we scrolled to first anchor");
     39  ok(firstOffset + window.innerHeight > 4000,
     40     "we scrolled enough to show the anchor");
     41  assert_fully_in_view(first);
     42 
     43  window.scrollTo(0, 0);
     44  second.focus();
     45  let secondOffset = window.scrollY;
     46  assert_fully_in_view(second);
     47 
     48  window.scrollTo(0, 0);
     49  third.focus();
     50  let thirdOffset = window.scrollY;
     51  assert_fully_in_view(third);
     52 
     53  ok(secondOffset > firstOffset, "we scrolled the second line of the anchor into view");
     54  ok(thirdOffset > secondOffset, "we scrolled the second line of the anchor into view");
     55 
     56  window.scrollTo(0, 0); // make the results visible
     57  SimpleTest.finish();
     58 }
     59 
     60 
     61 </script>
     62 </pre>
     63 
     64 <div style="height:4000px"></div>
     65 <a id="first"  href="http://www.mozilla.org/">first<br>link</a>
     66 <a id="second" href="http://www.mozilla.org/">second link</a>
     67 <a id="third"  href="http://www.mozilla.org/">third<br>link</a>
     68 <div style="height:4000px"></div>
     69 
     70 </body>
     71 </html>