Bug 1273654 - Extract a helper function to run continuation-style tests. r=botond

MozReview-Commit-ID: 67WYQr1d7YO
This commit is contained in:
Kartikaya Gupta 2016-05-25 15:31:52 -04:00
Родитель 52b50801d8
Коммит 1dbcbb831c
8 изменённых файлов: 131 добавлений и 160 удалений

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

@ -233,3 +233,37 @@ function isApzEnabled() {
}
return enabled;
}
// Despite what this function name says, this does not *directly* run the
// provided continuation testFunction. Instead, it returns a function that
// can be used to run the continuation. The extra level of indirection allows
// it to be more easily added to a promise chain, like so:
// waitUntilApzStable().then(runContinuation(myTest));
//
// If you want to run the continuation directly, outside of a promise chain,
// you can invoke the return value of this function, like so:
// runContinuation(myTest)();
function runContinuation(testFunction) {
// We need to wrap this in an extra function, so that the call site can
// be more readable without running the promise too early. In other words,
// if we didn't have this extra function, the promise would start running
// during construction of the promise chain, concurrently with the first
// promise in the chain.
return function() {
return new Promise(function(resolve, reject) {
var testContinuation = null;
function driveTest() {
if (!testContinuation) {
testContinuation = testFunction(driveTest);
}
var ret = testContinuation.next();
if (ret.done) {
resolve();
}
}
driveTest();
});
};
}

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

@ -4,7 +4,7 @@
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
function* runTest() {
function* test(testDriver) {
var scroller = document.getElementById('scroller');
var scrollerPos = scroller.scrollTop;
var dx = 100, dy = 50;
@ -12,38 +12,29 @@ function* runTest() {
is(window.scrollY, 0, "Initial page scroll position should be 0");
is(scrollerPos, 0, "Initial scroller position should be 0");
yield synthesizeNativeMouseMoveAndWaitForMoveEvent(scroller, dx, dy, driveTest);
yield synthesizeNativeWheelAndWaitForScrollEvent(scroller, dx, dy, 0, -10, driveTest);
yield synthesizeNativeMouseMoveAndWaitForMoveEvent(scroller, dx, dy, testDriver);
yield synthesizeNativeWheelAndWaitForScrollEvent(scroller, dx, dy, 0, -10, testDriver);
is(window.scrollY, 0, "Page scroll position should still be 0");
ok(scroller.scrollTop > scrollerPos, "Scroller should have scrolled");
// wait for it to layerize fully and then try again
yield waitForAllPaints(function() {
flushApzRepaints(driveTest);
flushApzRepaints(testDriver);
});
scrollerPos = scroller.scrollTop;
// The mouse is already at the right position. If we call scrollWheelOver it
// hangs on windows waiting for the mouse-move, so instead we just synthesize
// the wheel directly.
yield synthesizeNativeWheelAndWaitForScrollEvent(scroller, dx, dy, 0, -10, driveTest);
yield synthesizeNativeWheelAndWaitForScrollEvent(scroller, dx, dy, 0, -10, testDriver);
is(window.scrollY, 0, "Page scroll position should still be 0 after layerization");
ok(scroller.scrollTop > scrollerPos, "Scroller should have continued scrolling");
}
var gTestContinuation = null;
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
subtestDone();
}
}
waitUntilApzStable().then(driveTest);
waitUntilApzStable()
.then(runContinuation(test))
.then(subtestDone);
</script>
<style>

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

@ -9,15 +9,15 @@
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
function* runTest() {
function* test(testDriver) {
document.addEventListener('click', clicked, false);
// mouse down, move it around, and release it near where it went down. this
// should generate a click at the release point
yield synthesizeNativeMouseEvent(document.getElementById('b'), 5, 5, nativeMouseDownEventMsg(), driveTest);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 100, 100, nativeMouseMoveEventMsg(), driveTest);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 10, 10, nativeMouseMoveEventMsg(), driveTest);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 8, 8, nativeMouseUpEventMsg(), driveTest);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 5, 5, nativeMouseDownEventMsg(), testDriver);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 100, 100, nativeMouseMoveEventMsg(), testDriver);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 10, 10, nativeMouseMoveEventMsg(), testDriver);
yield synthesizeNativeMouseEvent(document.getElementById('b'), 8, 8, nativeMouseUpEventMsg(), testDriver);
dump("Finished synthesizing click with a drag in the middle\n");
}
@ -30,16 +30,8 @@ function clicked(e) {
subtestDone();
}
var gTestContinuation = null;
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
gTestContinuation.next();
}
waitUntilApzStable().then(driveTest);
waitUntilApzStable()
.then(runContinuation(test));
</script>
</head>

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

