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:
commit
d1e9c2d1e3
2 changed files with 22 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -9,3 +9,6 @@ README.html
|
||||||
addon.env
|
addon.env
|
||||||
|
|
||||||
src/web-ext-artifacts/*
|
src/web-ext-artifacts/*
|
||||||
|
|
||||||
|
# JetBrains IDE files
|
||||||
|
.idea
|
||||||
|
|
|
@ -143,7 +143,11 @@ const assignManager = {
|
||||||
|| this.storageArea.isExempted(options.url, tab.id)) {
|
|| this.storageArea.isExempted(options.url, tab.id)) {
|
||||||
return {};
|
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
|
// we decided to cancel the request at this point, register it as canceled request as early as possible
|
||||||
if (!this.canceledRequests[options.requestId]) {
|
if (!this.canceledRequests[options.requestId]) {
|
||||||
this.canceledRequests[options.requestId] = true;
|
this.canceledRequests[options.requestId] = true;
|
||||||
|
@ -158,8 +162,16 @@ const assignManager = {
|
||||||
cancel: true
|
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);
|
this.calculateContextMenu(tab);
|
||||||
|
|
||||||
/* Removal of existing tabs:
|
/* 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.
|
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.
|
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)
|
if (removeTab) {
|
||||||
|| (messageHandler.lastCreatedTab
|
|
||||||
&& messageHandler.lastCreatedTab.id === tab.id)) {
|
|
||||||
browser.tabs.remove(tab.id);
|
browser.tabs.remove(tab.id);
|
||||||
}
|
}
|
||||||
return {
|
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 cookieStoreId = backgroundLogic.cookieStoreId(userContextId);
|
||||||
const loadPage = browser.extension.getURL("confirm-page.html");
|
const loadPage = browser.extension.getURL("confirm-page.html");
|
||||||
// False represents assignment is not permitted
|
// 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 the user has explicitly checked "Never Ask Again" on the warning page we will send them straight there
|
||||||
if (neverAsk) {
|
if (neverAsk) {
|
||||||
browser.tabs.create({url, cookieStoreId, index, active});
|
browser.tabs.create({url, cookieStoreId, index, active, openerTabId});
|
||||||
} else {
|
} else {
|
||||||
let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`;
|
let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`;
|
||||||
let currentCookieStoreId;
|
let currentCookieStoreId;
|
||||||
|
@ -383,6 +393,7 @@ const assignManager = {
|
||||||
browser.tabs.create({
|
browser.tabs.create({
|
||||||
url: confirmUrl,
|
url: confirmUrl,
|
||||||
cookieStoreId: currentCookieStoreId,
|
cookieStoreId: currentCookieStoreId,
|
||||||
|
openerTabId,
|
||||||
index,
|
index,
|
||||||
active
|
active
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue