layout/base/tests/chrome/test_scrolling_repaints.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test that we don't get unnecessary repaints due to subpixel shifts</title>
     5   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
     7   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
     8 </head>
     9 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
    10 <body onload="setTimeout(startTest,0)">
    11 <div id="t" style="width:400px; height:100px; background:yellow; overflow:hidden">
    12   <div style="height:40px;"></div>
    13   <div id="e" style="height:30px; background:lime"></div>
    14   <div style="height:60.4px; background:pink"></div>
    15 </div>
    16 <pre id="test">
    17 <script type="application/javascript">
    18 SimpleTest.waitForExplicitFinish();
    20 var t = document.getElementById("t");
    21 var e = document.getElementById("e");
    22 var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
    23                getInterface(Components.interfaces.nsIDOMWindowUtils);
    25 function startTest() {
    26   // Do a scroll to ensure we trigger activity heuristics.
    27   waitForAllPaintsFlushed(function () {
    28     t.scrollTop = 5;
    29 	// Scroll down as far as we can, to put our rendering layer at a subpixel offset within the layer
    30     waitForAllPaintsFlushed(function () {
    31       t.scrollTop = 1000;
    32       waitForAllPaintsFlushed(function () {
    33         // Clear paint state now and scroll again.
    34         utils.checkAndClearPaintedState(e);
    35 		// scroll up a little bit. This should not cause anything to be repainted.
    36         t.scrollTop = t.scrollTop - 10;
    37         waitForAllPaintsFlushed(function () {
    38           var painted = utils.checkAndClearPaintedState(e);
    39           is(painted, false, "Fully-visible scrolled element should not have been painted");
    40           SimpleTest.finish();
    41         });
    42       });
    43     });
    44   });
    45 }
    46 </script>
    47 </pre>
    48 </body>
    49 </html>

mercurial