mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix some tests that depend on synchronous scrolling. (bug 1140293 part 1, r=masayuki,mstange,kgilbert)
This commit is contained in:
parent
e0533b9451
commit
b23b745a66
@ -20,7 +20,37 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=574663
|
||||
|
||||
/** Test for Bug 574663 **/
|
||||
|
||||
function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum) {
|
||||
// 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) {
|
||||
var win = scrollbox.ownerDocument.defaultView;
|
||||
let event = {
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
@ -29,10 +59,26 @@ function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum) {
|
||||
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 = 0; i < 5; ++i) {
|
||||
for (let i = 1; i <= kExtraEvents; ++i) {
|
||||
synthesizeWheel(scrollbox, 10, 10, event, win);
|
||||
}
|
||||
}
|
||||
@ -57,21 +103,11 @@ 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;
|
||||
|
||||
sendTouchpadScrollMotion(scrollbox, 1, ctrlKey, isMomentum);
|
||||
winUtils.advanceTimeAndRefresh(1000); // force scrolling to happen
|
||||
|
||||
setTimeout(function () {
|
||||
let check = function() {
|
||||
if (!ctrlKey) {
|
||||
let postfix = isMomentum ? ", even after releasing the touchpad" : "";
|
||||
// Normal scroll: scroll
|
||||
@ -86,12 +122,21 @@ 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
|
||||
|
||||
setTimeout(nextTest, 20);
|
||||
}, 20);
|
||||
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);
|
||||
}
|
||||
nextTest();
|
||||
}, win);
|
||||
@ -106,7 +151,6 @@ window.onload = function() {
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestFlakyTimeout("untriaged");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -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 = e10s || buildapp == 'b2g' # Bug 1062609
|
||||
skip-if = 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
|
||||
|
@ -4,6 +4,7 @@
|
||||
<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>
|
||||
@ -38,13 +39,16 @@ function doneScroll() {
|
||||
outer.scrollTop = 0;
|
||||
break;
|
||||
case 2:
|
||||
synthesizeWheel(inner, 4, 4,
|
||||
{ deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 });
|
||||
// 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() {});
|
||||
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;
|
||||
}
|
||||
|
@ -29,19 +29,28 @@
|
||||
}
|
||||
|
||||
window.addEventListener("load", function(event) {
|
||||
if (event.target == document) {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ 'set': [['layout.css.scroll-behavior.enabled', true]] },
|
||||
function () {
|
||||
testScrollBehaviorInterruption(function() {
|
||||
testScrollBehaviorFramerate(function() {
|
||||
window.scrollTo(0,0);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}, false);
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* sendChar
|
||||
* sendString
|
||||
* sendKey
|
||||
* sendWheelAndPaint
|
||||
* synthesizeMouse
|
||||
* synthesizeMouseAtCenter
|
||||
* synthesizePointer
|
||||
@ -430,6 +431,49 @@ 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) {
|
||||
|
@ -8,6 +8,7 @@ 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">
|
||||
@ -138,46 +139,47 @@ function testRichListbox(id, andThen)
|
||||
var winUtils = SpecialPowers.getDOMWindowUtils(window);
|
||||
winUtils.advanceTimeAndRefresh(100);
|
||||
|
||||
function helper()
|
||||
{
|
||||
var [aStart, aDelta, aIntDelta, aDeltaMode] = tests[0];
|
||||
tests.shift();
|
||||
function nextTest() {
|
||||
var [aStart, aDelta, aIntDelta, aDeltaMode] = tests.shift();
|
||||
listbox.scrollToIndex(aStart);
|
||||
|
||||
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 + " lineOrPageDelta " + aIntDelta +
|
||||
" aDeltaMode " + aDeltaMode);
|
||||
|
||||
// Check that horizontal scrolling has no effect
|
||||
listbox.scrollToIndex(aStart);
|
||||
synthesizeWheel(listbox, 10, 10,
|
||||
{ deltaMode: aDeltaMode, deltaX: aDelta,
|
||||
lineOrPageDeltaX: aIntDelta });
|
||||
|
||||
winUtils.advanceTimeAndRefresh(100);
|
||||
|
||||
is(listbox.getIndexOfFirstVisibleRow(), aStart,
|
||||
"testRichListbox(" + id + "): horizontal, starting " + aStart +
|
||||
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
|
||||
let event = {
|
||||
deltaMode: aDeltaMode,
|
||||
deltaY: aDelta,
|
||||
lineOrPageDeltaY: aIntDelta
|
||||
};
|
||||
sendWheelAndPaint(listbox, 10, 10, event, function() {
|
||||
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 +
|
||||
" aDeltaMode " + aDeltaMode);
|
||||
|
||||
if (tests.length) {
|
||||
winUtils.advanceTimeAndRefresh(100);
|
||||
helper();
|
||||
} else {
|
||||
winUtils.restoreNormalRefresh();
|
||||
andThen();
|
||||
}
|
||||
// Check that horizontal scrolling has no effect
|
||||
let event = {
|
||||
deltaMode: aDeltaMode,
|
||||
deltaX: aDelta,
|
||||
lineOrPageDeltaX: aIntDelta
|
||||
};
|
||||
|
||||
listbox.scrollToIndex(aStart);
|
||||
sendWheelAndPaint(listbox, 10, 10, event, function() {
|
||||
is(listbox.getIndexOfFirstVisibleRow(), aStart,
|
||||
"testRichListbox(" + id + "): horizontal, starting " + aStart +
|
||||
" delta " + aDelta + " lineOrPageDeltaX " + aIntDelta +
|
||||
" aDeltaMode " + aDeltaMode);
|
||||
|
||||
if (!tests.length) {
|
||||
winUtils.restoreNormalRefresh();
|
||||
andThen();
|
||||
return;
|
||||
}
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// richlistbox currently uses native XUL scrolling, so the "line"
|
||||
@ -190,7 +192,8 @@ function testRichListbox(id, andThen)
|
||||
tests.push([5, delta, 1, aDeltaMode]);
|
||||
tests.push([5, delta, 0, aDeltaMode]);
|
||||
});
|
||||
helper();
|
||||
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function testArrowScrollbox(id)
|
||||
|
Loading…
Reference in New Issue
Block a user