layout/base/tests/test_flush_on_paint.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/test_flush_on_paint.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test that we flush before painting</title>
     1.8 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.10 +</head>
    1.11 +<body onload="doIteration()">
    1.12 +<p id="display"></p>
    1.13 +<div id="content" style="display: none">
    1.14 +</div>
    1.15 +<embed type="application/x-test" id="plugin" drawmode="solid" style="width:200px; height:200px;"></embed>
    1.16 +<pre id="test">
    1.17 +<script type="application/javascript">
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +var iterations = 0;
    1.21 +var plugin = document.getElementById("plugin");
    1.22 +var lastPaintCount;
    1.23 +var expectedWidth;
    1.24 +
    1.25 +var toggle = true;
    1.26 +function invalidationLoop() {
    1.27 +  toggle = !toggle;
    1.28 +  var color = toggle ? "8F" : "00";
    1.29 +  plugin.setColor("FFFFFF" + color);
    1.30 +  setTimeout(invalidationLoop, 20);
    1.31 +}
    1.32 +invalidationLoop();
    1.33 +
    1.34 +function doIteration() {
    1.35 +  lastPaintCount = window.mozPaintCount;
    1.36 +  ok(true, "Beginning iteration " + iterations + ", last paint count: " + lastPaintCount);
    1.37 +
    1.38 +  expectedWidth = 201 + iterations;
    1.39 +  plugin.style.width = expectedWidth + "px";
    1.40 +  checkDone();
    1.41 +}
    1.42 +
    1.43 +function checkDone() {
    1.44 +  ok(true, "Check to see if we're done: " + window.mozPaintCount);
    1.45 +  if (window.mozPaintCount == lastPaintCount) {
    1.46 +    setTimeout(checkDone, 30);
    1.47 +    return;
    1.48 +  }
    1.49 +
    1.50 +  var utils = SpecialPowers.getDOMWindowUtils(window);
    1.51 +  is(plugin.getWidthAtLastPaint(), utils.screenPixelsPerCSSPixel*expectedWidth,
    1.52 +     "Check that we set width before painting");
    1.53 +
    1.54 +  ++iterations;
    1.55 +  if (iterations < 100) {
    1.56 +    doIteration();
    1.57 +  } else {
    1.58 +    SimpleTest.finish();
    1.59 +  }
    1.60 +}
    1.61 +</script>
    1.62 +</pre>
    1.63 +</body>
    1.64 +</html>

mercurial