Backed out changeset a6b9c152a7d1 (bug 1140293) for mochitest failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-03-25 08:42:46 -04:00
parent e670fee3f5
commit e55eb3d955
6 changed files with 71 additions and 175 deletions

View File

@ -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");
</script>
</pre>

View File

@ -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

View File

@ -4,7 +4,6 @@
<title>Test bug 784410</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
@ -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;
}

View File

@ -29,17 +29,7 @@
}
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;
}
if (event.target == document) {
SpecialPowers.pushPrefEnv(
{ 'set': [['layout.css.scroll-behavior.enabled', true]] },
function () {
@ -51,6 +41,7 @@
});
}
);
}
}, false);

View File

@ -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) {

View File

@ -8,7 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=378028
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
@ -139,47 +138,46 @@ function testRichListbox(id, andThen)
var winUtils = SpecialPowers.getDOMWindowUtils(window);
winUtils.advanceTimeAndRefresh(100);
function nextTest() {
var [aStart, aDelta, aIntDelta, aDeltaMode] = tests.shift();
function helper()
{
var [aStart, aDelta, aIntDelta, aDeltaMode] = tests[0];
tests.shift();
listbox.scrollToIndex(aStart);
let event = {
deltaMode: aDeltaMode,
deltaY: aDelta,
lineOrPageDeltaY: aIntDelta
};
sendWheelAndPaint(listbox, 10, 10, event, function() {
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaY: aDelta,
lineOrPageDeltaY: aIntDelta });
winUtils.advanceTimeAndRefresh(100);
var change = listbox.getIndexOfFirstVisibleRow() - aStart;
var direction = (change > 0) - (change < 0);
var expected = (aDelta > 0) - (aDelta < 0);
is(direction, expected,
"testRichListbox(" + id + "): vertical, starting " + aStart +
" delta " + aDelta + " lineOrPageDeltaY " + aIntDelta +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
// Check that horizontal scrolling has no effect
let event = {
deltaMode: aDeltaMode,
deltaX: aDelta,
lineOrPageDeltaX: aIntDelta
};
listbox.scrollToIndex(aStart);
sendWheelAndPaint(listbox, 10, 10, event, function() {
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaX: aDelta,
lineOrPageDeltaX: aIntDelta });
winUtils.advanceTimeAndRefresh(100);
is(listbox.getIndexOfFirstVisibleRow(), aStart,
"testRichListbox(" + id + "): horizontal, starting " + aStart +
" delta " + aDelta + " lineOrPageDeltaX " + aIntDelta +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
if (!tests.length) {
if (tests.length) {
winUtils.advanceTimeAndRefresh(100);
helper();
} else {
winUtils.restoreNormalRefresh();
andThen();
return;
}
nextTest();
});
});
}
// richlistbox currently uses native XUL scrolling, so the "line"
@ -192,8 +190,7 @@ function testRichListbox(id, andThen)
tests.push([5, delta, 1, aDeltaMode]);
tests.push([5, delta, 0, aDeltaMode]);
});
nextTest();
helper();
}
function testArrowScrollbox(id)