Skip to content

Commit ec149cc

Browse files
committed
Bug 1866884 - Make browser_alternate_fixup_middle_click_link.js wait for error page properly. r=Gijs
Depends on D198571 Differential Revision: https://phabricator.services.mozilla.com/D198574
1 parent 661cb35 commit ec149cc

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

docshell/test/browser/browser_alternate_fixup_middle_click_link.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,20 @@ add_task(async function test_alt_fixup_middle_click() {
1616
link.textContent = "Me, me, click me!";
1717
content.document.body.append(link);
1818
});
19-
let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
19+
let newTabPromise = BrowserTestUtils.waitForNewTab(
20+
gBrowser,
21+
/* wantLoad = */ null,
22+
/* waitForLoad = */ true,
23+
/* waitForAnyTab = */ false,
24+
/* maybeErrorPage = */ true
25+
);
2026
await BrowserTestUtils.synthesizeMouseAtCenter(
2127
"a[href]",
2228
{ button: 1 },
2329
browser
2430
);
2531
let tab = await newTabPromise;
2632
let { browsingContext } = tab.linkedBrowser;
27-
// Account for the possibility of a race, where the error page has already loaded:
28-
if (
29-
!browsingContext.currentWindowGlobal?.documentURI.spec.startsWith(
30-
"about:neterror"
31-
)
32-
) {
33-
await BrowserTestUtils.browserLoaded(
34-
tab.linkedBrowser,
35-
false,
36-
null,
37-
true
38-
);
39-
}
4033
// TBH, if the test fails, we probably force-crash because we try to reach
4134
// *www.* example.com, which isn't proxied by the test infrastructure so
4235
// will forcibly abort the test. But we need some asserts so they might as

testing/mochitest/BrowserTestUtils/BrowserTestUtils.sys.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ export var BrowserTestUtils = {
738738
* @param {boolean} [waitForAnyTab = false]
739739
* True to wait for the url to be loaded in any new tab, not just the next
740740
* one opened.
741+
* @param {boolean} [maybeErrorPage = false]
742+
* See ``browserLoaded`` function.
741743
*
742744
* @return {Promise}
743745
* @resolves With the {xul:tab} when a tab is opened and its location changes
@@ -750,7 +752,8 @@ export var BrowserTestUtils = {
750752
tabbrowser,
751753
wantLoad = null,
752754
waitForLoad = false,
753-
waitForAnyTab = false
755+
waitForAnyTab = false,
756+
maybeErrorPage = false
754757
) {
755758
let urlMatches;
756759
if (wantLoad && typeof wantLoad == "function") {
@@ -779,7 +782,8 @@ export var BrowserTestUtils = {
779782
result = BrowserTestUtils.browserLoaded(
780783
newBrowser,
781784
false,
782-
urlMatches
785+
urlMatches,
786+
maybeErrorPage
783787
).then(() => newTab);
784788
} else {
785789
// If not waiting for load, just resolve with the new tab.

0 commit comments

Comments
 (0)