tor-browser

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

helper_bug1756814.html (2184B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="apz_test_utils.js"></script>
      5  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      6  <script src="/tests/SimpleTest/paint_listener.js"></script>
      7 </head>
      8 <body>
      9  <div style="height: 200vh;"></div>
     10 </body>
     11 <script type="application/javascript">
     12 
     13 async function test() {
     14  const moveDistance = 10;
     15 
     16  // Start dragging the vertical scrollbar thumb.
     17  const startPoint = await scrollbarDragStart(window, 1);
     18  await promiseNativeMouseEventWithAPZ({
     19    target: window,
     20    offsetX: startPoint.x,
     21    offsetY: startPoint.y,
     22    type: "mousemove",
     23  });
     24  await promiseNativeMouseEventWithAPZ({
     25    target: window,
     26    offsetX: startPoint.x,
     27    offsetY: startPoint.y,
     28    type: "mousedown",
     29  });
     30 
     31  // Move the thumb and wait for a scroll event triggered by the movement.
     32  let scrollEventPromise = waitForScrollEvent(window);
     33  await promiseNativeMouseEventWithAPZ({
     34    target: window,
     35    offsetX: startPoint.x,
     36    offsetY: startPoint.y + moveDistance,
     37    type: "mousemove",
     38  });
     39  await scrollEventPromise;
     40 
     41  let scrollPosition = window.scrollY;
     42 
     43  // Append an element to the scroll container to expand the scroll range.
     44  const content = document.createElement("div");
     45  content.style.height = "200vh";
     46  document.body.appendChild(content);
     47 
     48  // flush the above change.
     49  document.documentElement.getBoundingClientRect();
     50 
     51  // Make sure the change has been reflected into APZ.
     52  await promiseApzFlushedRepaints();
     53 
     54  // Move the thumb again.
     55  scrollEventPromise = waitForScrollEvent(window);
     56  await promiseNativeMouseEventWithAPZ({
     57    target: window,
     58    offsetX: startPoint.x,
     59    offsetY: startPoint.y + moveDistance * 2,
     60    type: "mousemove",
     61  });
     62 
     63  await scrollEventPromise;
     64  ok(window.scrollY <= scrollPosition * 2,
     65     `The scroll position ${window.scrollY} should be less than ${scrollPosition*2}`);
     66 
     67  await promiseNativeMouseEventWithAPZ({
     68    target: window,
     69    offsetX: startPoint.x,
     70    offsetY: startPoint.y + moveDistance * 2,
     71    type: "mouseup",
     72  });
     73 }
     74 
     75 waitUntilApzStable()
     76 .then(test)
     77 .then(subtestDone, subtestFailed);
     78 
     79 </script>
     80 </html>