layout/base/tests/test_flush_on_paint.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test that we flush before painting</title>
     5   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7 </head>
     8 <body onload="doIteration()">
     9 <p id="display"></p>
    10 <div id="content" style="display: none">
    11 </div>
    12 <embed type="application/x-test" id="plugin" drawmode="solid" style="width:200px; height:200px;"></embed>
    13 <pre id="test">
    14 <script type="application/javascript">
    15 SimpleTest.waitForExplicitFinish();
    17 var iterations = 0;
    18 var plugin = document.getElementById("plugin");
    19 var lastPaintCount;
    20 var expectedWidth;
    22 var toggle = true;
    23 function invalidationLoop() {
    24   toggle = !toggle;
    25   var color = toggle ? "8F" : "00";
    26   plugin.setColor("FFFFFF" + color);
    27   setTimeout(invalidationLoop, 20);
    28 }
    29 invalidationLoop();
    31 function doIteration() {
    32   lastPaintCount = window.mozPaintCount;
    33   ok(true, "Beginning iteration " + iterations + ", last paint count: " + lastPaintCount);
    35   expectedWidth = 201 + iterations;
    36   plugin.style.width = expectedWidth + "px";
    37   checkDone();
    38 }
    40 function checkDone() {
    41   ok(true, "Check to see if we're done: " + window.mozPaintCount);
    42   if (window.mozPaintCount == lastPaintCount) {
    43     setTimeout(checkDone, 30);
    44     return;
    45   }
    47   var utils = SpecialPowers.getDOMWindowUtils(window);
    48   is(plugin.getWidthAtLastPaint(), utils.screenPixelsPerCSSPixel*expectedWidth,
    49      "Check that we set width before painting");
    51   ++iterations;
    52   if (iterations < 100) {
    53     doIteration();
    54   } else {
    55     SimpleTest.finish();
    56   }
    57 }
    58 </script>
    59 </pre>
    60 </body>
    61 </html>

mercurial