Bug 1273654 - Reuse the apz test utils in a few more places. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 25 May 2016 10:00:07 -0400
changeset 370880 057f2817785fd967b12a279613f0203d9bf4f3ad
parent 370879 e4a60ec6a8a0ad3071062926ebdf83236afeb03e
child 370881 812322f9f073cdc55da29e52ab61328cd61a8f2b
push id19168
push userkgupta@mozilla.com
push dateWed, 25 May 2016 14:24:41 +0000
reviewersbotond
bugs1273654
milestone49.0a1
Bug 1273654 - Reuse the apz test utils in a few more places. r?botond MozReview-Commit-ID: H1pigKUc9ln
gfx/layers/apz/test/mochitest/helper_long_tap.html
gfx/layers/apz/test/mochitest/helper_tap_passive.html
gfx/layers/apz/test/mochitest/test_bug1151663.html
gfx/layers/apz/test/mochitest/test_bug982141.html
--- 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();