Bug 1273654 - Reuse the apz test utils in a few more places. r?botond
MozReview-Commit-ID: H1pigKUc9ln
--- a/gfx/layers/apz/test/mochitest/helper_long_tap.html
+++ b/gfx/layers/apz/test/mochitest/helper_long_tap.html
@@ -37,28 +37,22 @@ function recordEvent(e) {
flushApzRepaints(function() {
dump("Done APZ flush, ending test...\n");
subtestDone(); // closing the window should dismiss the context menu dialog
});
});
}
}
-function registerListeners() {
- window.addEventListener('touchstart', recordEvent, { passive: true, capture: true });
- window.addEventListener('touchend', recordEvent, { passive: true, capture: true });
- window.addEventListener('touchcancel', recordEvent, true);
- window.addEventListener('contextmenu', recordEvent, true);
-}
+window.addEventListener('touchstart', recordEvent, { passive: true, capture: true });
+window.addEventListener('touchend', recordEvent, { passive: true, capture: true });
+window.addEventListener('touchcancel', recordEvent, true);
+window.addEventListener('contextmenu', recordEvent, true);
-window.onload = function() {
- registerListeners();
- waitForAllPaints(function() {
- flushApzRepaints(longPressLink);
- });
-}
+waitUntilApzStable()
+.then(longPressLink);
</script>
</head>
<body>
<a id="b" href="#">Link to nowhere</a>
</body>
</html>
--- a/gfx/layers/apz/test/mochitest/helper_tap_passive.html
+++ b/gfx/layers/apz/test/mochitest/helper_tap_passive.html
@@ -43,26 +43,20 @@ function recordEvent(e) {
e.preventDefault();
synthesizeNativeTouch(document.getElementById('b'), 5, 5, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, function() {
dump("Finished synthesizing touch-end to clear state; finishing test...\n");
subtestDone();
});
}
-function registerListeners() {
- window.addEventListener('touchstart', recordEvent, { passive: true, capture: true });
- window.addEventListener('contextmenu', recordEvent, true);
-}
+window.addEventListener('touchstart', recordEvent, { passive: true, capture: true });
+window.addEventListener('contextmenu', recordEvent, true);
-window.onload = function() {
- registerListeners();
- waitForAllPaints(function() {
- flushApzRepaints(longPressLink);
- });
-}
+waitUntilApzStable()
+.then(longPressLink);
</script>
</head>
<body>
<a id="b" href="#">Link to nowhere</a>
</body>
</html>
--- a/gfx/layers/apz/test/mochitest/test_bug1151663.html
+++ b/gfx/layers/apz/test/mochitest/test_bug1151663.html
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
// Run the actual test in its own window, because it requires that the
// root APZC be scrollable. Mochitest pages themselves often run
// inside an iframe which means we have no control over the root APZC.
var w = null;
window.onload = function() {
- SpecialPowers.pushPrefEnv({"set": [["apz.test.logging_enabled", true]]}, function() {
+ pushPrefs([["apz.test.logging_enabled", true]]).then(function() {
w = window.open("helper_bug1151663.html", "_blank");
});
};
}
function finishTest() {
w.close();
SimpleTest.finish();
--- a/gfx/layers/apz/test/mochitest/test_bug982141.html
+++ b/gfx/layers/apz/test/mochitest/test_bug982141.html
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
// Run the actual test in its own window, because it requires that the
// root APZC not be scrollable. Mochitest pages themselves often run
// inside an iframe which means we have no control over the root APZC.
var w = null;
window.onload = function() {
- SpecialPowers.pushPrefEnv({"set": [["apz.test.logging_enabled", true]]}, function() {
+ pushPrefs([["apz.test.logging_enabled", true]]).then(function() {
w = window.open("helper_bug982141.html", "_blank");
});
};
}
function finishTest() {
w.close();
SimpleTest.finish();