2011-01-31 18:41:58 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Tests for MozAfterPaint</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
2013-09-04 07:07:53 -07:00
|
|
|
<script type="text/javascript" src="enableTestPlugin.js"></script>
|
2011-01-31 18:41:58 -08:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="display">
|
|
|
|
<embed type="application/x-test" width="100" height="100" id="p"
|
|
|
|
drawmode="solid" color="FF00FF00"></embed>
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var initialPaintCount, afterPaintCount;
|
|
|
|
var color = 0;
|
|
|
|
|
|
|
|
function onAfterPaint () {
|
|
|
|
afterPaintCount += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest() {
|
|
|
|
setTimeout(function () {
|
|
|
|
afterPaintCount = 0;
|
|
|
|
initialPaintCount = window.mozPaintCount;
|
|
|
|
window.addEventListener("MozAfterPaint", onAfterPaint, true);
|
|
|
|
doBackgroundFlicker();
|
2011-02-03 22:12:06 -08:00
|
|
|
}, 500);
|
2011-01-31 18:41:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", startTest, true);
|
|
|
|
|
2011-02-03 22:12:06 -08:00
|
|
|
// Unfortunately we cannot reliably assert that mozPaintCount and afterPaintCount increment perfectly
|
|
|
|
// in sync, because they can diverge in the presence of OS-triggered paints or system load.
|
2011-04-29 05:26:46 -07:00
|
|
|
// Instead, wait for a minimum number of afterPaint events to at least ensure that they are being fired.
|
|
|
|
const minimumAfterPaintsToPass = 10;
|
2011-02-03 22:12:06 -08:00
|
|
|
|
2011-01-31 18:41:58 -08:00
|
|
|
function doPluginFlicker() {
|
|
|
|
ok(true, "Plugin color iteration " + color +
|
|
|
|
", afterpaint count: " + afterPaintCount +
|
|
|
|
", mozpaint count: " + window.mozPaintCount);
|
2011-04-29 05:26:46 -07:00
|
|
|
if (afterPaintCount >= minimumAfterPaintsToPass) {
|
|
|
|
ok(true, "afterPaintCount incremented enough from plugin color changes.");
|
2011-01-31 18:41:58 -08:00
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
color = (color + 1) % 256;
|
|
|
|
var str = color.toString(16);
|
|
|
|
if (str.length < 2) {
|
|
|
|
str = "0" + str;
|
|
|
|
}
|
|
|
|
str = "FF" + str + str + str;
|
|
|
|
document.getElementById("p").setColor(str);
|
|
|
|
setTimeout(doPluginFlicker, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doBackgroundFlicker() {
|
|
|
|
ok(true, "Background color iteration " + color +
|
|
|
|
", afterpaint count: " + afterPaintCount +
|
|
|
|
", mozpaint count: " + window.mozPaintCount);
|
2011-04-29 05:26:46 -07:00
|
|
|
if (afterPaintCount >= minimumAfterPaintsToPass) {
|
|
|
|
ok(true, "afterPaintCount incremented enough from background color changes.");
|
2011-01-31 18:41:58 -08:00
|
|
|
afterPaintCount = 0;
|
|
|
|
initialPaintCount = window.mozPaintCount;
|
|
|
|
doPluginFlicker();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
color = (color + 1) % 256;
|
|
|
|
document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
|
|
|
|
setTimeout(doBackgroundFlicker, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<div style="height:4000px"></div>
|
|
|
|
<a id="first" href="http://www.mozilla.org/">first<br>link</a>
|
|
|
|
<a id="second" href="http://www.mozilla.org/">second link</a>
|
|
|
|
<a id="third" href="http://www.mozilla.org/">third<br>link</a>
|
|
|
|
<div style="height:4000px"></div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|