diff --git a/browser/base/content/test/referrer/browser_referrer_open_link_in_private.js b/browser/base/content/test/referrer/browser_referrer_open_link_in_private.js index 8f12e38248a9..b09118529436 100644 --- a/browser/base/content/test/referrer/browser_referrer_open_link_in_private.js +++ b/browser/base/content/test/referrer/browser_referrer_open_link_in_private.js @@ -6,7 +6,7 @@ function startNewPrivateWindowTestCase(aTestNumber) { getReferrerTestDescription(aTestNumber)); contextMenuOpened(gTestWindow, "testlink").then(function(aContextMenu) { newWindowOpened().then(function(aNewWindow) { - BrowserTestUtils.firstBrowserLoaded(aNewWindow, false).then(function() { + someTabLoaded(aNewWindow).then(function() { checkReferrerAndStartNextTest(aTestNumber, aNewWindow, null, startNewPrivateWindowTestCase); }); diff --git a/browser/base/content/test/referrer/browser_referrer_open_link_in_window.js b/browser/base/content/test/referrer/browser_referrer_open_link_in_window.js index 81e7b2648e94..7fb9a23e2d3e 100644 --- a/browser/base/content/test/referrer/browser_referrer_open_link_in_window.js +++ b/browser/base/content/test/referrer/browser_referrer_open_link_in_window.js @@ -6,7 +6,7 @@ function startNewWindowTestCase(aTestNumber) { getReferrerTestDescription(aTestNumber)); contextMenuOpened(gTestWindow, "testlink").then(function(aContextMenu) { newWindowOpened().then(function(aNewWindow) { - BrowserTestUtils.firstBrowserLoaded(aNewWindow, false).then(function() { + someTabLoaded(aNewWindow).then(function() { checkReferrerAndStartNextTest(aTestNumber, aNewWindow, null, startNewWindowTestCase); }); diff --git a/browser/base/content/test/referrer/browser_referrer_open_link_in_window_in_container.js b/browser/base/content/test/referrer/browser_referrer_open_link_in_window_in_container.js index d5ce8795256b..3c45c4dd57c6 100644 --- a/browser/base/content/test/referrer/browser_referrer_open_link_in_window_in_container.js +++ b/browser/base/content/test/referrer/browser_referrer_open_link_in_window_in_container.js @@ -9,7 +9,7 @@ function startNewWindowTestCase(aTestNumber) { getReferrerTestDescription(aTestNumber)); contextMenuOpened(gTestWindow, "testlink").then(function(aContextMenu) { newWindowOpened().then(function(aNewWindow) { - BrowserTestUtils.firstBrowserLoaded(aNewWindow, false).then(function() { + someTabLoaded(aNewWindow).then(function() { checkReferrerAndStartNextTest(aTestNumber, aNewWindow, null, startNewWindowTestCase, { userContextId: 1 }); diff --git a/browser/base/content/test/referrer/head.js b/browser/base/content/test/referrer/head.js index f83bd9fd9fb8..5175cddf035f 100644 --- a/browser/base/content/test/referrer/head.js +++ b/browser/base/content/test/referrer/head.js @@ -140,8 +140,18 @@ function delayedStartupFinished(aWindow) { * @resolves With the tab once it's loaded. */ function someTabLoaded(aWindow) { - return BrowserTestUtils.waitForNewTab(gTestWindow.gBrowser).then((tab) => { - return BrowserTestUtils.browserStopped(tab.linkedBrowser).then(() => tab); + return new Promise(function(resolve) { + aWindow.gBrowser.addEventListener("load", function onLoad(aEvent) { + if (aWindow.location.href === "about:blank") { + return; + } + let tab = aWindow.gBrowser._getTabForContentWindow( + aEvent.target.defaultView.top); + if (tab) { + aWindow.gBrowser.removeEventListener("load", onLoad, true); + resolve(tab); + } + }, true); }); } @@ -199,7 +209,7 @@ function referrerTestCaseLoaded(aTestNumber, aParams) { let browser = gTestWindow.gBrowser; return BrowserTestUtils.openNewForegroundTab(browser, () => { browser.selectedTab = browser.addTab(url, aParams); - }, false, true); + }); } /** diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index b471ca3c6d08..48eae9c9c104 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -226,12 +226,11 @@ this.BrowserTestUtils = { * @return {Promise} * @resolves Once the selected browser fires its load event. */ - firstBrowserLoaded(win, aboutBlank = true) { + firstBrowserLoaded(win) { let mm = win.messageManager; return this.waitForMessage(mm, "browser-test-utils:loadEvent", (msg) => { let selectedBrowser = win.gBrowser.selectedBrowser; - return msg.target == selectedBrowser && - (aboutBlank || selectedBrowser.currentURI.spec != "about:blank") + return msg.target == selectedBrowser; }); },