tor-browser

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

helper_zoomToFocusedInput_scroll_visually_bug1943865.html (1308B)


      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</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 </head>
     11 <body>
     12 <div style="position: fixed; bottom: 0;">
     13  <div style="position: absolute; bottom: 0;">
     14    <input type="text" id="name" />
     15  </div>
     16 </div>
     17 <script>
     18 async function test() {
     19  is(window.scrollY, 0, "The initial scroll offset should be 0");
     20  is(visualViewport.scale, 2.0, "The document should get scaled by 2.0");
     21  is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0");
     22 
     23  document.querySelector("#name").focus();
     24  const scrollPromise =
     25    new Promise(resolve => visualViewport.addEventListener("scroll", resolve));
     26  SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
     27  await scrollPromise;
     28 
     29  await promiseApzFlushedRepaints();
     30 
     31  ok(visualViewport.pageTop > 0,
     32    `The visual viewport should have been scrolled: ${visualViewport.pageTop}`);
     33 }
     34 
     35 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     36 waitUntilApzStable()
     37 .then(test)
     38 .then(subtestDone, subtestFailed);
     39 </script>
     40 </body>
     41 </html>