Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Test that wheel events on an unscrollable OOP iframe are handoff-ed</title>
  <script src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
  iframe {
    height: 201px;
    border: none;
  }
  </style>
</head>
<body>
  <div id="iframe-container" style="overflow-y: scroll; height: 200px;">
    <iframe src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe_child.html"></iframe>
  </div>
  <div style="height: 200vh;"></div>
  <script type="application/javascript">
async function test() {
  const scrollContainer = document.querySelector("#iframe-container");
  let scrollEventPromise = promiseOneEvent(scrollContainer, "scroll");
  let scrollendEventPromise = promiseOneEvent(scrollContainer, "scrollend");
  // Send a wheel event on the iframe.
  const iframe = document.querySelector("iframe");
  const scrollEvent = {
    deltaY: 50,
    asyncEnabled: true,
  };
  synthesizeWheel(iframe, 50, 50, scrollEvent);
  await scrollEventPromise;
  await scrollendEventPromise;
  // The wheel event should be handoff-ed to the parent scroll container.
  is(scrollContainer.scrollTop, scrollContainer.scrollTopMax,
     "The scroll position in the parent scroll container should be at the bottom");
  // Make sure the wheel event wasn't handoff-ed to the root scroller.
  is(window.scrollY, 0, "The root scroll position should be 0");
  await promiseFrame();
  scrollEventPromise = promiseOneEvent(window, "scroll");
  scrollendEventPromise = promiseOneEvent(window, "scrollend");
  // Send a wheel event on the iframe again.
  synthesizeWheel(iframe, 50, 50, scrollEvent);
  await scrollEventPromise;
  await scrollendEventPromise;
  // Now it should be handoff-ed to the root scroller.
  ok(window.scrollY > 0,
     "The wheel event should have been handoff-ed to the root scroller");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
  </script>
</body>
</html>