summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_bug1464568_transform.html
blob: 1181571991ae43a789ba3f6d2f0d97a51b872083 (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
58
59
60
61
62
63
64
65
66
<!DOCTYPE HTML>
<html>
<head>
  <title>Test that transform animation is correctly placed during asynchronous scrolling</title>
  <script src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <meta name="viewport" content="width=device-width"/>
  <style>
    #anim {
      background: green;
      width: 100px;
      height: 100px;
      animation: anim 100s step-start;
    }
    @keyframes anim {
      from { transform: translateX(100px); }
      to { transform: translateX(200px); }
    }
  </style>
</head>
<body>
 <!--
  This height should be smaller than window height, otherwise the animation
  followed by this element will be out of view, thus the animation doesn't run
  on the compositor.
  -->
 <div style="height: 500px"></div>
 <div id="anim"></div>
 <!--
  Give the page room to scroll, so that the setAsyncScrollOffset() call
  doesn't take the scroll position out of bounds
 -->
 <div style="height: 1000px"></div>
</body>
<script>
"use strict";

const utils = SpecialPowers.getDOMWindowUtils(window);

async function test_transform() {
  utils.setDisplayPortForElement(0, 0, 300, 1000, document.documentElement, 1);
  await promiseAllPaintsDone();

  let dpr = window.devicePixelRatio;
  let transform = parseTransform(utils.getOMTCTransform(anim));
  isTransformClose(transform, [1, 0, 0, 1, 200 * dpr, 0],
     "The element shouldn't be moved before scrolling");

  utils.setAsyncScrollOffset(document.documentElement, 0, 300);

  await new Promise(resolve => waitForApzFlushedRepaints(resolve));

  transform = parseTransform(utils.getOMTCTransform(anim));
  isTransformClose(transform, [1, 0, 0, 1, 200 * dpr, -300 * dpr],
     "Element should have been moved by the offset");
}

if (utils.layerManagerType == "WebRender") {
  ok(true, "This test doesn't need to run on WebRender");
  subtestDone();
} else {
  waitUntilApzStable().then(test_transform).then(subtestDone, subtestFailed);
}

</script>
</html>