tor-browser

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

helper_drag_bug1827330.html (2184B)


      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 bug 1827330</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  <style>
     11    #scrollbox {
     12      overflow: scroll;
     13      width: 300px;
     14      height: 300px;
     15    }
     16    .spacer {
     17      height: 200%;
     18    }  </style>
     19 </head>
     20 <body>
     21  <div id="scrollbox">
     22    <iframe src="https://example.com" width="200" height="200"></iframe>
     23    <div class="spacer"></div>
     24  </div>
     25  <script type="text/javascript">
     26 
     27    async function test() {
     28      const utils = SpecialPowers.getDOMWindowUtils(window);
     29 
     30      // Zoom in.
     31      let resolution = 3.0;
     32      utils.setResolutionAndScaleTo(resolution);
     33      await promiseApzFlushedRepaints();
     34 
     35      var subframe = document.getElementById("scrollbox");
     36      let scrollPromise = new Promise(resolve => {
     37        subframe.addEventListener("scroll", resolve, {once: true});
     38      });
     39 
     40      // Scroll down a small amount (5px). The bug in this case is that the
     41      // scroll thumb does not start moving until the mouse has already moved
     42      // by some distance, so if the bug occurs, the first 5px of mouse movement
     43      // will cause no scrolling.
     44      var dragFinisher = await promiseVerticalScrollbarDrag(subframe, 5, 5);
     45      if (!dragFinisher) {
     46        ok(true, "No scrollbar, can't do this test");
     47        return;
     48      }
     49 
     50      // the events above might be stuck in APZ input queue for a bit until the
     51      // layer is activated, so we wait here until the scroll event listener is
     52      // triggered.
     53      await scrollPromise;
     54 
     55      await dragFinisher();
     56 
     57      // Flush everything just to be safe
     58      await promiseOnlyApzControllerFlushed();
     59 
     60      // Check that we've scrolled at all.
     61      ok(subframe.scrollTop > 0, "Scrollbar drag resulted in a scroll position of " + subframe.scrollTop);
     62    }
     63 
     64    waitUntilApzStable()
     65    .then(test)
     66    .then(subtestDone, subtestFailed);
     67 
     68  </script>
     69 </body>
     70 </html>