Bug 1672237 - Update most remaining APZ mochitests to use SimpleTest.finishWithFailure. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 22 Oct 2020 00:47:22 +0000
changeset 553978 5b41917730e22209c7634c344a517e13682c6e24
parent 553977 e2a78f81a8bd17cf413f99c7333745231b520189
child 553979 85b2a686add3d00797ec5d4a7c21876012c85101
push id129161
push userkgupta@mozilla.com
push dateThu, 22 Oct 2020 01:46:38 +0000
treeherderautoland@718f9800877a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1672237
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1672237 - Update most remaining APZ mochitests to use SimpleTest.finishWithFailure. r=botond A few tests do the SimpleTest.waitForExplicitFinish/SimpleTest.finish dance without a promise/async chain. This updates those tests to follow a more async style and to send failures through SimpleTest.finishWithFailure. Note that the conversion to async is done "locally" by wrapping callback-taking helper function calls in promises. In some cases it probably makes sense to modify the helper function itself to return a promise, but that's out of scope for this bug, so I'm punting those kinds of changes to a follow-up bug. Differential Revision: https://phabricator.services.mozilla.com/D94163
gfx/layers/apz/test/mochitest/test_bug1151667.html
gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
gfx/layers/apz/test/mochitest/test_scroll_inactive_flattened_frame.html
gfx/layers/apz/test/mochitest/test_scroll_subframe_scrollbar.html
--- a/gfx/layers/apz/test/mochitest/test_bug1151667.html
+++ b/gfx/layers/apz/test/mochitest/test_bug1151667.html
@@ -39,27 +39,27 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <!-- This makes sure the page is also scrollable, so it (rather than the subframe)
      is considered the primary async-scrollable frame, and so the subframe isn't
      layerized upon page load. -->
 <div id="page-content"></div>
 <pre id="test">
 <script type="application/javascript">
 
