tor-browser

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

helper_scrollIntoView_bug1950744-2.html (1928B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <!--
      6    `minimum-scale=1` for disallowing scaling down this document even if there's any element wider than the ICB.
      7   -->
      8  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
      9  <title>Tests that scrollIntoView doesn't scroll to an element which is already in view in the minimum-scale viewport</title>
     10  <script src="apz_test_native_event_utils.js"></script>
     11  <script src="apz_test_utils.js"></script>
     12  <script src="/tests/SimpleTest/paint_listener.js"></script>
     13  <style>
     14  html {
     15    height: 10000px;
     16    scroll-behavior: auto; /* to make scrolling instant */
     17  }
     18  #fixed {
     19    position: fixed;
     20    bottom: 0px;
     21    height: 20vh;
     22    overflow: scroll;
     23    background-color: gray;
     24  }
     25  #name {
     26    height: 10px;
     27    width: 200vw; /* wider than the ICB */
     28  }
     29  </style>
     30 </head>
     31 <body>
     32 <div id="fixed">
     33  <input type="text" id="name" />
     34 </div>
     35 <script>
     36 async function test() {
     37  is(window.scrollY, 0, "The initial scroll offset should be 0");
     38  is(visualViewport.scale, 1.0, "The document should not get scaled");
     39  is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0");
     40 
     41  visualViewport.addEventListener("scroll", () => {
     42    ok(false, "Any VisualViewport scroll event should not be observed");
     43  });
     44  window.addEventListener("scroll", () => {
     45    ok(false, "Any scroll event should not be observed");
     46  });
     47 
     48  // Scroll to the input element inside a position:fixed element.
     49  document.querySelector("#name").scrollIntoView();
     50 
     51  await promiseApzFlushedRepaints();
     52 
     53  // Wait two frames to give a chance to scroll.
     54  await promiseFrame();
     55  await promiseFrame();
     56 
     57  is(visualViewport.pageTop, 0, "The visual viewport pageTop should be zero");
     58  is(window.scrollY, 0, "The scroll offset should be zero");
     59 }
     60 
     61 waitUntilApzStable()
     62 .then(test)
     63 .then(subtestDone, subtestFailed);
     64 </script>
     65 </body>
     66 </html>