Bug 1273654 - Extract a pushPrefs helper function to simplify test setup. r=botond

The set of changes in this patch removes all waitForFocus calls in the test
folder, except for the one in apz_test_utils.js. This results in less
boilerplate and more consistent test state initialization.

MozReview-Commit-ID: IYlTKDx7Xx2
This commit is contained in:
Kartikaya Gupta 2016-05-25 15:31:52 -04:00
Родитель 18103f612f
Коммит 93e2c8a220
7 изменённых файлов: 47 добавлений и 71 удалений

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

@ -209,6 +209,10 @@ function runSubtestsSeriallyInFreshWindows(aSubtests) {
});
}
function pushPrefs(prefs) {
return SpecialPowers.pushPrefEnv({'set': prefs});
}
function waitUntilApzStable() {
return new Promise(function(resolve, reject) {
SimpleTest.waitForFocus(function() {

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

@ -229,9 +229,7 @@ function startTest() {
return;
}
waitForAllPaints(function() {
flushApzRepaints(driveTest);
})
driveTest();
}
SimpleTest.waitForExplicitFinish();
@ -243,12 +241,12 @@ SimpleTest.expectAssertions(0, 8); // we get a bunch of "ASSERTION: Bounds compu
// wheel event as corresponding to a later wheel event.
// Also enable APZ test logging, since we use that data to determine whether
// a scroll frame was layerized.
SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false],
["apz.displayport_expiry_ms", 0],
["apz.test.logging_enabled", true]]},
function() {
SimpleTest.waitForFocus(startTest, window);
});
pushPrefs([["general.smoothScroll", false],
["apz.displayport_expiry_ms", 0],
["apz.test.logging_enabled", true]])
.then(waitUntilApzStable)
.then(startTest);
</script>
</pre>
</body>

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

@ -2,9 +2,10 @@
<html>
<head>
<title>Test scrolling flattened inactive frames</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style>
p {
@ -526,18 +527,15 @@ function doInnerScrollAgain(subframe, oldpos) {
});
}
window.onload = function() {
SpecialPowers.pushPrefEnv({
'set': [['general.smoothScroll', false],
['mousewheel.transaction.timeout', 0],
['mousewheel.transaction.ignoremovedelay', 0]]
}, function () {
SimpleTest.waitForFocus(test);
});
}
SimpleTest.testInChaosMode();
SimpleTest.waitForExplicitFinish();
pushPrefs([['general.smoothScroll', false],
['mousewheel.transaction.timeout', 0],
['mousewheel.transaction.ignoremovedelay', 0]])
.then(waitUntilApzStable)
.then(test);
</script>
</body>
</html>

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

@ -36,23 +36,14 @@ function test() {
});
}
function startTest() {
waitForAllPaints(function() {
flushApzRepaints(test);
});
}
window.onload = function() {
SpecialPowers.pushPrefEnv({
'set': [['general.smoothScroll', false],
['mousewheel.transaction.timeout', 1000000]],
}, function () {
SimpleTest.waitForFocus(startTest);
});
}
SimpleTest.testInChaosMode();
SimpleTest.waitForExplicitFinish();
pushPrefs([['general.smoothScroll', false],
['mousewheel.transaction.timeout', 1000000]])
.then(waitUntilApzStable)
.then(test);
</script>
</body>
</html>

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

@ -104,23 +104,14 @@ function testScrolling(subframe) {
});
}
function startTest() {
waitForAllPaints(function() {
flushApzRepaints(test);
});
}
window.onload = function() {
SpecialPowers.pushPrefEnv({
'set': [['general.smoothScroll', false],
['mousewheel.transaction.timeout', 0],
['mousewheel.transaction.ignoremovedelay', 0]]
}, function () {
SimpleTest.waitForFocus(startTest);
});
}
SimpleTest.waitForExplicitFinish();
pushPrefs([['general.smoothScroll', false],
['mousewheel.transaction.timeout', 0],
['mousewheel.transaction.ignoremovedelay', 0]])
.then(waitUntilApzStable)
.then(test);
</script>
</body>
</html>

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

@ -6,7 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1013412
<head>
<title>Test for Bug 1013412</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
@ -99,16 +101,15 @@ function continueTest() {
}
}
function startTest() {
// If we allow smooth scrolling the "smooth" scrolling may cause the page to
// glide past the scrollbox (which is supposed to stop the scrolling) and so
// we might end up at the bottom of the page.
SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]}, continueTest);
}
SimpleTest.testInChaosMode();
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest, window);
// If we allow smooth scrolling the "smooth" scrolling may cause the page to
// glide past the scrollbox (which is supposed to stop the scrolling) and so
// we might end up at the bottom of the page.
pushPrefs([["general.smoothScroll", false]])
.then(waitUntilApzStable)
.then(continueTest);
</script>
</pre>

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

@ -132,20 +132,13 @@ function driveTest() {
}
}
function startTest() {
waitForAllPaints(function() {
flushApzRepaints(driveTest);
});
}
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).
SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]},
function() {
SimpleTest.waitForFocus(startTest, window);
});
SimpleTest.waitForExplicitFinish();
pushPrefs([["general.smoothScroll", false]])
.then(waitUntilApzStable)
.then(driveTest);
</script>
</pre>