-function startTest() {
+async function test() {
   var subframe = document.getElementById("subframe");
-  synthesizeNativeWheelAndWaitForScrollEvent(subframe, 100, 150, 0, -10, continueTest);
-}
+  await new Promise(resolve => {
+    synthesizeNativeWheelAndWaitForScrollEvent(subframe, 100, 150, 0, -10, resolve);
+  });
 
-function continueTest() {
-  var subframe = document.getElementById("subframe");
   is(subframe.scrollTop > 0, true, "We should have scrolled the subframe down");
   is(document.documentElement.scrollTop, 0, "We should not have scrolled the page");
-  SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
-waitUntilApzStable().then(startTest);
+waitUntilApzStable()
+  .then(test)
+  .then(SimpleTest.finish, SimpleTest.finishWithFailure);
 
 </script>
 </pre>
 </body>
 </html>
--- a/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
+++ b/gfx/layers/apz/test/mochitest/test_scroll_inactive_bug1190112.html
@@ -492,57 +492,61 @@ function ScrollTops() {
 }
 
 var DefaultEvent = {
   deltaMode: WheelEvent.DOM_DELTA_LINE,
   deltaX: 0, deltaY: 1,
   lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
 };
 
-function test() {
+async function test() {
   var subframe = document.getElementById("subframe");
   var oldpos = new ScrollTops();
-  sendWheelAndPaint(subframe, 10, 10, DefaultEvent, function() {
-    var newpos = new ScrollTops();
-    ok(oldpos.outerScrollTop == newpos.outerScrollTop, "viewport should not have scrolled");
-    ok(oldpos.innerScrollTop != newpos.innerScrollTop, "subframe should have scrolled");
-    doOuterScroll(subframe, newpos);
+  await new Promise(resolve => {
+    sendWheelAndPaint(subframe, 10, 10, DefaultEvent, resolve);
   });
-}
 
-function doOuterScroll(subframe, oldpos) {
+  var newpos = new ScrollTops();
+  ok(oldpos.outerScrollTop == newpos.outerScrollTop, "viewport should not have scrolled");
+  ok(oldpos.innerScrollTop != newpos.innerScrollTop, "subframe should have scrolled");
+  oldpos = newpos;
+
+  // Scroll outer
   var outer = document.getElementById("iframe-body");
-  sendWheelAndPaint(outer, 20, 5, DefaultEvent, function() {
-    var newpos = new ScrollTops();
-    ok(oldpos.outerScrollTop != newpos.outerScrollTop, "viewport should have scrolled");
-    ok(oldpos.innerScrollTop == newpos.innerScrollTop, "subframe should not have scrolled");
-    doInnerScrollAgain(subframe, newpos);
+  await new Promise(resolve => {
+    sendWheelAndPaint(outer, 20, 5, DefaultEvent, resolve);
   });
-}
 
-function doInnerScrollAgain(subframe, oldpos) {
+  newpos = new ScrollTops();
+  ok(oldpos.outerScrollTop != newpos.outerScrollTop, "viewport should have scrolled");
+  ok(oldpos.innerScrollTop == newpos.innerScrollTop, "subframe should not have scrolled");
+  oldpos = newpos;
+
+  // Scroll inner again
   // Tick the refresh driver once to make sure the compositor has sent the
   // updated scroll offset for the outer scroller to WebRender, so that the
   // hit-test in sendWheelAndPaint takes it into account. (This isn't needed
   // if using non-WR layers, but doesn't hurt either).
   var dwu = SpecialPowers.getDOMWindowUtils(window);
   dwu.advanceTimeAndRefresh(16);
   dwu.restoreNormalRefresh();
 
-  sendWheelAndPaint(subframe, 10, 10, DefaultEvent, function() {
-    var newpos = new ScrollTops();
-    ok(oldpos.outerScrollTop == newpos.outerScrollTop, "viewport should not have scrolled");
-    ok(oldpos.innerScrollTop != newpos.innerScrollTop, "subframe should have scrolled");
-    SimpleTest.finish();
+  await new Promise(resolve => {
+    sendWheelAndPaint(subframe, 10, 10, DefaultEvent, resolve);
   });
+
+  newpos = new ScrollTops();
+  ok(oldpos.outerScrollTop == newpos.outerScrollTop, "viewport should not have scrolled");
+  ok(oldpos.innerScrollTop != newpos.innerScrollTop, "subframe should have scrolled");
 }
 
 SimpleTest.waitForExplicitFinish();
 
 pushPrefs([["general.smoothScroll", false],
            ["mousewheel.transaction.timeout", 0],
            ["mousewheel.transaction.ignoremovedelay", 0]])
 .then(waitUntilApzStable)
-.then(test);
+.then(test)
+.then(SimpleTest.finish, SimpleTest.finishWithFailure);
 
 </script>
 </body>
 </html>
--- a/gfx/layers/apz/test/mochitest/test_scroll_inactive_flattened_frame.html
+++ b/gfx/layers/apz/test/mochitest/test_scroll_inactive_flattened_frame.html
@@ -11,38 +11,39 @@
 <body>
 <div id="container" style="height: 300px; width: 600px; overflow: auto; background: yellow">
  <div id="outer" style="height: 400px; width: 500px; overflow: auto; background: black">
   <div id="inner" style="mix-blend-mode: screen; height: 800px; overflow: auto; background: purple">
   </div>
  </div>
 </div>
 <script class="testbody" type="text/javascript">
-function test() {
+async function test() {
   var container = document.getElementById("container");
   var outer = document.getElementById("outer");
   var inner = document.getElementById("inner");
   var outerScrollTop = outer.scrollTop;
   var containerScrollTop = container.scrollTop;
   var event = {
     deltaMode: WheelEvent.DOM_DELTA_LINE,
     deltaX: 0,
     deltaY: 10,
     lineOrPageDeltaX: 0,
     lineOrPageDeltaY: 10,
   };
-  sendWheelAndPaint(inner, 20, 30, event, function() {
-    ok(container.scrollTop == containerScrollTop, "container scrollframe should not have scrolled");
-    ok(outer.scrollTop > outerScrollTop, "nested scrollframe should have scrolled");
-    SimpleTest.finish();
+  await new Promise(resolve => {
+    sendWheelAndPaint(inner, 20, 30, event, resolve);
   });
+  ok(container.scrollTop == containerScrollTop, "container scrollframe should not have scrolled");
+  ok(outer.scrollTop > outerScrollTop, "nested scrollframe should have scrolled");
 }
 
 SimpleTest.waitForExplicitFinish();
 
 pushPrefs([["general.smoothScroll", false],
            ["mousewheel.transaction.timeout", 1000000]])
 .then(waitUntilApzStable)
-.then(test);
+.then(test)
+.then(SimpleTest.finish, SimpleTest.finishWithFailure);
 
 </script>
 </body>
 </html>
--- a/gfx/layers/apz/test/mochitest/test_scroll_subframe_scrollbar.html
+++ b/gfx/layers/apz/test/mochitest/test_scroll_subframe_scrollbar.html
@@ -63,55 +63,53 @@ 40	<br>
 var DefaultEvent = {
   deltaMode: WheelEvent.DOM_DELTA_LINE,
   deltaX: 0, deltaY: 1,
   lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
 };
 
 var ScrollbarWidth = 0;
 
-function test() {
+async function test() {
   var subframe = document.getElementById("subframe");
   var oldClientWidth = subframe.clientWidth;
 
   subframe.style.overflow = "auto";
   subframe.getBoundingClientRect();
 
-  waitForAllPaintsFlushed(function() {
-    ScrollbarWidth = oldClientWidth - subframe.clientWidth;
-    if (!ScrollbarWidth) {
-      // Probably we have overlay scrollbars - abort the test.
-      ok(true, "overlay scrollbars - skipping test");
-      SimpleTest.finish();
-      return;
-    }
+  await promiseAllPaintsDone(null, /*flush=*/true);
 
-    ok(subframe.scrollHeight > subframe.clientHeight, "subframe should have scrollable content");
-    testScrolling(subframe);
-  });
-}
+  ScrollbarWidth = oldClientWidth - subframe.clientWidth;
+  if (!ScrollbarWidth) {
+    // Probably we have overlay scrollbars - abort the test.
+    ok(true, "overlay scrollbars - skipping test");
+    return;
+  }
 
-function testScrolling(subframe) {
+  ok(subframe.scrollHeight > subframe.clientHeight, "subframe should have scrollable content");
+
   // Send a wheel event roughly to where we think the trackbar is. We pick a
   // point at the bottom, in the middle of the trackbar, where the slider is
   // unlikely to be (since it starts at the top).
   var posX = subframe.clientWidth + (ScrollbarWidth / 2);
   var posY = subframe.clientHeight - 20;
 
   var oldScrollTop = subframe.scrollTop;
 
-  sendWheelAndPaint(subframe, posX, posY, DefaultEvent, function() {
-    ok(subframe.scrollTop > oldScrollTop, "subframe should have scrolled");
-    SimpleTest.finish();
+  await new Promise(resolve => {
+    sendWheelAndPaint(subframe, posX, posY, DefaultEvent, resolve);
   });
+
+  ok(subframe.scrollTop > oldScrollTop, "subframe should have scrolled");
 }
 
 SimpleTest.waitForExplicitFinish();
 
 pushPrefs([["general.smoothScroll", false],
            ["mousewheel.transaction.timeout", 0],
            ["mousewheel.transaction.ignoremovedelay", 0]])
 .then(waitUntilApzStable)
-.then(test);
+.then(test)
+.then(SimpleTest.finish, SimpleTest.finishWithFailure);
 
 </script>
 </body>
 </html>