summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
blob: eb2d583276a89f189ea9aa42008f86e978b3481d (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
53
54
55
56
57
<!DOCTYPE HTML>
<html>
<head>
  <title>APZ hit-testing over a checkerboarded area</title>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <meta name="viewport" content="width=device-width"/>
</head>
<body>
 <div id="scroller" style="width: 300px; height: 300px; overflow:scroll; margin-top: 100px; margin-left: 50px">
  <!-- Make the contents tall enough to be sure we can checkerboard -->
  <div id="contents" style="width: 100%; height: 5000px; background-image: linear-gradient(blue,red)">
  </div>
 </div>
 <div id="make_root_scrollable" style="height: 5000px"></div>
</body>
<script type="application/javascript">

async function test() {
  var config = getHitTestConfig();
  var utils = config.utils;

  var scroller = document.getElementById("scroller");

  // Activate the scrollframe but keep the main-thread scroll position at 0.
  // Also apply an async scroll offset in the y-direction such that the
  // scrollframe scrolls all the way to the bottom of its range, where it's
  // sure to checkerboard.
  utils.setDisplayPortForElement(0, 0, 300, 1000, scroller, 1);
  await promiseApzFlushedRepaints();
  var scrollY = scroller.scrollTopMax;
  utils.setAsyncScrollOffset(scroller, 0, scrollY);
  // Tick the refresh driver once to make sure the compositor has applied the
  // async scroll offset (for WebRender hit-testing we need to make sure WR has
  // the latest info).
  utils.advanceTimeAndRefresh(16);
  utils.restoreNormalRefresh();

  var scrollerViewId = utils.getViewId(scroller);

  // Hit-test the middle of the scrollframe, which is now inside the
  // checkerboarded region, and check that we hit the scrollframe and
  // not its parent.
  checkHitResult(hitTest(centerOf(scroller)),
                 APZHitResultFlags.VISIBLE,
                 scrollerViewId,
                 utils.getLayersId(),
                 "active scrollframe");
}

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

</script>
</html>