diff --git a/index.js b/index.js index 878236b..fcf91d0 100644 --- a/index.js +++ b/index.js @@ -112,6 +112,7 @@ const ContextualIdentityProxy = { const ContainerService = { _identitiesState: {}, _windowMap: new Map(), + _containerWasEnabled: false, init(installation) { // If we are just been installed, we must store some information for the @@ -159,6 +160,10 @@ const ContainerService = { } } + // Let's see if containers were enabled before this addon. + this._containerWasEnabled = + ss.storage.savedConfiguration.prefs["privacy.userContext.enabled"]; + // Enabling preferences PREFS.forEach((pref) => { @@ -1005,16 +1010,16 @@ const ContainerService = { for (let window of windows.browserWindows) { // eslint-disable-line prefer-const // Let's close all the container tabs. - // Note 1: we don't care if containers are supported but the current FF - // version. - // Note 2: We cannot use _closeTabs() because at this point tab.window is - // null. - for (let tab of window.tabs) { // eslint-disable-line prefer-const - if (this._getUserContextIdFromTab(tab)) { - tab.close(); - try { - SessionStore.forgetClosedTab(viewFor(window), 0); - } catch(e) {} // eslint-disable-line no-empty + // Note: We cannot use _closeTabs() because at this point tab.window is + // null. + if (!this._containerWasEnabled) { + for (let tab of window.tabs) { // eslint-disable-line prefer-const + if (this._getUserContextIdFromTab(tab)) { + tab.close(); + try { + SessionStore.forgetClosedTab(viewFor(window), 0); + } catch(e) {} // eslint-disable-line no-empty + } } }