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
This commit is contained in:
LoveIsGrief 2018-01-05 13:51:47 +01:00
parent 7e04c46070
commit af986e8880
No known key found for this signature in database
GPG key ID: E96D1EDFA05345EB

View file

@ -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 {