From 166420dd863a97b102d8e2c5ee2d5f0dd5cdd769 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Fri, 5 Jan 2018 13:01:43 +0100 Subject: [PATCH 1/3] Ignore JetBrains IDE files #1065 - [Feature Request] Pass openerTabId when creating tabs in order to know the parent --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 752eb58..c745683 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ README.html addon.env src/web-ext-artifacts/* + +# JetBrains IDE files +.idea From 7e04c460700b78115e530bc13a5ddd9182ed3859 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Fri, 5 Jan 2018 13:05:32 +0100 Subject: [PATCH 2/3] Pass the openerTabId when automatically opening tabs in containers the `openerTabId` can also be seen as the tab's parent. This is useful for extensions like https://github.com/piroor/treestyletab #1065 - [Feature Request] Pass openerTabId when creating tabs in order to know the parent --- src/js/background/assignManager.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index f95023f..8386edf 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -144,7 +144,15 @@ const assignManager = { return {}; } - this.reloadPageInContainer(options.url, userContextId, siteSettings.userContextId, tab.index + 1, tab.active, siteSettings.neverAsk); + this.reloadPageInContainer( + options.url, + userContextId, + siteSettings.userContextId, + tab.index + 1, + tab.active, + siteSettings.neverAsk, + tab.id + ); this.calculateContextMenu(tab); /* Removal of existing tabs: @@ -350,13 +358,13 @@ const assignManager = { }); }, - reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false) { + reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false, openerTabId = null) { const cookieStoreId = backgroundLogic.cookieStoreId(userContextId); const loadPage = browser.extension.getURL("confirm-page.html"); // False represents assignment is not permitted // If the user has explicitly checked "Never Ask Again" on the warning page we will send them straight there if (neverAsk) { - browser.tabs.create({url, cookieStoreId, index, active}); + browser.tabs.create({url, cookieStoreId, index, active, openerTabId}); } else { let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; let currentCookieStoreId; @@ -367,6 +375,7 @@ const assignManager = { browser.tabs.create({ url: confirmUrl, cookieStoreId: currentCookieStoreId, + openerTabId, index, active }).then(() => { From af986e888043d24e5776fe019d66bb76dc60307c Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Fri, 5 Jan 2018 13:51:47 +0100 Subject: [PATCH 3/3] 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 {