summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/chrome/test_prerendered_transforms.html
blob: d8b8c8bcfda2a56dae49afa34ab5e76c7c50771b (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test that active transformed elements coming into view are prerendered so we don't have to redraw constantly</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body onload="startTest()">
<div>
<div id="t" style="position:absolute; left:0; top:500px; transform: translatex(-100px); width:200px; height:100px; background:yellow;">
  <div style="text-align:right">Hello</div>
  <div style="text-align:left">Kitty</div>
</div>
</div>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();

var t = document.getElementById("t");
var utils = window.windowUtils;

function startTest() {
  // Do a couple of transform changes to ensure we've triggered activity heuristics
  waitForAllPaintsFlushed(function () {
    t.style.transform = "translatex(-75px)";
    waitForAllPaintsFlushed(function () {
      t.style.transform = "translatex(-50px)";
      waitForAllPaintsFlushed(function () {
        // Clear paint state now and move again.
        utils.checkAndClearPaintedState(t);
        // Don't move to 0 since that might trigger some special case that turns off transforms.
        t.style.transform = "translatex(-1px)";
        waitForAllPaintsFlushed(function () {
          var painted = utils.checkAndClearPaintedState(t);
          is(painted, false, "Transformed element should not have been painted");
          SimpleTest.finish();
        });
      });
    });
  });
}
</script>
</pre>
</body>
</html>