Bug 614643 - Don't rely on the afterpaint event because its firing times can be seemingly random. Instead, use the beforepaint event to see when the test is painting; r=arpad

This commit is contained in:
Ehsan Akhgari 2011-03-21 15:37:17 -04:00
Родитель 6c0317e6f3
Коммит cea2a66696
1 изменённых файлов: 5 добавлений и 8 удалений

Просмотреть файл

@ -29,8 +29,9 @@ function test()
}
var elem = doc.getElementById(test.elem);
// skip a few frames before checking the tests
var skipFrames = 3;
// Skip the first BeforePaint event as it's the same event that the browser
// uses to kick off the scrolling.
var skipFrames = 1;
var checkScroll = function () {
if (skipFrames--) {
window.mozRequestAnimationFrame();
@ -45,7 +46,7 @@ function test()
ok((scrollHori && elem.scrollLeft > 0) ||
(!scrollHori && elem.scrollLeft == 0),
test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
window.removeEventListener("MozAfterPaint", checkScroll, false);
window.removeEventListener("MozBeforePaint", checkScroll, false);
nextTest();
};
EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 },
@ -60,7 +61,7 @@ function test()
EventUtils.synthesizeMouse(elem, 100, 100,
{ type: "mousemove", clickCount: "0" },
gBrowser.contentWindow);
window.addEventListener("MozAfterPaint", checkScroll, false);
window.addEventListener("MozBeforePaint", checkScroll, false);
/*
* if scrolling didnt work, we wouldnt do any redraws and thus time out.
* so request and force redraws to get the chance to check for scrolling at
@ -95,10 +96,6 @@ function test()
function onFocus() {
doc = gBrowser.contentDocument;
// force redraws, so we actually get AfterPaint events
window.addEventListener("MozBeforePaint", function(ev) {
doc.body.appendChild(doc.createTextNode('.'));
}, false);
nextTest();
}