summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe.html
blob: 79101b2ca5b710365143db4c655441514fb7fe75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<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_native_event_utils.js"></script>
  <script src="apz_test_utils.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 = waitForScrollEvent(scrollContainer);

  // Send a wheel event on the iframe.
  const iframe = document.querySelector("iframe");
  await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
  await scrollEventPromise;

  // 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 = waitForScrollEvent(window);
  // Send a wheel event on the iframe again.
  await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
  await scrollEventPromise;

  // 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>