Bug 1276107 - Move scrollWheelOver() into apz_test_native_event_utils.js, renaming it to moveMouseAndScrollWheelOver(). r=kats

MozReview-Commit-ID: JgJIZm783qK

--HG--
extra : source : f492d508146b30a84c6e197d383fb587735382ff
extra : histedit_source : 94099476c51283ca8953127d09aa9ebfec01866d
This commit is contained in:
Botond Ballo 2016-06-01 19:39:20 -04:00
Родитель 5067bf046b
Коммит cac77c7630
2 изменённых файлов: 26 добавлений и 20 удалений

Просмотреть файл

@ -241,3 +241,23 @@ function synthesizeNativeClick(aElement, aX, aY, aObserver = null) {
});
return true;
}
// Move the mouse to (dx, dy) relative to |element|, and scroll the wheel
// at that location.
// Moving the mouse is necessary to avoid wheel events from two consecutive
// scrollWheelOver() calls on different elements being incorreclty considered
// as part of t he same wheel transaction.
// We also wait for the mouse move event to be processed before sending the
// wheel event, otherwise there is a chance they might get reordered, and
// we have the transaction problem again.
// XXX FOOTGUN: On Windows, if the mouse cursor is already at the target
// position, the mouse-move event doesn't get dispatched, and
// we end up hanging waiting for it. As a result, care must
// be taken that the mouse isn't already at the target position
// when using this function.
function moveMouseAndScrollWheelOver(element, dx, dy, testDriver) {
return synthesizeNativeMouseMoveAndWaitForMoveEvent(element, dx, dy, function() {
synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver);
});
}

Просмотреть файл

@ -6,45 +6,31 @@
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
// Scroll the mouse wheel at (dx, dy) relative to |element|.
function scrollWheelOver(element, dx, dy, testDriver) {
// Move the mouse to the desired wheel location.
// Not doing so can result in the wheel events from two consecutive
// scrollWheelOver() calls on different elements being incorrectly considered
// as part of the same wheel transaction.
// We also wait for the mouse move event to be processed before sending the
// wheel event, otherwise there is a chance they might get reordered, and
// we have the transaction problem again.
return synthesizeNativeMouseMoveAndWaitForMoveEvent(element, dx, dy, function() {
synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver);
});
}
function* test(testDriver) {
var iframeWin = document.getElementById('iframe').contentWindow;
// scroll over the middle of the iframe's position:sticky element, check
// that it scrolls the iframe
var scrollPos = iframeWin.scrollY;
yield scrollWheelOver(iframeWin.document.body, 50, 150, testDriver);
yield moveMouseAndScrollWheelOver(iframeWin.document.body, 50, 150, testDriver);
ok(iframeWin.scrollY > scrollPos, "iframe scrolled after wheeling over the position:sticky element");
// same, but using the iframe's position:fixed element
scrollPos = iframeWin.scrollY;
yield scrollWheelOver(iframeWin.document.body, 250, 150, testDriver);
yield moveMouseAndScrollWheelOver(iframeWin.document.body, 250, 150, testDriver);
ok(iframeWin.scrollY > scrollPos, "iframe scrolled after wheeling over the position:fixed element");
// same, but scrolling the scrollable frame *inside* the position:fixed item
var fpos = document.getElementById('fpos_scrollable');
scrollPos = fpos.scrollTop;
yield scrollWheelOver(fpos, 50, 150, testDriver);
yield moveMouseAndScrollWheelOver(fpos, 50, 150, testDriver);
ok(fpos.scrollTop > scrollPos, "scrollable item inside fixed-pos element scrolled");
// wait for it to layerize fully and then try again
yield waitForAllPaints(function() {
flushApzRepaints(testDriver);
});
scrollPos = fpos.scrollTop;
// The mouse is already at the right position. If we call scrollWheelOver it
// The mouse is already at the right position. If we call moveMouseAndScrollWheelOver it
// hangs on windows waiting for the mouse-move, so instead we just synthesize
// the wheel directly.
yield synthesizeNativeWheelAndWaitForScrollEvent(fpos, 50, 150, 0, -10, testDriver);
@ -52,12 +38,12 @@ function* test(testDriver) {
// same, but using the top-level window's position:sticky element
scrollPos = window.scrollY;
yield scrollWheelOver(document.body, 50, 150, testDriver);
yield moveMouseAndScrollWheelOver(document.body, 50, 150, testDriver);
ok(window.scrollY > scrollPos, "top-level document scrolled after wheeling over the position:sticky element");
// same, but using the top-level window's position:fixed element
scrollPos = window.scrollY;
yield scrollWheelOver(document.body, 250, 150, testDriver);
yield moveMouseAndScrollWheelOver(document.body, 250, 150, testDriver);
ok(window.scrollY > scrollPos, "top-level document scrolled after wheeling over the position:fixed element");
}