tor-browser

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

helper_visual_smooth_scroll.html (1891B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width, minimum-scale=1.0">
      6  <title>Tests that the (internal) visual smooth scrolling API is not restricted to the layout scroll range</title>
      7  <script type="application/javascript" src="apz_test_utils.js"></script>
      8  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <style>
     11    div {
     12      position: absolute;
     13    }
     14  </style>
     15 </head>
     16 <body>
     17  <div style="width: 100%; height: 200%; background-color: green"></div>
     18  <div style="width: 100%; height: 100%; background-color: blue"></div>
     19  <script type="application/javascript">
     20    const utils = SpecialPowers.getDOMWindowUtils(window);
     21 
     22    async function test() {
     23      // Pick a destination to scroll to that's outside the layout scroll range
     24      // but within the visual scroll range.
     25      const destY = window.scrollMaxY + 100;
     26 
     27      // Register a TransformEnd observer so we can tell when the smooth scroll
     28      // animation stops.
     29      let transformEndPromise = promiseTransformEnd();
     30 
     31      // Use scrollToVisual() to smooth-scroll to the destination.
     32      utils.scrollToVisual(0, destY, utils.UPDATE_TYPE_MAIN_THREAD,
     33                           utils.SCROLL_MODE_SMOOTH);
     34 
     35      // Wait for the TransformEnd.
     36      await transformEndPromise;
     37 
     38      // Give scroll offsets a chance to sync.
     39      await promiseApzFlushedRepaints();
     40 
     41      // Check that the visual viewport scrolled to the desired destination.
     42      is(visualViewport.pageTop, destY,
     43         "The visual viewport should have scrolled past the layout scroll range");
     44    }
     45 
     46    SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     47 
     48    waitUntilApzStable()
     49    .then(test)
     50    .then(subtestDone, subtestFailed);
     51  </script>
     52 </body>
     53 </html>