tor-browser

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

helper_smoothscroll_spam.html (1918B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width; initial-scale=1.0">
      6  <title>Test for scenario in bug 1228407</title>
      7  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      8  <script type="application/javascript" src="apz_test_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <script type="application/javascript">
     11 
     12 async function test() {
     13  let utils = SpecialPowers.getDOMWindowUtils(window);
     14  utils.advanceTimeAndRefresh(0);
     15 
     16  // Part of the problem in bug 1228407 was that the main-thread scroll
     17  // generation counter was continually increasing (due to scrollBy calls in
     18  // quick succession), and so repaint requests from APZ would get ignored (due
     19  // to stale scroll generation), and so the main thread scroll position would
     20  // never actually get updated. This loop exercises that case. The expected
     21  // behaviour (pre-APZ) was that the scrollBy call would actually start the
     22  // scroll animation and advance the scroll position a little bit, so the next
     23  // scrollBy call would move the animation destination a little bit, and so
     24  // the loop would continue advancing the scroll position. The bug resulted
     25  // in the scroll position not advancing at all.
     26  for (let i = 0; i < 100; i++) {
     27    document.scrollingElement.scrollBy({top:60, behavior: "smooth"});
     28    await promiseOnlyApzControllerFlushed();
     29    utils.advanceTimeAndRefresh(16);
     30  }
     31 
     32  utils.restoreNormalRefresh();
     33  await promiseOnlyApzControllerFlushed();
     34 
     35  let scrollPos = document.scrollingElement.scrollTop;
     36  ok(scrollPos > 60, `Scrolled ${scrollPos}px, should be more than 60`);
     37 }
     38 
     39 waitUntilApzStable().then(test).then(subtestDone, subtestFailed);
     40 
     41  </script>
     42  <style>
     43    body {
     44      height: 5000px;
     45      background: linear-gradient(red, black);
     46    }
     47  </style>
     48 </head>
     49 <body>
     50 </body>
     51 </html>