From 50b58f649f512011386888e738ee91dbb066c765 Mon Sep 17 00:00:00 2001 From: baku Date: Thu, 2 Mar 2017 15:53:24 +0100 Subject: [PATCH] Cleanup cookieJar when addon is uninstall - issue #300 --- .eslintrc.js | 3 ++- index.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3876d96..2650c58 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { "globals": { "CustomizableUI": true, "CustomizableWidgets": true, - "SessionStore": true + "SessionStore": true, + "Services": true }, "plugins": [ "promise" diff --git a/index.js b/index.js index 1fa0e91..1615cad 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,7 @@ const IDENTITY_ICONS = [ { name: "briefcase", image: "chrome://browser/skin/usercontext/work.svg" }, { name: "dollar", image: "chrome://browser/skin/usercontext/banking.svg" }, { name: "cart", image: "chrome://browser/skin/usercontext/shopping.svg" }, + // All of these do not exist in gecko { name: "gift", image: "gift" }, { name: "vacation", image: "vacation" }, { name: "food", image: "food" }, @@ -37,7 +38,7 @@ const IDENTITY_ICONS = [ { name: "pet", image: "pet" }, { name: "tree", image: "tree" }, { name: "chill", image: "chill" }, - { name: "circle", image: "circle" }, // this doesn't exist in m-b + { name: "circle", image: "circle" }, ]; const PREFS = [ @@ -68,6 +69,7 @@ const windowUtils = require("sdk/window/utils"); Cu.import("resource:///modules/CustomizableUI.jsm"); Cu.import("resource:///modules/CustomizableWidgets.jsm"); Cu.import("resource:///modules/sessionstore/SessionStore.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); // ---------------------------------------------------------------------------- // ContextualIdentityProxy @@ -1076,6 +1078,10 @@ const ContainerService = { ContextualIdentityProxy.getIdentities().forEach(identity => { if (!preInstalledIdentities.includes(identity.userContextId)) { ContextualIdentityProxy.remove(identity.userContextId); + } else { + // Let's cleanup all the cookies for this container. + Services.obs.notifyObservers(null, "clear-origin-attributes-data", + JSON.stringify({ userContextId: identity.userContextId })); } });