diff --git a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js index 3ceba3329fe..84aafc7b7cf 100644 --- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js +++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js @@ -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(); }