tor-browser

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

helper_tab_scroll_scrollIntoView.html (1321B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <script src="apz_test_utils.js"></script>
      6  <script src="apz_test_native_event_utils.js"></script>
      7  <script src="/tests/SimpleTest/EventUtils.js"></script>
      8  <script src="/tests/SimpleTest/paint_listener.js"></script>
      9  <style>
     10 .spacer {
     11  height: 200vh;
     12  width: 100%;
     13  background: green;
     14 }
     15 #target {
     16  height: 5vh;
     17  width: 100%;
     18  background: red;
     19 }
     20  </style>
     21 </head>
     22 <body>
     23  <div class="spacer"></div>
     24  <button id="target"></button>
     25  <div class="spacer"></div>
     26 </body>
     27 <script>
     28 async function test() {
     29  let scrollendPromise = promiseScrollend();
     30 
     31  window.synthesizeKey("KEY_Tab");
     32 
     33  await scrollendPromise;
     34 
     35  let tabScrollPosition = document.scrollingElement.scrollTop;
     36 
     37  target.scrollIntoView({block: "center", inline: "center"});
     38 
     39  let scrollIntoViewPosition = document.scrollingElement.scrollTop;
     40 
     41  // The scroll position after an explicit scrollIntoView call on the target
     42  // with block and inline set to "center" should be within +/- 1 of the
     43  // scroll position from the tab scroll.
     44  ok(tabScrollPosition >= scrollIntoViewPosition - 1 &&
     45     tabScrollPosition <= scrollIntoViewPosition + 1,
     46     "target element should be centered by tab scroll");
     47 }
     48 waitUntilApzStable()
     49 .then(test)
     50 .then(subtestDone, subtestFailed);
     51 </script>
     52 </html>