Merge pull request #1066 from LoveIsGrief/1065_-_Feature_Request]_Pass_openerTabId_when_creating_tabs_in_order_to_know_the_parent

Pass opener tab id when creating tabs in order to know the parent
This commit is contained in:
Jonathan Kingston 2018-02-09 18:06:56 +00:00 committed by GitHub
commit d1e9c2d1e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

3
.gitignore vendored
View file

@ -9,3 +9,6 @@ README.html
addon.env
src/web-ext-artifacts/*
# JetBrains IDE files
.idea

View file

@ -143,7 +143,11 @@ 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;
// we decided to cancel the request at this point, register it as canceled request as early as possible
if (!this.canceledRequests[options.requestId]) {
this.canceledRequests[options.requestId] = true;
@ -158,8 +162,16 @@ const assignManager = {
cancel: true
};
}
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,
openTabId
);
this.calculateContextMenu(tab);
/* Removal of existing tabs:
@ -173,9 +185,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 {
@ -366,13 +376,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;
@ -383,6 +393,7 @@ const assignManager = {
browser.tabs.create({
url: confirmUrl,
cookieStoreId: currentCookieStoreId,
openerTabId,
index,
active
}).then(() => {