@ -7,7 +7,7 @@
<script type="application/javascript">
// Scroll the mouse wheel at (dx, dy) relative to |element|.
function scrollWheelOver(element, dx, dy) {
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
@ -16,63 +16,54 @@ function scrollWheelOver(element, dx, dy) {
// 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, driveTest);
synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver);
});
}
function* runTest() {
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);
yield scrollWheelOver(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);
yield scrollWheelOver(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);
yield scrollWheelOver(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(driveTest);
flushApzRepaints(testDriver);
});
scrollPos = fpos.scrollTop;
// The mouse is already at the right position. If we call scrollWheelOver it
// hangs on windows waiting for the mouse-move, so instead we just synthesize
// the wheel directly.
yield synthesizeNativeWheelAndWaitForScrollEvent(fpos, 50, 150, 0, -10, driveTest);
yield synthesizeNativeWheelAndWaitForScrollEvent(fpos, 50, 150, 0, -10, testDriver);
ok(fpos.scrollTop > scrollPos, "scrollable item inside fixed-pos element scrolled after layerization");
// same, but using the top-level window's position:sticky element
scrollPos = window.scrollY;
yield scrollWheelOver(document.body, 50, 150);
yield scrollWheelOver(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);
yield scrollWheelOver(document.body, 250, 150, testDriver);
ok(window.scrollY > scrollPos, "top-level document scrolled after wheeling over the position:fixed element");
}
var gTestContinuation = null;
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
subtestDone();
}
}
waitUntilApzStable().then(driveTest);
waitUntilApzStable()
.then(runContinuation(test))
.then(subtestDone);
</script>
</head>

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

@ -154,10 +154,10 @@
<pre id="test">
<script type="application/javascript;version=1.7">
function* runTest() {
function* test(testDriver) {
var elm = document.getElementsByClassName('inner')[0];
elm.scrollTop = 0;
yield flushApzRepaints(driveTest);
yield flushApzRepaints(testDriver);
// Take over control of the refresh driver and compositor
var utils = SpecialPowers.DOMWindowUtils;
@ -165,12 +165,12 @@ function* runTest() {
// Kick off an APZ smooth-scroll to 0,200
elm.scrollTo(0, 200);
yield waitForAllPaints(function() { setTimeout(driveTest, 0); });
yield waitForAllPaints(function() { setTimeout(testDriver, 0); });
// Let's do a couple of frames of the animation, and make sure it's going
utils.advanceTimeAndRefresh(16);
utils.advanceTimeAndRefresh(16);
yield flushApzRepaints(driveTest);
yield flushApzRepaints(testDriver);
ok(elm.scrollTop > 0, "APZ animation in progress", "scrollTop is now " + elm.scrollTop);
ok(elm.scrollTop < 200, "APZ animation not yet completed", "scrollTop is now " + elm.scrollTop);
@ -190,7 +190,7 @@ function* runTest() {
// and the frame reconstruction
utils.advanceTimeAndRefresh(16);
utils.advanceTimeAndRefresh(16);
yield flushApzRepaints(driveTest);
yield flushApzRepaints(testDriver);
ok(elm.scrollTop < 200, "APZ animation not yet completed", "scrollTop is now " + elm.scrollTop);
ok(frameReconstructionTriggered > 0, "Frame reconstruction triggered", "reconstruction triggered " + frameReconstructionTriggered + " times");
@ -199,27 +199,18 @@ function* runTest() {
utils.advanceTimeAndRefresh(16);
}
utils.restoreNormalRefresh();
yield waitForAllPaints(function() { setTimeout(driveTest, 0); });
yield flushApzRepaints(driveTest);
yield waitForAllPaints(function() { setTimeout(testDriver, 0); });
yield flushApzRepaints(testDriver);
is(elm.scrollTop, 200, "Element should have scrolled by 200px");
}
var gTestContinuation = null;
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
}
}
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
SimpleTest.expectAssertions(0, 1); // this test triggers an assertion, see bug 1247050
waitUntilApzStable().then(driveTest);
waitUntilApzStable()
.then(runContinuation(test))
.then(SimpleTest.finish);
}
</script>

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

