Bug 1517895 - Wait for mozvisualscroll explicitly in the session store tests. r=JanH
authorBotond Ballo <botond@mozilla.com>
Wed, 13 Mar 2019 16:00:07 +0000
changeset 521795 f41b081164d2
parent 521794 02e879149e47
child 521796 a0bf4a689da4
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJanH
bugs1517895
milestone67.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 1517895 - Wait for mozvisualscroll explicitly in the session store tests. r=JanH SSTabScrollCaptured can sometimes be fired for other reasons, causing us to query the visual scroll position before it has been updated. Not explicitly waiting for SSTabScrollCaptured is also safe in this case because we're only querying the session store's view of the scroll position *after* closing the tab, which will flush any pending scroll position updates in the session store. Differential Revision: https://phabricator.services.mozilla.com/D19875
mobile/android/tests/browser/chrome/test_session_scroll_position.html
--- a/mobile/android/tests/browser/chrome/test_session_scroll_position.html
+++ b/mobile/android/tests/browser/chrome/test_session_scroll_position.html
@@ -55,16 +55,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   function cleanupTabs() {
     if (tabScroll) {
       BrowserApp.closeTab(tabScroll);
       tabScroll = null;
     }
   }
 
+  function promiseVisualScrollEvent(browser) {
+    return promiseBrowserEvent(browser, "mozvisualscroll",
+                               { mozSystemGroup: true });
+  }
+
   SimpleTest.registerCleanupFunction(function() {
     cleanupTabs();
   });
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
   add_task(async function test_sessionStoreScrollPositionReaderMode() {
     let testData = {x: 0, y: SCROLL_Y};
@@ -73,17 +78,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       return Task.spawn(function* () {
         // Create a new tab.
         tabScroll = BrowserApp.addTab(URL_reader);
         let browser = tabScroll.browser;
         yield promiseBrowserEvent(browser, "AboutReaderContentReady");
 
         // Modify scroll position.
         setScrollPosition(browser, testData);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(browser);
 
         // Check that we've actually scrolled.
         checkScroll(browser, testData);
 
         // Remove the tab.
         BrowserApp.closeTab(tabScroll);
         yield promiseTabEvent(browser, "SSTabCloseProcessed");
       });
@@ -114,27 +119,27 @@ https://bugzilla.mozilla.org/show_bug.cg
       return Task.spawn(function* () {
         // Create a new tab.
         tabScroll = BrowserApp.addTab(URL);
         let browser = tabScroll.browser;
         yield promiseBrowserEvent(browser, "pageshow");
 
         // Modify scroll position and zoom level.
         setScrollPosition(browser, testData1);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(browser);
 
         // Check that we've actually scrolled and zoomed.
         checkScroll(browser, testData1);
 
         // Navigate to a different page and scroll/zoom there as well.
         browser.loadURI(URL2);
         yield promiseBrowserEvent(browser, "pageshow");
 
         setScrollPosition(browser, testData2);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(browser);
 
         checkScroll(browser, testData2);
 
         // Remove the tab.
         BrowserApp.closeTab(tabScroll);
         yield promiseTabEvent(browser, "SSTabCloseProcessed");
       });
     }
@@ -144,30 +149,28 @@ https://bugzilla.mozilla.org/show_bug.cg
     let [{scrolldata}] = state;
     is(scrolldata.scroll, getScrollString(testData2), "stored scroll position is correct");
     ok(fuzzyEquals(scrolldata.zoom.resolution, ZOOM2), "stored zoom level is correct");
 
     // Restore the closed tab.
     let closedTabData = ss.getClosedTabs(chromeWin)[0];
     let browser = ss.undoCloseTab(chromeWin, closedTabData);
     let pageshow = promiseBrowserEvent(browser, "pageshow");
-    let scroll = promiseBrowserEvent(browser, "mozvisualscroll",
-                                     { mozSystemGroup: true });
+    let scroll = promiseVisualScrollEvent(browser);
     await pageshow;
     await scroll;
 
     // Check the scroll position and zoom level.
     checkScroll(browser, testData2);
 
     // Now go back in history and check that the scroll position
     // is restored there as well.
     is(browser.canGoBack, true, "can go back");
     pageshow = promiseBrowserEvent(browser, "pageshow");
-    scroll = promiseBrowserEvent(browser, "mozvisualscroll",
-                                 { mozSystemGroup: true });
+    scroll = promiseVisualScrollEvent(browser);
     browser.goBack();
     await pageshow;
     await scroll;
 
     checkScroll(browser, testData1);
 
     // Remove the tab.
     BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
@@ -180,17 +183,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       return Task.spawn(function* () {
         // Create a new tab.
         tabScroll = BrowserApp.addTab(URL);
         let browser = tabScroll.browser;
         yield promiseBrowserEvent(browser, "pageshow");
 
         // Modify scroll position and zoom level.
         setScrollPosition(browser, testData);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(browser);
 
         // Check that we've actually scrolled and zoomed.
         checkScroll(browser, testData);
 
         // Remove the tab.
         BrowserApp.closeTab(tabScroll);
         yield promiseTabEvent(browser, "SSTabCloseProcessed");
       });
@@ -230,27 +233,27 @@ https://bugzilla.mozilla.org/show_bug.cg
       return Task.spawn(function* () {
         // Create a new tab.
         tabScroll = BrowserApp.addTab(URL_FRAMESET);
         let browser = tabScroll.browser;
         yield promiseBrowserEvent(browser, "pageshow");
 
         // Move the frameset itself.
         setScrollPosition(browser, testDataParent);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(browser);
         checkScroll(browser, testDataParent);
 
         // Modify scroll position and zoom level for one frame...
         setScrollPosition(browser, testData1);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(getFrame(browser, testData1));
         checkScroll(browser, testData1);
 
         // ... and the other.
         setScrollPosition(browser, testData2);
-        yield promiseTabEvent(browser, "SSTabScrollCaptured");
+        yield promiseVisualScrollEvent(getFrame(browser, testData2));
         checkScroll(browser, testData2);
 
         // Remove the tab.
         BrowserApp.closeTab(tabScroll);
         yield promiseTabEvent(browser, "SSTabCloseProcessed");
       });
     }
 
@@ -263,25 +266,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // Restore the closed tab.
     let closedTabData = ss.getClosedTabs(chromeWin)[0];
     let browser = ss.undoCloseTab(chromeWin, closedTabData);
     let pageshow = promiseBrowserEvent(browser, "pageshow");
     // We can't add event listeners for the frames until we're sure that they've actually loaded.
     let load = promiseBrowserEvent(browser, "load");
     await load;
-    let scrollParent = promiseBrowserEvent(getFrame(browser, testDataParent),
-                                           "mozvisualscroll",
-                                           { mozSystemGroup: true });
-    let scroll1 = promiseBrowserEvent(getFrame(browser, testData1),
-                                      "mozvisualscroll",
-                                      { mozSystemGroup: true });
-    let scroll2 = promiseBrowserEvent(getFrame(browser, testData2),
-                                      "mozvisualscroll",
-                                      { mozSystemGroup: true });
+    let scrollParent = promiseVisualScrollEvent(getFrame(browser, testDataParent));
+    let scroll1 = promiseVisualScrollEvent(getFrame(browser, testData1));
+    let scroll2 = promiseVisualScrollEvent(getFrame(browser, testData2));
     await pageshow;
     await scrollParent;
     await scroll1;
     await scroll2;
 
     // Check the scroll position and zoom level.
     checkScroll(browser, testDataParent);
     checkScroll(browser, testData1);