Bug 1664446. Properly wait to make sure any potential scroll events get fired in several tests. r=kats
authorTimothy Nikkel <tnikkel@gmail.com>
Sun, 13 Sep 2020 20:21:11 +0000
changeset 548466 f51b6c3688a43eeb552349f171c4fa4c8a35d797
parent 548465 85e23b4d97acb9c2d8c113bbe7956ced0af19cf4
child 548467 da187b003f27fee651173cb7a458894aebbe4002
push id37781
push userdluca@mozilla.com
push dateMon, 14 Sep 2020 09:51:01 +0000
treeherdermozilla-central@09390cf1d667 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1664446
milestone82.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 1664446. Properly wait to make sure any potential scroll events get fired in several tests. r=kats Doing rAF rAF flushApzRepaints is not enough to make sure that any potential scroll events are sent to content. The reason is that if the apz repaint request causes us to do scrolling on the main thread then the scrolling will be finished after flushApzRepaints, and the scroll event will be pending, but it's not sent until the next refresh driver tick. So we need to do at least one rAF after flushApzRepaints. Differential Revision: https://phabricator.services.mozilla.com/D90035
editor/libeditor/tests/test_bug549262.html
editor/libeditor/tests/test_bug915962.html
editor/libeditor/tests/test_selection_move_commands.html
layout/base/tests/test_bug1120705.html
layout/base/tests/test_scroll_per_page.html
layout/generic/test/test_bug633762.html
--- a/editor/libeditor/tests/test_bug549262.html
+++ b/editor/libeditor/tests/test_bug549262.html
@@ -33,28 +33,28 @@ function waitForScrollEvent(aWindow) {
 
 function waitAndCheckNoScrollEvent(aWindow) {
   let gotScroll = false;
   function recordScroll() {
     gotScroll = true;
   }
   aWindow.addEventListener("scroll", recordScroll, {capture: true});
   return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
-    () => { flushApzRepaints(
+    () => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
       function() {
         aWindow.removeEventListener("scroll", recordScroll, {capture: true});
         is(gotScroll, false, "check that we didn't get a scroll");
         resolve();
-      }, aWindow
+      }); } ); }, aWindow
     ); }
   ); }); });
 }
 
 function waitToClearOutAnyPotentialScrolls(aWindow) {
-  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
+  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
 }
 
 SimpleTest.waitForFocus(function() {
   SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, startTest);
 }, win);
 async function startTest() {
   // Make sure that pressing Space when a contenteditable element is not focused
   // will scroll the page.
--- a/editor/libeditor/tests/test_bug915962.html
+++ b/editor/libeditor/tests/test_bug915962.html
@@ -34,28 +34,28 @@ function waitForScrollEvent(aWindow) {
 
 function waitAndCheckNoScrollEvent(aWindow) {
   let gotScroll = false;
   function recordScroll() {
     gotScroll = true;
   }
   aWindow.addEventListener("scroll", recordScroll, {capture: true});
   return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
-    () => { flushApzRepaints(
+    () => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
       function() {
         aWindow.removeEventListener("scroll", recordScroll, {capture: true});
         is(gotScroll, false, "check that we didn't get a scroll");
         resolve();
-      }, aWindow
+      }); } ); }, aWindow
     ); }
   ); }); });
 }
 
 function waitToClearOutAnyPotentialScrolls(aWindow) {
-  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
+  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
 }
 
 SimpleTest.waitForFocus(function() {
   SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, startTest);
 }, win);
 async function startTest() {
   // Make sure that pressing Space when a tabindex=-1 element is focused
   // will scroll the page.
--- a/editor/libeditor/tests/test_selection_move_commands.html
+++ b/editor/libeditor/tests/test_selection_move_commands.html
@@ -204,17 +204,17 @@ async function testRunner() {
 
   let curTest = runTests();
   while (true) {
     let promise = new Promise(resolve => { win.addEventListener("scroll", () => { SimpleTest.executeSoon(resolve); }, {once: true, capture: true}); });
     if ((await curTest.next()).done) {
       break;
     }
     await promise;
-    await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(resolve, win); }); }); });
+    await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(() => { win.requestAnimationFrame(() => { win.requestAnimationFrame(resolve); } ); }, win); }); }); });
   }
 }
 
 SimpleTest.waitForFocus(function() {
   setup()
     .then(() => testRunner())
     .then(() => cleanup())
     .catch(err => ok(false, err));
--- a/layout/base/tests/test_bug1120705.html
+++ b/layout/base/tests/test_bug1120705.html
@@ -47,17 +47,17 @@ function clickDownButton() {
 
   synthesizeMouse(sel,
                   sel.offsetWidth - scrollbar_width / 2,
                   sel.offsetHeight - scrollbar_width / 2,
                   { type: "mouseup" });
 }
 
 function waitToClearOutAnyPotentialScrolls(aWindow) {
-  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
+  return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
 }
 
 function waitForScrollEvent(aWindow) {
   return new Promise(resolve => {
     aWindow.addEventListener("scroll", () => { SimpleTest.executeSoon(resolve); }, {once: true, capture: true});
   });
 }
 
--- a/layout/base/tests/test_scroll_per_page.html
+++ b/layout/base/tests/test_scroll_per_page.html
@@ -58,19 +58,20 @@ async function doTests(aWindow) {
 
   function waitForScrollEvent() {
     return new Promise(resolve => {
       aWindow.addEventListener("scroll", () => { SimpleTest.executeSoon(resolve); }, {once: true, capture: true});
     });
   }
 
   function waitToClearOutAnyPotentialScrolls() {
-    return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
+    return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
   }
 
+
   async function doPageDown() {
     let waitForScrolling = waitForScrollEvent();
     if (kUseKeyboardEvent) {
       synthesizeKey("KEY_PageDown", {}, aWindow);
     } else {
       selectionController.pageMove(true, false);
     }
     await waitForScrolling;
--- a/layout/generic/test/test_bug633762.html
+++ b/layout/generic/test/test_bug633762.html
@@ -28,17 +28,18 @@ async function runTests() {
   // set display none on b
   doc.getElementById("b").style.display = "none";
   // flush layout
   doc.documentElement.offsetLeft;
   // focus on the iframe
   win.focus();
 
   // clear out any potential scroll events so we can listen for the one we want without false positives
-  await new Promise(resolve => {window.requestAnimationFrame(() => { window.requestAnimationFrame(() => { flushApzRepaints(resolve, window); }); }); });
+  await new Promise(resolve => {window.requestAnimationFrame(() => { window.requestAnimationFrame(() => { flushApzRepaints(() => { window.requestAnimationFrame(() => { window.requestAnimationFrame(resolve); } ); }, window); }); }); });
+
   step2();
 }
 
 function step2() {
   var i = document.getElementById("i");
   doc = i.contentDocument;
   var win = i.contentWindow;
   // record scrolltop