From 1003d191b8d65c6b3e33dd9e950a52d848038a10 Mon Sep 17 00:00:00 2001 From: stoically Date: Thu, 23 Jun 2022 01:45:06 +0200 Subject: [PATCH] Remove identityState when deleting containers Fixes #1140 --- src/js/background/assignManager.js | 1 + test/issues/1140.test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/issues/1140.test.js diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 907e3c3..058329a 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -102,6 +102,7 @@ window.assignManager = { async deleteContainer(userContextId) { const sitesByContainer = await this.getAssignedSites(userContextId); this.area.remove(Object.keys(sitesByContainer)); + identityState.storageArea.remove(backgroundLogic.cookieStoreId(userContextId)); }, async getAssignedSites(userContextId = null) { diff --git a/test/issues/1140.test.js b/test/issues/1140.test.js new file mode 100644 index 0000000..53fa724 --- /dev/null +++ b/test/issues/1140.test.js @@ -0,0 +1,27 @@ +const { sinon, nextTick, buildBackgroundDom } = require("../common"); + +describe("#1140", () => { + beforeEach(async () => { + this.background = await buildBackgroundDom(); + }); + + describe("removing containers", () => { + beforeEach(async () => { + this.background.browser.contextualIdentities.onRemoved.addListener = sinon.stub(); + const [promise] = this.background.browser.runtime.onMessage.addListener.yield({ + method: "deleteContainer", + message: { + userContextId: "1" + } + }); + await promise; + await nextTick(); + }); + + it("should remove the identitystate from storage as well", async () => { + this.background.browser.storage.local.remove.should.have.been.calledWith([ + "identitiesState@@_firefox-container-1" + ]); + }); + }); +}); \ No newline at end of file