gecko/layout/base/tests/test_bug569520.html

64 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=569520
-->
<head>
<title>Test for Bug 569520</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569520">Mozilla Bug 569520</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 569520 **/
SimpleTest.waitForExplicitFinish();
var startNow = Date.now();
var start = window.mozAnimationStartTime;
var firstListenerTime;
var secondListenerTime;
function secondListener(ev) {
secondListenerTime = ev.timeStamp;
window.removeEventListener("MozBeforePaint", secondListener, false);
// They really shouldn't be more than 100ms apart, but we can get weird
// effects on slow machines. 5 minutes is our test timeout, though.
ok(Math.abs(startNow - start) <= 5 * 60 * 1000, "Bogus animation start time");
ok(firstListenerTime >= start, "First listener should fire after start");
// FIXME: The timer filtering code makes the refresh driver call back in 0ms
// sometimes!
ok(secondListenerTime >= firstListenerTime,
"Second listener should fire after first listener");
SimpleTest.finish();
}
function firstListener(ev) {
firstListenerTime = ev.timeStamp;
window.removeEventListener("MozBeforePaint", firstListener, false);
window.addEventListener("MozBeforePaint", secondListener, false);
mozRequestAnimationFrame();
}
addLoadEvent(function() {
setTimeout(function() {
window.addEventListener("MozBeforePaint", firstListener, false);
mozRequestAnimationFrame();
}, 100);
});
</script>
</pre>
</body>
</html>