Merge pull request #870 from jonathanKingston/delete-non-existent-container

Fix assignment of stale containers. Fixes #803
This commit is contained in:
luke crouch 2017-09-29 11:06:03 -05:00 committed by GitHub
commit 0ff8e17005

View file

@ -113,21 +113,29 @@ const assignManager = {
return true; return true;
}, },
init() {
browser.contextMenus.onClicked.addListener((info, tab) => {
this._onClickedHandler(info, tab);
});
// Before a request is handled by the browser we decide if we should route through a different container // Before a request is handled by the browser we decide if we should route through a different container
browser.webRequest.onBeforeRequest.addListener((options) => { async onBeforeRequest(options) {
if (options.frameId !== 0 || options.tabId === -1) { if (options.frameId !== 0 || options.tabId === -1) {
return {}; return {};
} }
this.removeContextMenu(); this.removeContextMenu();
return Promise.all([ const [tab, siteSettings] = await Promise.all([
browser.tabs.get(options.tabId), browser.tabs.get(options.tabId),
this.storageArea.get(options.url) this.storageArea.get(options.url)
]).then(([tab, siteSettings]) => { ]);
let container;
try {
container = await browser.contextualIdentities.get(backgroundLogic.cookieStoreId(siteSettings.userContextId));
} catch (e) {
container = false;
}
// The container we have in the assignment map isn't present any more so lets remove it
// then continue the existing load
if (!container) {
this.deleteContainer(siteSettings.userContextId);
return {};
}
const userContextId = this.getUserContextIdFromCookieStore(tab); const userContextId = this.getUserContextIdFromCookieStore(tab);
if (!siteSettings if (!siteSettings
|| userContextId === siteSettings.userContextId || userContextId === siteSettings.userContextId
@ -158,9 +166,16 @@ const assignManager = {
return { return {
cancel: true, cancel: true,
}; };
}).catch((e) => { },
throw e;
init() {
browser.contextMenus.onClicked.addListener((info, tab) => {
this._onClickedHandler(info, tab);
}); });
// Before a request is handled by the browser we decide if we should route through a different container
browser.webRequest.onBeforeRequest.addListener((options) => {
return this.onBeforeRequest(options);
},{urls: ["<all_urls>"], types: ["main_frame"]}, ["blocking"]); },{urls: ["<all_urls>"], types: ["main_frame"]}, ["blocking"]);
}, },