Skip to content

Commit 5a5ba86

Browse files
committed
Bug 1852963 - BrowserTestUtils.browserLoaded() should also accept gBrowser as input. r=dao
BrowserTestUtils.browserLoaded() wants a tabbrowser-tab as input, most of it will also work passing gBrowser, and indeed some tests ended up doing that. Unfortunately some parts of it are skipped in that case. Since it's confusing anyway, let's make it more lenient on its input. Differential Revision: https://phabricator.services.mozilla.com/D188212
1 parent 68e8e4f commit 5a5ba86

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

testing/mochitest/BrowserTestUtils/BrowserTestUtils.sys.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,11 @@ export var BrowserTestUtils = {
440440
);
441441
}
442442

443+
// Consumers may pass gBrowser instead of a browser, so adjust for that.
444+
if ("selectedBrowser" in browser) {
445+
browser = browser.selectedBrowser;
446+
}
447+
443448
// If browser belongs to tabbrowser-tab, ensure it has been
444449
// inserted into the document.
445450
let tabbrowser = browser.ownerGlobal.gBrowser;

0 commit comments

Comments
 (0)