summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_overscroll_behavior_bug1494440.html
blob: 3f12e36102f1f934540412e4742dc81e1018f7e0 (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
<head>
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Inactive iframe with overscroll-behavior</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>
</head>
<body>
  <iframe id="scroll" srcdoc="<!doctype html><html style='overscroll-behavior:none; overflow: auto;'><div style='width:100px;height:2000px;'>">
  </iframe>
  <div style="height: 5000px;"></div><!-- So the page is scrollable as well -->

  <script type="application/javascript">

async function test() {
  var iframe = document.getElementById("scroll");
  var iframeWindow = iframe.contentWindow;

  // scroll the iframe to the bottom, such that a subsequent scroll on it
  // _would_ hand off to the page if overscroll-behavior allowed it
  iframeWindow.scrollTo(0, iframeWindow.scrollMaxY);
  await promiseApzFlushedRepaints();
  is(iframeWindow.scrollY, iframeWindow.scrollMaxY, "iframe has scrolled to the bottom");

  // Scroll over the iframe, and make sure that the page
  // does not scroll.
  // We can't wait for a "scroll" event unconditionally, since if the platform
  // behaviour we are testing is correct (overscroll-behavior is respected),
  // one will never arrive.
  var waitForScroll = false;
  await promiseMoveMouseAndScrollWheelOver(iframeWindow, 100, 100, waitForScroll);
  // However, we need to give a potential "scroll" event a chance to be dispatched,
  // so that if the platform behaviour we are testing is incorrect (overscroll-behavior)
  // is not respected, we catch it.
  await promiseApzFlushedRepaints();
  is(window.scrollY, 0, "overscroll-behavior was respected");
}

waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);

  </script>
  <style>
    #scroll {
      width: 200px;
      height: 500px;
    }
  </style>
</body>