author Cosmin Sabou <>
Sun, 05 Feb 2023 19:37:33 +0000
changeset 651812 d8601249f1eb8c52c742b0c19c9ca0fa8f2e31fe
parent 616557 918ef225713fa9fc188f42355a6cd4a2bfb3b64c
permissions -rw-r--r--
Bug 1806090 - temporarily disable browser_quickactions.js on linux for frequent failures. r=intermittent-reviewers,MasterWayZ Differential Revision:

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Sanity panning test</title>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript">

async function test() {
  let scrEvt = new EventCounter(window, "scroll");
  let visScrEvt = new EventCounter(window.visualViewport, "scroll");
  // Our internal visual viewport events aren't restricted to the visual view-
  // port itself, so we can listen on the window itself, however the event
  // listener needs to be in the system group.
  let visScrEvtInternal = new EventCounter(window, "mozvisualscroll",
                                           { mozSystemGroup: true });

  // This listener will trigger the test to continue once APZ is done with
  // processing the scroll.
  let transformEndPromise = promiseTransformEnd();

  await synthesizeNativeTouchDrag(document.body, 10, 100, 0, -50);
  dump("Finished native drag, waiting for transform-end observer...\n");

  // Wait for the APZ:TransformEnd to be fired after touch events are processed.
  await transformEndPromise;

  // Flush state.
  await promiseApzFlushedRepaints();

  is(window.scrollY, 50, "check that the window scrolled");

  // Check we've got the expected events.
  // This page is using "width=device-width; initial-scale=1.0" and we haven't
  // pinch-zoomed any further, so layout and visual viewports have the same
  // size and will scroll together. Therefore we should be getting layout
  // viewport "scroll" events as well.
  ok(scrEvt.count > 0, "Got some layout viewport scroll events");
  // This one is a bit tricky: Visual viewport "scroll" events are supposed to
  // fire only when the relative offset between layout and visual viewport
  // changes. Even when they're both scrolling together, we may update their
  // positions independently, though, leading to some jitter in the offset and
  // triggering the event after all.
  // At least for the case here, where both viewports are the same size and we
  // have a freshly loaded page, we should however be able to keep the offset at
  // a constant zero and therefore not cause any visual viewport scroll events
  // to fire.
  is(visScrEvt.count, 0, "Got no visual viewport scroll events");
  // Our internal visual viewport scroll event on the other hand only cares
  // about the absolute offset of the visual viewport and should therefore
  // definitively fire.
  ok(visScrEvtInternal.count > 0, "Got some mozvisualscroll events");

.then(subtestDone, subtestFailed);

 <div style="height: 5000px; background-color: lightgreen;">
  This div makes the page scrollable.