tor-browser

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

helper_zoomToFocusedInput_scroll_visually_bug1947470.html (1867B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width,initial-scale=1">
      6  <title>Tests that zoomToFocuedInput scrolls visually with the non-zero root scroll offset</title>
      7  <script src="apz_test_native_event_utils.js"></script>
      8  <script src="apz_test_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <style>
     11  html {
     12    height: 10000px;
     13    scroll-behavior: auto; /* to make scrolling instant */
     14  }
     15  #fixed {
     16    position: fixed;
     17    bottom: 0px;
     18    height: 50vh;
     19    width: 100vw;
     20    overflow: scroll;
     21    background-color: gray;
     22  }
     23  input {
     24    height: 20px;
     25  }
     26  </style>
     27 </head>
     28 <body>
     29 <div id="fixed">
     30  <div style="height: calc(80vh - 40px)"></div>
     31  <input type="text" id="name" />
     32 </div>
     33 <script>
     34 async function test() {
     35  is(window.scrollY, 0, "The initial scroll offset should be 0");
     36  is(visualViewport.scale, 2.0, "The document should get scaled by 2.0");
     37  is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0");
     38 
     39  // Scroll the root scroll container.
     40  window.scrollTo(0, 2000);
     41  is(window.scrollY, 2000, "Now the scroll offset should be 2000");
     42 
     43  const expectedPageTop = visualViewport.pageTop;
     44 
     45  const scrollPromise =
     46    new Promise(resolve => visualViewport.addEventListener("scroll", resolve));
     47  document.querySelector("#name").focus();
     48  SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
     49  await scrollPromise;
     50 
     51  await promiseApzFlushedRepaints();
     52 
     53  ok(visualViewport.pageTop > expectedPageTop,
     54    `visual viewport should have scrolled ` +
     55    `the current pageTop: ${visualViewport.pageTop}, ` +
     56    `the previous pageTop: ${expectedPageTop}`);
     57 }
     58 
     59 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     60 waitUntilApzStable()
     61 .then(test)
     62 .then(subtestDone, subtestFailed);
     63 </script>
     64 </body>
     65 </html>