layout/base/tests/chrome/test_scrolling_repaints.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/chrome/test_scrolling_repaints.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test that we don't get unnecessary repaints due to subpixel shifts</title>
     1.8 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
    1.11 +</head>
    1.12 +<!-- Need a timeout here to allow paint unsuppression before we start the test -->
    1.13 +<body onload="setTimeout(startTest,0)">
    1.14 +<div id="t" style="width:400px; height:100px; background:yellow; overflow:hidden">
    1.15 +  <div style="height:40px;"></div>
    1.16 +  <div id="e" style="height:30px; background:lime"></div>
    1.17 +  <div style="height:60.4px; background:pink"></div>
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript">
    1.21 +SimpleTest.waitForExplicitFinish();
    1.22 +
    1.23 +var t = document.getElementById("t");
    1.24 +var e = document.getElementById("e");
    1.25 +var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
    1.26 +               getInterface(Components.interfaces.nsIDOMWindowUtils);
    1.27 +
    1.28 +function startTest() {
    1.29 +  // Do a scroll to ensure we trigger activity heuristics.
    1.30 +  waitForAllPaintsFlushed(function () {
    1.31 +    t.scrollTop = 5;
    1.32 +	// Scroll down as far as we can, to put our rendering layer at a subpixel offset within the layer
    1.33 +    waitForAllPaintsFlushed(function () {
    1.34 +      t.scrollTop = 1000;
    1.35 +      waitForAllPaintsFlushed(function () {
    1.36 +        // Clear paint state now and scroll again.
    1.37 +        utils.checkAndClearPaintedState(e);
    1.38 +		// scroll up a little bit. This should not cause anything to be repainted.
    1.39 +        t.scrollTop = t.scrollTop - 10;
    1.40 +        waitForAllPaintsFlushed(function () {
    1.41 +          var painted = utils.checkAndClearPaintedState(e);
    1.42 +          is(painted, false, "Fully-visible scrolled element should not have been painted");
    1.43 +          SimpleTest.finish();
    1.44 +        });
    1.45 +      });
    1.46 +    });
    1.47 +  });
    1.48 +}
    1.49 +</script>
    1.50 +</pre>
    1.51 +</body>
    1.52 +</html>

mercurial