layout/base/tests/test_mozPaintCount.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/test_mozPaintCount.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Tests for mozPaintCount</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="enableTestPlugin.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +</head>
    1.12 +<body onload="doBackgroundFlicker()">
    1.13 +<p id="display">
    1.14 +<embed type="application/x-test" width="100" height="100" id="p"
    1.15 +       drawmode="solid" color="FF00FF00"></embed>
    1.16 +</p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +SimpleTest.waitForExplicitFinish();
    1.24 +
    1.25 +var startPaintCount = window.mozPaintCount;
    1.26 +ok(true, "Got to initial paint count: " + startPaintCount);
    1.27 +var color = 0;
    1.28 +
    1.29 +function doPluginFlicker() {
    1.30 +  ok(true, "Plugin color iteration " + color + ", paint count: " + window.mozPaintCount);
    1.31 +  if (window.mozPaintCount - startPaintCount > 20) {
    1.32 +    ok(true, "Got enough paints from plugin color changes");
    1.33 +    SimpleTest.finish();
    1.34 +    return;
    1.35 +  }
    1.36 +
    1.37 +  color = (color + 1) % 256;
    1.38 +  var str = color.toString(16);
    1.39 +  if (str.length < 2) {
    1.40 +    str = "0" + str;
    1.41 +  }
    1.42 +  str = "FF" + str + str + str;
    1.43 +  document.getElementById("p").setColor(str);
    1.44 +  setTimeout(doPluginFlicker, 0);
    1.45 +}
    1.46 +
    1.47 +function doBackgroundFlicker() {
    1.48 +  ok(true, "Background color iteration " + color + ", paint count: " + window.mozPaintCount);
    1.49 +  if (window.mozPaintCount - startPaintCount > 20) {
    1.50 +    ok(true, "Got enough paints from background color changes");
    1.51 +    startPaintCount = window.mozPaintCount;
    1.52 +    doPluginFlicker();
    1.53 +    return;
    1.54 +  }
    1.55 +
    1.56 +  color = (color + 1) % 256;
    1.57 +  document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
    1.58 +  setTimeout(doBackgroundFlicker, 0);
    1.59 +}
    1.60 +
    1.61 +</script>
    1.62 +</pre>
    1.63 +
    1.64 +<div style="height:4000px"></div>
    1.65 +<a id="first"  href="http://www.mozilla.org/">first<br>link</a>
    1.66 +<a id="second" href="http://www.mozilla.org/">second link</a>
    1.67 +<a id="third"  href="http://www.mozilla.org/">third<br>link</a>
    1.68 +<div style="height:4000px"></div>
    1.69 +
    1.70 +</body>
    1.71 +</html>
    1.72 +

mercurial