Bug 1860375 - Add check for if tabs are not undefined to getTabsForWindow method. r=webdriver-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D191632
This commit is contained in:
Alexandra Borovova 2023-10-24 15:36:27 +00:00
parent a26eafe5c3
commit 31fd0bf54b

View file

@ -309,11 +309,17 @@ export var TabManager = {
* Window whose <code>tabs</code> need to be returned. * Window whose <code>tabs</code> need to be returned.
* *
* @returns {Array<Tab>} * @returns {Array<Tab>}
* The list of tabs. Will return an empty list if tab browser is not available. * The list of tabs. Will return an empty list if tab browser is not available
* or tabs are undefined.
*/ */
getTabsForWindow(win) { getTabsForWindow(win) {
const tabBrowser = this.getTabBrowser(win); const tabBrowser = this.getTabBrowser(win);
return tabBrowser ? tabBrowser.tabs : []; // For web-platform reftests a faked tabbrowser is used,
// which does not actually have tabs.
if (tabBrowser && tabBrowser.tabs) {
return tabBrowser.tabs;
}
return [];
}, },
getWindowForTab(tab) { getWindowForTab(tab) {