From ab5d67eacb0fc2492e89f09c64fb07b893c1489d Mon Sep 17 00:00:00 2001 From: garywill Date: Sun, 14 Mar 2021 19:01:37 +0800 Subject: [PATCH 1/2] fix can't open in default container if url assigned to a container associate userContextId=0 with CookieStoreId="firefox-default" --- src/js/background/assignManager.js | 5 ++--- src/js/background/backgroundLogic.js | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 032adb1..d2aa804 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -705,9 +705,8 @@ window.assignManager = { return browser.tabs.create({url, cookieStoreId, index, active, openerTabId}); } else { let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; - let currentCookieStoreId; - if (currentUserContextId) { - currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId); + const currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId); + if (parseInt(currentUserContextId, 10) > 0) { confirmUrl += `¤tCookieStoreId=${currentCookieStoreId}`; } return browser.tabs.create({ diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 7643221..d0ef360 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -32,6 +32,9 @@ const backgroundLogic = { if (!cookieStoreId) { return false; } + if (cookieStoreId === "firefox-default") { + return "0"; + } const container = cookieStoreId.replace("firefox-container-", ""); if (container !== cookieStoreId) { return container; @@ -357,7 +360,7 @@ const backgroundLogic = { }, cookieStoreId(userContextId) { - if(userContextId === 0) return "firefox-default"; + if (parseInt(userContextId, 10) === 0) return "firefox-default"; return `firefox-container-${userContextId}`; } }; From 613002c64aac346eaacaca776aafeb9d0cd7542a Mon Sep 17 00:00:00 2001 From: garywill Date: Sun, 14 Mar 2021 21:12:10 +0800 Subject: [PATCH 2/2] change test 'should open the confirm page' to "cookieStoreId: 'firefox-default'" --- test/features/assignment.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/features/assignment.test.js b/test/features/assignment.test.js index 990f3ff..1df0e26 100644 --- a/test/features/assignment.test.js +++ b/test/features/assignment.test.js @@ -73,7 +73,7 @@ describe("Assignment Comfirm Page Feature", function () { url: "moz-extension://fake/confirm-page.html?" + `url=${encodeURIComponent(url)}` + `&cookieStoreId=${this.webExt.tab.cookieStoreId}`, - cookieStoreId: undefined, + cookieStoreId: "firefox-default", openerTabId: null, index: 2, active: true