From e55eb3d9558bdcddf0aa777dbeec27077ca199a6 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 25 Mar 2015 08:42:46 -0400 Subject: [PATCH] Backed out changeset a6b9c152a7d1 (bug 1140293) for mochitest failures. CLOSED TREE --- dom/events/test/test_bug574663.html | 82 +++++-------------- layout/generic/test/mochitest.ini | 2 +- layout/generic/test/test_bug784410.html | 8 +- layout/generic/test/test_scroll_behavior.html | 33 +++----- .../mochitest/tests/SimpleTest/EventUtils.js | 44 ---------- .../content/tests/chrome/test_mousescroll.xul | 77 +++++++++-------- 6 files changed, 71 insertions(+), 175 deletions(-) diff --git a/dom/events/test/test_bug574663.html b/dom/events/test/test_bug574663.html index 355ba6c844b..6150c5b0b9b 100644 --- a/dom/events/test/test_bug574663.html +++ b/dom/events/test/test_bug574663.html @@ -20,37 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=574663 /** Test for Bug 574663 **/ -// SimpleTest's paint_listener does not work on other windows, so we inline -// a smaller version here. -function waitForPaint(win, utils, callback) { - win.document.documentElement.getBoundingClientRect(); - if (!utils.isMozAfterPaintPending) { - callback(); - return; - } - - var onpaint = function() { - if (!utils.isMozAfterPaintPending) { - win.removeEventListener("MozAfterPaint", onpaint); - callback(); - return; - } - } - win.addEventListener("MozAfterPaint", onpaint); - if (utils.isTestControllingRefreshes) { - utils.advanceTimeAndRefresh(0); - } -} - -function forceScrollAndWait(scrollbox, callback) { - let win = scrollbox.ownerDocument.defaultView; - let utils = SpecialPowers.getDOMWindowUtils(win); - - utils.advanceTimeAndRefresh(1000); - waitForPaint(win, utils, callback); -} - -function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum, callback) { +function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum) { var win = scrollbox.ownerDocument.defaultView; let event = { deltaMode: WheelEvent.DOM_DELTA_PIXEL, @@ -59,26 +29,10 @@ function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum, callback ctrlKey: ctrl, isMomentum: momentum }; - - let kExtraEvents = 5; - - var received = 0; - var onwheel = function() { - if (++received == 1 + kExtraEvents) { - // We have captured all the outstanding wheel events. Wait for the - // animation to add itself to the refresh driver. - scrollbox.removeEventListener("wheel", onwheel); - setTimeout(function() { - forceScrollAndWait(scrollbox, callback); - }, 0); - } - }; - scrollbox.addEventListener("wheel", onwheel); - synthesizeWheel(scrollbox, 10, 10, event, win); // then 5 additional pixel scrolls event.lineOrPageDeltaY = 0; - for (let i = 1; i <= kExtraEvents; ++i) { + for (let i = 0; i < 5; ++i) { synthesizeWheel(scrollbox, 10, 10, event, win); } } @@ -103,11 +57,21 @@ function runTest() { winUtils.advanceTimeAndRefresh(1000); function nextTest() { + if (!outstandingTests.length) { + winUtils.restoreNormalRefresh(); + win.close(); + SimpleTest.finish(); + return; + } + let [ctrlKey, isMomentum] = outstandingTests.shift(); let scrollTopBefore = scrollbox.scrollTop; let zoomFactorBefore = winUtils.fullZoom; - let check = function() { + sendTouchpadScrollMotion(scrollbox, 1, ctrlKey, isMomentum); + winUtils.advanceTimeAndRefresh(1000); // force scrolling to happen + + setTimeout(function () { if (!ctrlKey) { let postfix = isMomentum ? ", even after releasing the touchpad" : ""; // Normal scroll: scroll @@ -122,21 +86,12 @@ function runTest() { isnot(scrollbox.scrollTop, scrollTopBefore, "Momentum scrolling should scroll, even when pressing Ctrl"); } } + // Revert the effect. + sendTouchpadScrollMotion(scrollbox, -1, ctrlKey, isMomentum); + winUtils.advanceTimeAndRefresh(1000); // force scrolling to happen - if (!outstandingTests.length) { - winUtils.restoreNormalRefresh(); - win.close(); - SimpleTest.finish(); - return; - } - - // Revert the effect for the next test. - sendTouchpadScrollMotion(scrollbox, -1, ctrlKey, isMomentum, function() { - setTimeout(nextTest, 0); - }); - } - - sendTouchpadScrollMotion(scrollbox, 1, ctrlKey, isMomentum, check); + setTimeout(nextTest, 20); + }, 20); } nextTest(); }, win); @@ -151,6 +106,7 @@ window.onload = function() { } SimpleTest.waitForExplicitFinish(); +SimpleTest.requestFlakyTimeout("untriaged"); diff --git a/layout/generic/test/mochitest.ini b/layout/generic/test/mochitest.ini index 59a4509c747..126ec362582 100644 --- a/layout/generic/test/mochitest.ini +++ b/layout/generic/test/mochitest.ini @@ -127,7 +127,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1 [test_plugin_position.xhtml] skip-if = e10s [test_scroll_behavior.html] -skip-if = buildapp == 'b2g' # Bug 1062609 +skip-if = e10s || buildapp == 'b2g' # Bug 1062609 [test_selection_expanding.html] skip-if = buildapp == 'mulet' || buildapp == 'b2g' # b2g(mouse selection not working) b2g-debug(mouse selection not working) b2g-desktop(mouse selection not working) support-files = selection_expanding_xbl.xml diff --git a/layout/generic/test/test_bug784410.html b/layout/generic/test/test_bug784410.html index 133435107b2..eff5c12e7f7 100644 --- a/layout/generic/test/test_bug784410.html +++ b/layout/generic/test/test_bug784410.html @@ -4,7 +4,6 @@ Test bug 784410 - @@ -39,16 +38,13 @@ function doneScroll() { outer.scrollTop = 0; break; case 2: - // Wait for paints to flush, so APZ is notified of the new scroll offset. - sendWheelAndPaint(inner, 4, 4, - { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 }, - function() {}); + synthesizeWheel(inner, 4, 4, + { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 }); break; case 3: is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down"); ok(outer.scrollTop > 0, "Outer element should have scrolled down"); - SpecialPowers.DOMWindowUtils.restoreNormalRefresh(); SimpleTest.finish(); break; } diff --git a/layout/generic/test/test_scroll_behavior.html b/layout/generic/test/test_scroll_behavior.html index 4508e84c36f..ad08abf37fa 100644 --- a/layout/generic/test/test_scroll_behavior.html +++ b/layout/generic/test/test_scroll_behavior.html @@ -29,28 +29,19 @@ } window.addEventListener("load", function(event) { - if (event.target != document) - return; - - // See bug 1062609 - these tests do not work with APZ yet. If APZ is - // enabled, end the tests early. - if (SpecialPowers.getBoolPref("layers.async-pan-zoom.enabled")) { - todo(false, "This test does not yet work with APZ."); - SimpleTest.finish(); - return; - } - - SpecialPowers.pushPrefEnv( - { 'set': [['layout.css.scroll-behavior.enabled', true]] }, - function () { - testScrollBehaviorInterruption(function() { - testScrollBehaviorFramerate(function() { - window.scrollTo(0,0); - SimpleTest.finish(); + if (event.target == document) { + SpecialPowers.pushPrefEnv( + { 'set': [['layout.css.scroll-behavior.enabled', true]] }, + function () { + testScrollBehaviorInterruption(function() { + testScrollBehaviorFramerate(function() { + window.scrollTo(0,0); + SimpleTest.finish(); + }); }); - }); - } - ); + } + ); + } }, false); diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index 5eb92d64bd6..12b02beaccc 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -5,7 +5,6 @@ * sendChar * sendString * sendKey - * sendWheelAndPaint * synthesizeMouse * synthesizeMouseAtCenter * synthesizePointer @@ -431,49 +430,6 @@ function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) lineOrPageDeltaX, lineOrPageDeltaY, options); } -/** - * This is a wrapper around synthesizeWheel that waits for the wheel event - * to be dispatched and for the subsequent layout/paints to be flushed. - * - * This requires including paint_listener.js. Tests must call - * DOMWindowUtils.restoreNormalRefresh() before finishing, if they use this - * function. - */ -function sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, aEvent, aCallback, aWindow) { - aWindow = aWindow || window; - - var utils = _getDOMWindowUtils(aWindow); - if (!utils) - return; - - if (utils.isMozAfterPaintPending) { - // If a paint is pending, then APZ may be waiting for a scroll acknowledgement - // from the content thread. If we send a wheel event now, it could be ignored - // by APZ (or its scroll offset could be overridden). To avoid problems we - // just wait for the paint to complete. - aWindow.waitForAllPaintsFlushed(function() { - sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, aEvent, aCallback, aWindow); - }); - return; - } - - var onwheel = function() { - window.removeEventListener("wheel", onwheel); - - // Wait one frame since the wheel event has not caused a refresh observer - // to be added yet. - setTimeout(function() { - utils.advanceTimeAndRefresh(1000); - aWindow.waitForAllPaintsFlushed(function() { - aCallback(); - }); - }, 0); - }; - - aWindow.addEventListener("wheel", onwheel); - synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow); -} - function _computeKeyCodeFromChar(aChar) { if (aChar.length != 1) { diff --git a/toolkit/content/tests/chrome/test_mousescroll.xul b/toolkit/content/tests/chrome/test_mousescroll.xul index ebd4788b237..fa6f19d69f4 100644 --- a/toolkit/content/tests/chrome/test_mousescroll.xul +++ b/toolkit/content/tests/chrome/test_mousescroll.xul @@ -8,7 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=378028 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">