зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
19b1445e88
Коммит
ca8b5ca0ad
|
@ -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 didn’t work, we wouldn’t 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();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче