tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_scrolling_repaints.html (1821B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test that we don't get unnecessary repaints due to subpixel shifts</title>
      5  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      6  <script 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();
     19 
     20 var t = document.getElementById("t");
     21 var e = document.getElementById("e");
     22 var utils = window.windowUtils;
     23 
     24 function startTest() {
     25  // Do a scroll to ensure we trigger activity heuristics.
     26  waitForAllPaintsFlushed(function () {
     27    t.scrollTop = 5;
     28 // Scroll down as far as we can, to put our rendering layer at a subpixel offset within the layer
     29    waitForAllPaintsFlushed(function () {
     30      t.scrollTop = 1000;
     31      waitForAllPaintsFlushed(function () {
     32        // Clear paint state now and scroll again.
     33        utils.checkAndClearPaintedState(e);
     34 	// scroll up a little bit. This should not cause anything to be repainted.
     35        t.scrollTop = t.scrollTop - 10;
     36        waitForAllPaintsFlushed(function () {
     37          var painted = utils.checkAndClearPaintedState(e);
     38          is(painted, false, "Fully-visible scrolled element should not have been painted");
     39          SimpleTest.finish();
     40        });
     41      });
     42    });
     43  });
     44 }
     45 </script>
     46 </pre>
     47 </body>
     48 </html>