summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_reset_zoom_bug1818967.html
blob: 4a4d7e34cab63d9405f2606e439f1e5b824bbb53 (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
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Test that we do not checkerboard after resetting the pinch-zoom scale</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>
<style>
.scrolled {
  width: 10000px;
  height: 10000px;
  background: linear-gradient(lime, cyan);
}
</style>
</head><body>
  <div class="scrolled"></div>
</body>

<script type="application/javascript">
async function test() {
  var utils = SpecialPowers.getDOMWindowUtils(window);
  var scrollerId = utils.getViewId(document.documentElement);

  // Zoom in to the maximum level
  utils.setResolutionAndScaleTo(10.0);
  await promiseApzFlushedRepaints();

  // Scroll the layout viewport to around middle of the page
  window.scrollTo(window.scrollMaxX / 2, window.scrollMaxY / 2);
  await promiseApzFlushedRepaints();

  // Scroll the visual viewport to the bottom of the layout viewport.
  // This creates an offset between the visual and layout viewport
  // offsets which is needed to trigger the bug.
  utils.scrollToVisual(window.scrollX,
                       window.scrollY + (0.9 * document.documentElement.clientHeight),
                       utils.UPDATE_TYPE_MAIN_THREAD,
                       utils.SCROLL_MODE_INSTANT);
  await promiseApzFlushedRepaints();

  // Reset the zoom level to 1.0x
  utils.setResolutionAndScaleTo(1.0);
  await promiseApzFlushedRepaints();

  // Assert that we're not checkerboarded
  assertNotCheckerboarded(utils, scrollerId, "After resetting zoom level");
}

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

</script>
</html>