From af986e888043d24e5776fe019d66bb76dc60307c Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Fri, 5 Jan 2018 13:51:47 +0100 Subject: [PATCH] Set the openerTabId to a tab that won't be removed/closed The tab might be removed before we can create the tab making the parent invalid. #1065 - [Feature Request] Pass openerTabId when creating tabs in order to know the parent --- src/js/background/assignManager.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 8386edf..7040b4f 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -143,7 +143,10 @@ const assignManager = { || this.storageArea.isExempted(options.url, tab.id)) { return {}; } - + const removeTab = backgroundLogic.NEW_TAB_PAGES.has(tab.url) + || (messageHandler.lastCreatedTab + && messageHandler.lastCreatedTab.id === tab.id); + const openTabId = removeTab ? tab.openerTabId : tab.id; this.reloadPageInContainer( options.url, userContextId, @@ -151,7 +154,7 @@ const assignManager = { tab.index + 1, tab.active, siteSettings.neverAsk, - tab.id + openTabId ); this.calculateContextMenu(tab); @@ -166,9 +169,7 @@ const assignManager = { however they don't run on about:blank so this would likely be just as hacky. We capture the time the tab was created and close if it was within the timeout to try to capture pages which haven't had user interaction or history. */ - if (backgroundLogic.NEW_TAB_PAGES.has(tab.url) - || (messageHandler.lastCreatedTab - && messageHandler.lastCreatedTab.id === tab.id)) { + if (removeTab) { browser.tabs.remove(tab.id); } return {