From d7a2b43b07b0e039fecbebdd396e9f738ba82c69 Mon Sep 17 00:00:00 2001 From: Eric Lathrop Date: Fri, 22 Dec 2017 11:45:52 -0500 Subject: [PATCH 1/8] Fix #1053. Create the new window with the default tab rather than an existing tab, then pin the default tab. This allows any pinned tabs to be moved to the new window because they're not allowed to be moved after a un-pinned tab. The default tab is automatically closed later in `moveTabsToWindow` because it's not a part of the container. --- src/js/background/backgroundLogic.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 36bcb47..04906d8 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -131,9 +131,13 @@ const backgroundLogic = { let newWindowObj; let hiddenDefaultTabToClose; if (list.length) { - newWindowObj = await browser.windows.create({ - tabId: list.shift().id - }); + newWindowObj = await browser.windows.create(); + + // Pin the default tab in the new window so existing pinned tabs can be moved after it. + // From the docs (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/move): + // Note that you can't move pinned tabs to a position after any unpinned tabs in a window, or move any unpinned tabs to a position before any pinned tabs. + await browser.tabs.update(newWindowObj.tabs[0].id, { pinned: true }); + browser.tabs.move(list.map((tab) => tab.id), { windowId: newWindowObj.id, index: -1 From 1e16e203dc4b4633ee7dc57bb1b8705d8b48e3f2 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 8 Jan 2018 20:37:35 +0000 Subject: [PATCH 2/8] Fixes code markdown wrapping under Development in the README section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b5e37f..def3d7d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For more info, see: ## Development 1. `npm install` -2. `./node_modules/.bin/web-ext run -s src/ +2. `./node_modules/.bin/web-ext run -s src/` ### Testing TBD From 0ddee7f9d084f6e79cf2a15d330eaee04580f246 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Tue, 5 Dec 2017 13:26:51 -0600 Subject: [PATCH 3/8] id:@testpilot-containers to manifest.json; 5.0.1 --- package.json | 2 +- src/manifest.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5a7ff73..ca8eb7d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "testpilot-containers", "title": "Multi-Account Containers", "description": "Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.", - "version": "5.0.0", + "version": "5.0.1", "author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston", "bugs": { "url": "https://github.com/mozilla/testpilot-containers/issues" diff --git a/src/manifest.json b/src/manifest.json index 199f593..d5350e2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Firefox Multi-Account Containers", - "version": "5.0.0", + "version": "5.0.1", "description": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.", "icons": { @@ -11,6 +11,7 @@ "applications": { "gecko": { + "id": "@testpilot-containers", "strict_min_version": "57.0" } }, From 30e5a27eb4d3dcd5e82f6b5da21cf8b5dba0fa40 Mon Sep 17 00:00:00 2001 From: Charles Renwick Date: Fri, 26 Jan 2018 13:44:46 -0500 Subject: [PATCH 4/8] Fixes #1084. Before opening a container with the `1-9` shortcut, it ensures that the current pannel is the "containersList" --- src/js/popup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/popup.js b/src/js/popup.js index a644322..a9e3d26 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -524,7 +524,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, { previous(); break; default: - if (e.keyCode >= 49 && e.keyCode <= 57) { + if ((e.keyCode >= 49 && e.keyCode <= 57) && + Logic._currentPanel === "containersList") { const element = selectables[e.keyCode - 48]; if (element) { element.click(); From a16cae0342ddf8b9319da01c7526133c23b921e9 Mon Sep 17 00:00:00 2001 From: Timendum Date: Tue, 30 Jan 2018 10:51:38 +0100 Subject: [PATCH 5/8] Fix for siteSettings is null siteSettings can be null, with this change we can avoid an exception. --- src/js/background/assignManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index f95023f..0051e09 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -132,7 +132,7 @@ const assignManager = { // The container we have in the assignment map isn't present any more so lets remove it // then continue the existing load - if (!container) { + if (siteSettings && !container) { this.deleteContainer(siteSettings.userContextId); return {}; } From 7dceaf6679296a1116876ee4e01b376e07c21d36 Mon Sep 17 00:00:00 2001 From: stoically Date: Fri, 9 Feb 2018 10:47:05 +0100 Subject: [PATCH 6/8] Cancel requests with the same requestId Prevents potential redirects from opening two tabs Closes #1114 --- src/js/background/assignManager.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 0051e09..86b9c3e 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -144,6 +144,21 @@ const assignManager = { return {}; } + // we decided to cancel the request at this point, register it as canceled request as early as possible + if (!this.canceledRequests[options.requestId]) { + this.canceledRequests[options.requestId] = true; + // register a cleanup for handled requestIds + // all relevant requests that come in that timeframe with the same requestId will be canceled + setTimeout(() => { + delete this.canceledRequests[options.requestId]; + }, 2000); + } else { + // if we see a request for the same requestId at this point then this is a redirect that we have to cancel to prevent opening two tabs + return { + cancel: true + }; + } + this.reloadPageInContainer(options.url, userContextId, siteSettings.userContextId, tab.index + 1, tab.active, siteSettings.neverAsk); this.calculateContextMenu(tab); @@ -174,6 +189,7 @@ const assignManager = { }); // Before a request is handled by the browser we decide if we should route through a different container + this.canceledRequests = {}; browser.webRequest.onBeforeRequest.addListener((options) => { return this.onBeforeRequest(options); },{urls: [""], types: ["main_frame"]}, ["blocking"]); From ce84665e3a986a7703a5897f566387c41ad0e3a3 Mon Sep 17 00:00:00 2001 From: stoically <29637501+stoically@users.noreply.github.com> Date: Tue, 30 Jan 2018 22:34:00 +0100 Subject: [PATCH 7/8] Add management permission to manifest.json Part of #1095 --- src/manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/manifest.json b/src/manifest.json index d5350e2..3963e24 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -26,6 +26,7 @@ "contextualIdentities", "history", "idle", + "management", "storage", "tabs", "webRequestBlocking", From 609f62ac7afe015a91e5bc2da15b42846fe604ec Mon Sep 17 00:00:00 2001 From: stoically <29637501+stoically@users.noreply.github.com> Date: Tue, 30 Jan 2018 22:34:11 +0100 Subject: [PATCH 8/8] Allow webextensions with contextualIdentities permission to get assignment Closes #1095 --- src/js/background/messageHandler.js | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/js/background/messageHandler.js b/src/js/background/messageHandler.js index 1971953..6e5fced 100644 --- a/src/js/background/messageHandler.js +++ b/src/js/background/messageHandler.js @@ -72,6 +72,42 @@ const messageHandler = { return response; }); + // Handles external messages from webextensions + const externalExtensionAllowed = {}; + browser.runtime.onMessageExternal.addListener(async (message, sender) => { + if (!externalExtensionAllowed[sender.id]) { + const extensionInfo = await browser.management.get(sender.id); + if (!extensionInfo.permissions.includes("contextualIdentities")) { + throw new Error("Missing contextualIdentities permission"); + } + externalExtensionAllowed[sender.id] = true; + } + let response; + switch (message.method) { + case "getAssignment": + if (typeof message.url === "undefined") { + throw new Error("Missing message.url"); + } + response = assignManager.storageArea.get(message.url); + break; + default: + throw new Error("Unknown message.method"); + } + return response; + }); + // Delete externalExtensionAllowed if add-on installs/updates; permissions might change + browser.management.onInstalled.addListener(extensionInfo => { + if (externalExtensionAllowed[extensionInfo.id]) { + delete externalExtensionAllowed[extensionInfo.id]; + } + }); + // Delete externalExtensionAllowed if add-on uninstalls; not needed anymore + browser.management.onUninstalled.addListener(extensionInfo => { + if (externalExtensionAllowed[extensionInfo.id]) { + delete externalExtensionAllowed[extensionInfo.id]; + } + }); + if (browser.contextualIdentities.onRemoved) { browser.contextualIdentities.onRemoved.addListener(({contextualIdentity}) => { const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(contextualIdentity.cookieStoreId);