https://github.com/mozilla/gecko-dev
Raw File
Tip revision: 39ff442a68b35e2412bd3f81a1fe0046dbad56a1 authored by ffxbld on 04 April 2012, 03:40:54 UTC
Added FENNEC_12_0b4_RELEASE FENNEC_12_0b4_BUILD1 tag(s) for changeset a8e7d1956aa3. DONTBUILD CLOSED TREE a=release
Tip revision: 39ff442
test_flush_on_paint.html
<!DOCTYPE HTML>
<html>
<head>
  <title>Test that we flush before painting</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="doIteration()">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<embed type="application/x-test" id="plugin" drawmode="solid" style="width:200px; height:200px;"></embed>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();

var iterations = 0;
var plugin = document.getElementById("plugin");
var lastPaintCount;
var expectedWidth;

var toggle = true;
function invalidationLoop() {
  toggle = !toggle;
  var color = toggle ? "8F" : "00";
  plugin.setColor("FFFFFF" + color);
  setTimeout(invalidationLoop, 20);
}
invalidationLoop();

function doIteration() {
  lastPaintCount = window.mozPaintCount;
  ok(true, "Beginning iteration " + iterations + ", last paint count: " + lastPaintCount);

  expectedWidth = 201 + iterations;
  plugin.style.width = expectedWidth + "px";
  checkDone();
}

function checkDone() {
  ok(true, "Check to see if we're done: " + window.mozPaintCount);
  if (window.mozPaintCount == lastPaintCount) {
    setTimeout(checkDone, 30);
    return;
  }

  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                 getInterface(Components.interfaces.nsIDOMWindowUtils);
  is(plugin.getWidthAtLastPaint(), utils.screenPixelsPerCSSPixel*expectedWidth,
     "Check that we set width before painting");

  ++iterations;
  if (iterations < 100) {
    doIteration();
  } else {
    SimpleTest.finish();
  }
}
</script>
</pre>
</body>
</html>
back to top