From 93e2c8a220888da3e6c666862623a1ebecc8aa13 Mon Sep 17 00:00:00 2001
From: Kartikaya Gupta
Date: Wed, 25 May 2016 15:31:52 -0400
Subject: [PATCH] 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
---
.../apz/test/mochitest/apz_test_utils.js | 4 ++++
.../apz/test/mochitest/test_layerization.html | 16 ++++++-------
.../test_scroll_inactive_bug1190112.html | 20 ++++++++--------
.../test_scroll_inactive_flattened_frame.html | 21 +++++------------
.../test_scroll_subframe_scrollbar.html | 23 ++++++-------------
.../apz/test/mochitest/test_wheel_scroll.html | 19 +++++++--------
.../mochitest/test_wheel_transactions.html | 15 ++++--------
7 files changed, 47 insertions(+), 71 deletions(-)
diff --git a/gfx/layers/apz/test/mochitest/apz_test_utils.js b/gfx/layers/apz/test/mochitest/apz_test_utils.js
index b6a07c6adedf..9cbf95aeb278 100644
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -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() {
diff --git a/gfx/layers/apz/test/mochitest/test_layerization.html b/gfx/layers/apz/test/mochitest/test_layerization.html
index 1ba093f1ec61..e85d6fdcfcdd 100644
--- a/gfx/layers/apz/test/mochitest/test_layerization.html
+++ b/gfx/layers/apz/test/mochitest/test_layerization.html
@@ -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);
+
diff --git a/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html b/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
index 0868ffe73379..3349ef1abc7c 100644
--- a/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
+++ b/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
@@ -2,9 +2,10 @@