@ -54,7 +54,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1173580
<script type="application/javascript;version=1.7">
// Scroll the mouse wheel over |element|.
function scrollWheelOver(element, waitForScroll = true) {
function scrollWheelOver(element, waitForScroll, testDriver) {
var x = 10;
var y = 10;
// Move the mouse to the desired wheel location.
@ -66,14 +66,13 @@ function scrollWheelOver(element, waitForScroll = true) {
// we have the transaction problem again.
synthesizeNativeMouseMoveAndWaitForMoveEvent(element, x, y, function() {
if (waitForScroll) {
synthesizeNativeWheelAndWaitForScrollEvent(element, x, y, 0, -10, driveTest);
synthesizeNativeWheelAndWaitForScrollEvent(element, x, y, 0, -10, testDriver);
} else {
synthesizeNativeWheelAndWaitForWheelEvent(element, x, y, 0, -10, driveTest);
synthesizeNativeWheelAndWaitForWheelEvent(element, x, y, 0, -10, testDriver);
}
});
}
var gTestContinuation = null;
var utils;
const DISPLAYPORT_EXPIRY = 100;
@ -97,15 +96,19 @@ function isLayerized(elementId) {
return false;
}
// Helper function to pass to waitForAllPaints rather than passing driveTest
// directly. If there are no paints pending waitForAllPaints will invoke the
// callback synchronously, and if we did waitForAllPaints(driveTest) that might
// cause reentrancy into driveTest which is bad.
function callDriveTestAsync() {
setTimeout(driveTest, 0);
// This helper function produces another helper function, which, when invoked,
// invokes the provided testDriver argument in a setTimeout 0. This is really
// just useful in cases when there are no paints pending, because then
// waitForAllPaints will invoke its callback synchronously. If we did
// waitForAllPaints(testDriver) that might cause reentrancy into the testDriver
// which is bad. This function works around that.
function asyncWrapper(testDriver) {
return function() {
setTimeout(testDriver, 0);
};
}
function* runTest() {
function* test(testDriver) {
utils = SpecialPowers.getDOMWindowUtils(window);
// Initially, nothing should be layerized.
@ -119,12 +122,12 @@ function* runTest() {
ok(!isLayerized('inner4'), "initially 'inner4' should not be layerized");
// Scrolling over outer1 should layerize outer1, but not inner1.
yield scrollWheelOver(document.getElementById('outer1'));
yield scrollWheelOver(document.getElementById('outer1'), true, testDriver);
ok(isLayerized('outer1'), "scrolling 'outer1' should cause it to be layerized");
ok(!isLayerized('inner1'), "scrolling 'outer1' should not cause 'inner1' to be layerized");
// Scrolling over inner2 should layerize both outer2 and inner2.
yield scrollWheelOver(document.getElementById('inner2'));
yield scrollWheelOver(document.getElementById('inner2'), true, testDriver);
ok(isLayerized('inner2'), "scrolling 'inner2' should cause it to be layerized");
ok(isLayerized('outer2'), "scrolling 'inner2' should also cause 'outer2' to be layerized");
@ -132,18 +135,18 @@ function* runTest() {
// but with an iframe as the outer scrollable frame.
// Scrolling over outer3 should layerize outer3, but not inner3.
yield scrollWheelOver(document.getElementById('outer3').contentDocument.documentElement);
yield scrollWheelOver(document.getElementById('outer3').contentDocument.documentElement, true, testDriver);
ok(isLayerized('outer3'), "scrolling 'outer3' should cause it to be layerized");
ok(!isLayerized('inner3'), "scrolling 'outer3' should not cause 'inner3' to be layerized");
// Scrolling over outer4 should layerize both outer4 and inner4.
yield scrollWheelOver(document.getElementById('outer4').contentDocument.getElementById('inner4'));
yield scrollWheelOver(document.getElementById('outer4').contentDocument.getElementById('inner4'), true, testDriver);
ok(isLayerized('inner4'), "scrolling 'inner4' should cause it to be layerized");
ok(isLayerized('outer4'), "scrolling 'inner4' should also cause 'outer4' to be layerized");
// Now we enable displayport expiry, and verify that things are still
// layerized as they were before.
yield SpecialPowers.pushPrefEnv({"set": [["apz.displayport_expiry_ms", DISPLAYPORT_EXPIRY]]}, driveTest);
yield SpecialPowers.pushPrefEnv({"set": [["apz.displayport_expiry_ms", DISPLAYPORT_EXPIRY]]}, testDriver);
ok(isLayerized('outer1'), "outer1 is still layerized after enabling expiry");
ok(!isLayerized('inner1'), "inner1 is still not layerized after enabling expiry");
ok(isLayerized('outer2'), "outer2 is still layerized after enabling expiry");
@ -157,27 +160,27 @@ function* runTest() {
// the displayport expiry gets triggered.
// Expire displayport with scrolling on outer1
yield scrollWheelOver(document.getElementById('outer1'));
yield scrollWheelOver(document.getElementById('outer1'), true, testDriver);
yield waitForAllPaints(function() {
flushApzRepaints(driveTest);
flushApzRepaints(testDriver);
});
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(!isLayerized('outer1'), "outer1 is no longer layerized after displayport expiry");
ok(!isLayerized('inner1'), "inner1 is still not layerized after displayport expiry");
// Expire displayport with scrolling on inner2
yield scrollWheelOver(document.getElementById('inner2'));
yield scrollWheelOver(document.getElementById('inner2'), true, testDriver);
yield waitForAllPaints(function() {
flushApzRepaints(driveTest);
flushApzRepaints(testDriver);
});
// Once the expiry elapses, it will trigger expiry on outer2, so we check
// both, one at a time.
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(!isLayerized('inner2'), "inner2 is no longer layerized after displayport expiry");
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(!isLayerized('outer2'), "outer2 got de-layerized with inner2");
// Scroll on inner3. inner3 isn't layerized, and this will cause it to
@ -186,40 +189,30 @@ function* runTest() {
// Note that the displayport expiration might actually happen before the wheel
// input is processed in the compositor (see bug 1246480 comment 3), and so
// we make sure not to wait for a scroll event here, since it may never fire.
yield scrollWheelOver(document.getElementById('outer3').contentDocument.getElementById('inner3'), false);
yield scrollWheelOver(document.getElementById('outer3').contentDocument.getElementById('inner3'), false, testDriver);
yield waitForAllPaints(function() {
flushApzRepaints(driveTest);
flushApzRepaints(testDriver);
});
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(!isLayerized('inner3'), "inner3 becomes unlayerized after expiry");
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(!isLayerized('outer3'), "outer3 is no longer layerized after inner3 triggered expiry");
// Scroll outer4 and wait for the expiry. It should NOT get expired because
// inner4 is still layerized
yield scrollWheelOver(document.getElementById('outer4').contentDocument.documentElement);
yield scrollWheelOver(document.getElementById('outer4').contentDocument.documentElement, true, testDriver);
yield waitForAllPaints(function() {
flushApzRepaints(driveTest);
flushApzRepaints(testDriver);
});
// Wait for the expiry to elapse
yield setTimeout(driveTest, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(callDriveTestAsync);
yield setTimeout(testDriver, DISPLAYPORT_EXPIRY);
yield waitForAllPaints(asyncWrapper(testDriver));
ok(isLayerized('inner4'), "inner4 is still layerized because it never expired");
ok(isLayerized('outer4'), "outer4 is still layerized because inner4 is still layerized");
}
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
}
}
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("we are testing code that measures an actual timeout");
@ -234,7 +227,8 @@ if (isApzEnabled()) {
["apz.displayport_expiry_ms", 0],
["apz.test.logging_enabled", true]])
.then(waitUntilApzStable)
.then(driveTest);
.then(runContinuation(test))
.then(SimpleTest.finish);
}
</script>

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

@ -77,10 +77,10 @@ document.getElementById("scrollbox").addEventListener("wheel", function (e) {
e.preventDefault();
});
function* runTest() {
function* test(testDriver) {
var content = document.getElementById('content');
for (i = 0; i < 300; i++) { // enough iterations that we would scroll to the bottom of 'content'
yield synthesizeNativeWheelAndWaitForWheelEvent(content, 100, 150, 0, -5, continueTest);
yield synthesizeNativeWheelAndWaitForWheelEvent(content, 100, 150, 0, -5, testDriver);
}
var scrollbox = document.getElementById('scrollbox');
is(content.scrollTop > 0, true, "We should have scrolled down somewhat");
@ -88,19 +88,6 @@ function* runTest() {
is(rotationAdjusted, true, "The rotation should have been adjusted");
}
var gTestContinuation = null;
function continueTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
} else {
is(ret.value, true, "Wheel event successfully synthesized");
}
}
SimpleTest.testInChaosMode();
SimpleTest.waitForExplicitFinish();
@ -109,7 +96,8 @@ SimpleTest.waitForExplicitFinish();
// we might end up at the bottom of the page.
pushPrefs([["general.smoothScroll", false]])
.then(waitUntilApzStable)
.then(continueTest);
.then(runContinuation(test))
.then(SimpleTest.finish);
</script>
</pre>

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

@ -41,11 +41,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1175585
<pre id="test">
<script type="application/javascript;version=1.7">
function scrollWheelOver(element, deltaY) {
synthesizeNativeWheelAndWaitForScrollEvent(element, 10, 10, 0, deltaY, driveTest);
function scrollWheelOver(element, deltaY, testDriver) {
synthesizeNativeWheelAndWaitForScrollEvent(element, 10, 10, 0, deltaY, testDriver);
}
function* runTest() {
function* test(testDriver) {
var outer = document.getElementById('outer-frame');
var inner = document.getElementById('inner-frame');
var innerContent = document.getElementById('inner-content');
@ -58,7 +58,7 @@ function* runTest() {
// Scroll |outer| to the bottom.
while (outer.scrollTop < outer.scrollTopMax) {
yield scrollWheelOver(outer, -10);
yield scrollWheelOver(outer, -10, testDriver);
}
// Verify that this has brought |inner| under the wheel.
@ -66,7 +66,7 @@ function* runTest() {
window.removeEventListener("wheel", wheelTargetRecorder);
// Immediately after, scroll it back up a bit.
yield scrollWheelOver(outer, 10);
yield scrollWheelOver(outer, 10, testDriver);
// Check that it was |outer| that scrolled back, and |inner| didn't
// scroll at all, as all the above scrolls should be in the same
@ -78,21 +78,21 @@ function* runTest() {
// Turn it down a bit so waiting for the timeout to elapse doesn't
// slow down the test harness too much.
var timeout = 5;
yield SpecialPowers.pushPrefEnv({"set": [["mousewheel.transaction.timeout", timeout]]}, driveTest);
yield SpecialPowers.pushPrefEnv({"set": [["mousewheel.transaction.timeout", timeout]]}, testDriver);
SimpleTest.requestFlakyTimeout("we are testing code that measures actual elapsed time between two events");
// Scroll up a bit more. It's still |outer| scrolling because
// |inner| is still scrolled all the way to the top.
yield scrollWheelOver(outer, 10);
yield scrollWheelOver(outer, 10, testDriver);
// Wait for the transaction timeout to elapse.
// timeout * 5 is used to make it less likely that the timeout is less than
// the system timestamp resolution
yield window.setTimeout(driveTest, timeout * 5);
yield window.setTimeout(testDriver, timeout * 5);
// Now scroll down. The transaction having timed out, the event
// should pick up a new target, and that should be |inner|.
yield scrollWheelOver(outer, -10);
yield scrollWheelOver(outer, -10, testDriver);
ok(inner.scrollTop > 0, "'inner' should have been scrolled");
// Finally, test scroll handoff after a timeout.
@ -100,7 +100,7 @@ function* runTest() {
// Continue scrolling |inner| down to the bottom.
var prevScrollTop = inner.scrollTop;
while (inner.scrollTop < inner.scrollTopMax) {
yield scrollWheelOver(outer, -10);
yield scrollWheelOver(outer, -10, testDriver);
// Avoid a failure getting us into an infinite loop.
ok(inner.scrollTop > prevScrollTop, "scrolling down should increase scrollTop");
prevScrollTop = inner.scrollTop;
@ -109,36 +109,26 @@ function* runTest() {
// Wait for the transaction timeout to elapse.
// timeout * 5 is used to make it less likely that the timeout is less than
// the system timestamp resolution
yield window.setTimeout(driveTest, timeout * 5);
yield window.setTimeout(testDriver, timeout * 5);
// Continued downward scrolling should scroll |outer| to the bottom.
prevScrollTop = outer.scrollTop;
while (outer.scrollTop < outer.scrollTopMax) {
yield scrollWheelOver(outer, -10);
yield scrollWheelOver(outer, -10, testDriver);
// Avoid a failure getting us into an infinite loop.
ok(outer.scrollTop > prevScrollTop, "scrolling down should increase scrollTop");
prevScrollTop = outer.scrollTop;
}
}
var gTestContinuation = null;
function driveTest() {
if (!gTestContinuation) {
gTestContinuation = runTest();
}
var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
// Disable smooth scrolling because it makes the test flaky (we don't have a good
// way of detecting when the scrolling is finished).
pushPrefs([["general.smoothScroll", false]])
.then(waitUntilApzStable)
.then(driveTest);
.then(runContinuation(test))
.then(SimpleTest.finish);
</script>
</pre>