diff --git a/webextensions/background/successor-tab.js b/webextensions/background/successor-tab.js index 73cd190d8..27af6a6b9 100644 --- a/webextensions/background/successor-tab.js +++ b/webextensions/background/successor-tab.js @@ -90,13 +90,20 @@ function update(tabId) { }, 100); } async function updateInternal(tabId) { + // tabs.onActivated can be notified before the tab is completely tracked... + await Tab.waitUntilTracked(tabId); + const tab = Tab.get(tabId); + if (!tab) + return; + const promisedUpdate = mPromisedUpdatedSuccessorTabId.get(tabId); - if (promisedUpdate) - await promisedUpdate.promisedSuccessorTabId; + await Promise.all([ + tab.$TST.opened, + promisedUpdate && promisedUpdate.promisedSuccessorTabId, + ]); + const renewedTab = await browser.tabs.get(tabId).catch(ApiTabs.createErrorHandler(ApiTabs.handleMissingTabError)); - const tab = Tab.get(tabId); if (!renewedTab || - !tab || !TabsStore.ensureLivingTab(tab)) return; log('updateInternal: ', dumpTab(tab), { @@ -230,6 +237,7 @@ Tab.onCreating.addListener((tab, info = {}) => { configs.simulateSelectOwnerOnClose ); + log(`shouldControlSuccesor: `, shouldControlSuccesor); if (shouldControlSuccesor) { // don't use await here, to prevent that other onCreating handlers are treated async. tryClearOwnerSuccessor(info.activeTab).then(() => {