Merge branch 'testing-6.0.0' into 1065_-_Feature_Request]_Pass_openerTabId_when_creating_tabs_in_order_to_know_the_parent

This commit is contained in:
Jonathan Kingston 2018-02-09 18:04:58 +00:00 committed by GitHub
commit 3bd33cda99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 16 deletions

View file

@ -19,7 +19,7 @@ For more info, see:
## Development ## Development
1. `npm install` 1. `npm install`
2. `./node_modules/.bin/web-ext run -s src/ 2. `./node_modules/.bin/web-ext run -s src/`
### Testing ### Testing
TBD TBD

View file

@ -2,7 +2,7 @@
"name": "testpilot-containers", "name": "testpilot-containers",
"title": "Multi-Account 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.", "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", "author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston",
"bugs": { "bugs": {
"url": "https://github.com/mozilla/testpilot-containers/issues" "url": "https://github.com/mozilla/testpilot-containers/issues"

View file

@ -132,7 +132,7 @@ const assignManager = {
// The container we have in the assignment map isn't present any more so lets remove it // The container we have in the assignment map isn't present any more so lets remove it
// then continue the existing load // then continue the existing load
if (!container) { if (siteSettings && !container) {
this.deleteContainer(siteSettings.userContextId); this.deleteContainer(siteSettings.userContextId);
return {}; return {};
} }
@ -147,15 +147,31 @@ const assignManager = {
|| (messageHandler.lastCreatedTab || (messageHandler.lastCreatedTab
&& messageHandler.lastCreatedTab.id === tab.id); && messageHandler.lastCreatedTab.id === tab.id);
const openTabId = removeTab ? tab.openerTabId : tab.id; const openTabId = removeTab ? tab.openerTabId : tab.id;
// 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( this.reloadPageInContainer(
options.url, options.url,
userContextId, userContextId,
siteSettings.userContextId, siteSettings.userContextId,
tab.index + 1, tab.index + 1,
tab.active, tab.active,
siteSettings.neverAsk, siteSettings.neverAsk,
openTabId openTabId
); );
this.calculateContextMenu(tab); this.calculateContextMenu(tab);
/* Removal of existing tabs: /* Removal of existing tabs:
@ -183,6 +199,7 @@ const assignManager = {
}); });
// Before a request is handled by the browser we decide if we should route through a different container // 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) => { browser.webRequest.onBeforeRequest.addListener((options) => {
return this.onBeforeRequest(options); return this.onBeforeRequest(options);
},{urls: ["<all_urls>"], types: ["main_frame"]}, ["blocking"]); },{urls: ["<all_urls>"], types: ["main_frame"]}, ["blocking"]);

View file

@ -131,9 +131,13 @@ const backgroundLogic = {
let newWindowObj; let newWindowObj;
let hiddenDefaultTabToClose; let hiddenDefaultTabToClose;
if (list.length) { if (list.length) {
newWindowObj = await browser.windows.create({ newWindowObj = await browser.windows.create();
tabId: list.shift().id
}); // 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), { browser.tabs.move(list.map((tab) => tab.id), {
windowId: newWindowObj.id, windowId: newWindowObj.id,
index: -1 index: -1

View file

@ -72,6 +72,42 @@ const messageHandler = {
return response; 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) { if (browser.contextualIdentities.onRemoved) {
browser.contextualIdentities.onRemoved.addListener(({contextualIdentity}) => { browser.contextualIdentities.onRemoved.addListener(({contextualIdentity}) => {
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(contextualIdentity.cookieStoreId); const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(contextualIdentity.cookieStoreId);

View file

@ -524,7 +524,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
previous(); previous();
break; break;
default: default:
if (e.keyCode >= 49 && e.keyCode <= 57) { if ((e.keyCode >= 49 && e.keyCode <= 57) &&
Logic._currentPanel === "containersList") {
const element = selectables[e.keyCode - 48]; const element = selectables[e.keyCode - 48];
if (element) { if (element) {
element.click(); element.click();

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Firefox Multi-Account Containers", "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.", "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": { "icons": {
@ -11,6 +11,7 @@
"applications": { "applications": {
"gecko": { "gecko": {
"id": "@testpilot-containers",
"strict_min_version": "57.0" "strict_min_version": "57.0"
} }
}, },
@ -25,6 +26,7 @@
"contextualIdentities", "contextualIdentities",
"history", "history",
"idle", "idle",
"management",
"storage", "storage",
"tabs", "tabs",
"webRequestBlocking", "webRequestBlocking",