Bug 1587784 - avoid the test listener in browser_alltabslistener.js being notified for the base/dummy page loading when fission is enabled, r=dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 11 Oct 2019 15:12:21 +0000
changeset 497284 a90b5a94599371b19551906fd41384367b2eb16a
parent 497283 d4837cfe8ba0a5f25658d2aeb9bfc5cb99d06f33
child 497285 c51f3b5c78ad30cbebc0a94419f342a6b5350191
push id36681
push usercbrindusan@mozilla.com
push dateFri, 11 Oct 2019 21:50:12 +0000
treeherdermozilla-central@c5e6477c3a24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1587784
milestone71.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 1587784 - avoid the test listener in browser_alltabslistener.js being notified for the base/dummy page loading when fission is enabled, r=dao Differential Revision: https://phabricator.services.mozilla.com/D48852
browser/base/content/test/general/browser_alltabslistener.js
--- a/browser/base/content/test/general/browser_alltabslistener.js
+++ b/browser/base/content/test/general/browser_alltabslistener.js
@@ -183,17 +183,17 @@ var gBackgroundTab,
   gTestBrowser;
 var gTestPage =
   "/browser/browser/base/content/test/general/alltabslistener.html";
 const kBasePage =
   "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
 var gNextTest;
 var gUsingDocumentChannel;
 
-function test() {
+async function test() {
   waitForExplicitFinish();
 
   gBackgroundTab = BrowserTestUtils.addTab(gBrowser);
   gForegroundTab = BrowserTestUtils.addTab(gBrowser);
   gBackgroundBrowser = gBrowser.getBrowserForTab(gBackgroundTab);
   gForegroundBrowser = gBrowser.getBrowserForTab(gForegroundTab);
   gBrowser.selectedTab = gForegroundTab;
 
@@ -216,17 +216,23 @@ function test() {
   // We must wait until a page has completed loading before
   // starting tests or we get notifications from that
   let promises = [
     BrowserTestUtils.browserStopped(gBackgroundBrowser, kBasePage),
     BrowserTestUtils.browserStopped(gForegroundBrowser, kBasePage),
   ];
   BrowserTestUtils.loadURI(gBackgroundBrowser, kBasePage);
   BrowserTestUtils.loadURI(gForegroundBrowser, kBasePage);
-  Promise.all(promises).then(startTest1);
+  await Promise.all(promises);
+  // If we process switched, the tabbrowser may still be processing the state_stop
+  // notification here because of how microtasks work. Ensure that that has
+  // happened before starting to test (which would add listeners to the tabbrowser
+  // which would get confused by being called about kBasePage loading).
+  await new Promise(executeSoon);
+  startTest1();
 }
 
 function runTest(browser, url, next) {
   gFrontNotificationsPos = 0;
   gAllNotificationsPos = 0;
   gNextTest = next;
   gTestBrowser = browser;
   BrowserTestUtils.loadURI(browser, url);