Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7833a6a79f | |||
| cc42beeb5a | |||
| ea5669911b | |||
| b4c2da5474 | |||
| 6d7086d541 | |||
| db0dba66b2 | |||
| 5b58168999 | |||
| 4ed453d58e | |||
| 66a9116524 | |||
| cb7ac6ca5e | |||
| a2995b6c66 | |||
| ed383c8dfc | |||
| df9b900db6 | |||
| 8e611de605 | |||
| 8af4c36fd0 | |||
| abc4e0cdcf | |||
| b6dd32f683 | |||
| 0a437ff303 | |||
| f7f4c320a6 | |||
| 5813621fb9 | |||
| 56fc7407da | |||
| 220b902144 | |||
| c15eee22c6 | |||
| dcc3b76cda | |||
| 752d18ffca | |||
| 97559dd08a | |||
| 0e7363a87f | |||
| 6c62c2f599 | |||
| 884e419a7c | |||
| d7586dd4c2 | |||
| aada0419eb | |||
| 1ea04587d9 | |||
| 3d1dcd33d1 | |||
| bfdbd8199f | |||
| fe0810b048 | |||
| e1c1ac4bd9 | |||
| 7f7f221a79 | |||
| e57c556427 | |||
| dd57158ab5 | |||
| 99db192792 | |||
| fcbee854d0 | |||
| fae1336467 | |||
| 655d8f3791 | |||
| dcc852bf17 | |||
| dab3005c6f |
@@ -0,0 +1,28 @@
|
|||||||
|
<!--
|
||||||
|
Feel free to ignore this Issue template if you just want to ask or suggest something. If you experience an Issue then please provide all asked informations.
|
||||||
|
|
||||||
|
Note: If "Firefox will: Never remember history" in the Firefox Preferences/Options under "Privacy & Security > History" is selected, then Multi-Account Containers will not work, since Containers aren't available in Private Windows.
|
||||||
|
-->
|
||||||
|
- Is "Firefox will: Never remember history" in the Firefox Preferences/Options under "Privacy & Security > History" selected? Yes/No:
|
||||||
|
- Are you using Firefox in a Private Window? Yes/No:
|
||||||
|
- Can you see a grayed out but ticked Checkbox with the description "Enable Container Tabs" in the Firefox Preferences/Options under "Tabs"? Yes/No:
|
||||||
|
- Multi-Account Containers Version:
|
||||||
|
- Operating System + Version:
|
||||||
|
- Firefox Version:
|
||||||
|
- Other installed Add-ons + Version + Enabled/Disabled-Status:
|
||||||
|
<!-- To be able to Copy&Paste the full list of your Add-ons navigate to "about:support" and scroll down to "Extensions" -->
|
||||||
|
|
||||||
|
|
||||||
|
### Actual behavior
|
||||||
|
..
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
..
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
1. ..
|
||||||
|
2. ..
|
||||||
|
3. ..
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
..
|
||||||
+2
-2
@@ -9,9 +9,9 @@ Everyone is welcome to contribute to containers. Reach out to team members if yo
|
|||||||
|
|
||||||
If you find a bug with containers, please file a issue.
|
If you find a bug with containers, please file a issue.
|
||||||
|
|
||||||
Check first if the bug might already exist: https://github.com/mozilla/testpilot-containers/issues
|
Check first if the bug might already exist: https://github.com/mozilla/multi-account-containers/issues
|
||||||
|
|
||||||
[Open an issue](https://github.com/mozilla/testpilot-containers/issues/new)
|
[Open an issue](https://github.com/mozilla/multi-account-containers/issues/new)
|
||||||
|
|
||||||
1. Visit about:support
|
1. Visit about:support
|
||||||
2. Click "Copy raw data to clipboard" and paste into the bug. Alternatively copy the following sections into the issue:
|
2. Click "Copy raw data to clipboard" and paste into the bug. Alternatively copy the following sections into the issue:
|
||||||
|
|||||||
+8
-9
@@ -2,41 +2,40 @@
|
|||||||
"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": "6.0.0",
|
"version": "6.1.0",
|
||||||
"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/multi-account-containers/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"addons-linter": "^0.15.14",
|
"ajv": "^6.6.2",
|
||||||
|
"addons-linter": "^1.3.2",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"deploy-txp": "^1.0.7",
|
|
||||||
"eslint": "^3.17.1",
|
"eslint": "^3.17.1",
|
||||||
"eslint-plugin-no-unsanitized": "^2.0.0",
|
"eslint-plugin-no-unsanitized": "^2.0.0",
|
||||||
"eslint-plugin-promise": "^3.4.0",
|
"eslint-plugin-promise": "^3.4.0",
|
||||||
"htmllint-cli": "^0.0.5",
|
"htmllint-cli": "0.0.7",
|
||||||
"jsdom": "^11.6.2",
|
"jsdom": "^11.6.2",
|
||||||
"json": "^9.0.6",
|
"json": "^9.0.6",
|
||||||
"mocha": "^5.0.0",
|
"mocha": "^5.0.0",
|
||||||
"npm-run-all": "^4.0.0",
|
"npm-run-all": "^4.0.0",
|
||||||
"sinon": "^4.2.2",
|
"sinon": "^4.4.0",
|
||||||
"sinon-chai": "^2.14.0",
|
"sinon-chai": "^2.14.0",
|
||||||
"stylelint": "^7.9.0",
|
"stylelint": "^7.9.0",
|
||||||
"stylelint-config-standard": "^16.0.0",
|
"stylelint-config-standard": "^16.0.0",
|
||||||
"stylelint-order": "^0.3.0",
|
"stylelint-order": "^0.3.0",
|
||||||
"web-ext": "^2.2.2"
|
"web-ext": "^2.2.2"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/mozilla/testpilot-containers#readme",
|
"homepage": "https://github.com/mozilla/multi-account-containers#readme",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/mozilla/testpilot-containers.git"
|
"url": "git+https://github.com/mozilla/multi-account-containers.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm test && cd src && web-ext build --overwrite-dest",
|
"build": "npm test && cd src && web-ext build --overwrite-dest",
|
||||||
"deploy": "deploy-txp",
|
|
||||||
"lint": "npm-run-all lint:*",
|
"lint": "npm-run-all lint:*",
|
||||||
"lint:addon": "addons-linter src --self-hosted",
|
"lint:addon": "addons-linter src --self-hosted",
|
||||||
"lint:css": "stylelint src/css/*.css",
|
"lint:css": "stylelint src/css/*.css",
|
||||||
|
|||||||
+29
-7
@@ -45,6 +45,8 @@ body {
|
|||||||
--small-text-size: 0.833rem; /* 10px */
|
--small-text-size: 0.833rem; /* 10px */
|
||||||
--small-radius: 3px;
|
--small-radius: 3px;
|
||||||
--icon-button-size: calc(calc(var(--block-line-separation-size) * 2) + 1.66rem); /* 20px */
|
--icon-button-size: calc(calc(var(--block-line-separation-size) * 2) + 1.66rem); /* 20px */
|
||||||
|
--column-panel-inline-size: 268px;
|
||||||
|
--inactive-opacity: 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-resolution: 1dppx) {
|
@media (min-resolution: 1dppx) {
|
||||||
@@ -266,7 +268,7 @@ table {
|
|||||||
.column-panel-content {
|
.column-panel-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
inline-size: 268px;
|
inline-size: var(--column-panel-inline-size);
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-panel-content .panel-footer {
|
.column-panel-content .panel-footer {
|
||||||
@@ -537,7 +539,7 @@ span ~ .panel-header-text {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#current-tab > label > input:checked {
|
#current-tab > label > input:checked {
|
||||||
background-image: url("chrome://global/skin/in-content/check.svg#check-native");
|
background-image: url("/img/check.svg");
|
||||||
background-position: -1px -1px;
|
background-position: -1px -1px;
|
||||||
background-size: var(--icon-size);
|
background-size: var(--icon-size);
|
||||||
}
|
}
|
||||||
@@ -578,6 +580,11 @@ span ~ .panel-header-text {
|
|||||||
max-inline-size: 204px;
|
max-inline-size: 204px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disable-edit-containers {
|
||||||
|
opacity: var(--inactive-opacity);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.userContext-wrapper {
|
.userContext-wrapper {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -653,7 +660,11 @@ span ~ .panel-header-text {
|
|||||||
|
|
||||||
/* Container info list */
|
/* Container info list */
|
||||||
.container-info-tab-title {
|
.container-info-tab-title {
|
||||||
flex: 1;
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-info-tab-row:hover .container-info-tab-title .truncate-text {
|
||||||
|
inline-size: calc(var(--column-panel-inline-size) - 58px);
|
||||||
}
|
}
|
||||||
|
|
||||||
#container-info-hideorshow {
|
#container-info-hideorshow {
|
||||||
@@ -670,6 +681,21 @@ span ~ .panel-header-text {
|
|||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container-close-tab {
|
||||||
|
transform: scale(0.7);
|
||||||
|
visibility: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-info-tab-row:hover .container-close-tab {
|
||||||
|
opacity: 0.5;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-info-tab-row .container-close-tab:hover {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
.container-info-has-tabs,
|
.container-info-has-tabs,
|
||||||
.container-info-tab-row {
|
.container-info-tab-row {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -696,10 +722,6 @@ span ~ .panel-header-text {
|
|||||||
margin-inline-end: 0;
|
margin-inline-end: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container-info-tab-row td {
|
|
||||||
max-inline-size: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container-info-list {
|
.container-info-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 61 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||||
|
<path fill="#3c3c3c" d="M6 14a1 1 0 0 1-.707-.293l-3-3a1 1 0 0 1 1.414-1.414l2.157 2.157 6.316-9.023a1 1 0 0 1 1.639 1.146l-7 10a1 1 0 0 1-.732.427A.863.863 0 0 1 6 14z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 477 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 7 7">
|
||||||
|
<polygon fill="#4c4c4c" points="5.8,0 3.5,2.4 1.2,0 0,1.2 2.4,3.5 0.1,5.8 1.2,7 3.5,4.7 5.8,7 7,5.8 4.7,3.5 7,1.2"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 183 B |
@@ -147,22 +147,44 @@ 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[tab.id]) {
|
||||||
if (!this.canceledRequests[options.requestId]) {
|
// we decided to cancel the request at this point, register canceled request
|
||||||
this.canceledRequests[options.requestId] = true;
|
this.canceledRequests[tab.id] = {
|
||||||
// register a cleanup for handled requestIds
|
requestIds: {
|
||||||
// all relevant requests that come in that timeframe with the same requestId will be canceled
|
[options.requestId]: true
|
||||||
|
},
|
||||||
|
urls: {
|
||||||
|
[options.url]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// since webRequest onCompleted and onErrorOccurred are not 100% reliable (see #1120)
|
||||||
|
// we register a timer here to cleanup canceled requests, just to make sure we don't
|
||||||
|
// end up in a situation where certain urls in a tab.id stay canceled
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
delete this.canceledRequests[options.requestId];
|
if (this.canceledRequests[tab.id]) {
|
||||||
|
delete this.canceledRequests[tab.id];
|
||||||
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
} 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
|
let cancelEarly = false;
|
||||||
return {
|
if (this.canceledRequests[tab.id].requestIds[options.requestId] ||
|
||||||
cancel: true
|
this.canceledRequests[tab.id].urls[options.url]) {
|
||||||
};
|
// same requestId or url from the same tab
|
||||||
|
// this is a redirect that we have to cancel early to prevent opening two tabs
|
||||||
|
cancelEarly = true;
|
||||||
|
}
|
||||||
|
// we decided to cancel the request at this point, register canceled request
|
||||||
|
this.canceledRequests[tab.id].requestIds[options.requestId] = true;
|
||||||
|
this.canceledRequests[tab.id].urls[options.url] = true;
|
||||||
|
if (cancelEarly) {
|
||||||
|
return {
|
||||||
|
cancel: true
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reloadPageInContainer(
|
this.reloadPageInContainer(
|
||||||
options.url,
|
options.url,
|
||||||
userContextId,
|
userContextId,
|
||||||
@@ -203,6 +225,19 @@ const assignManager = {
|
|||||||
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"]);
|
||||||
|
|
||||||
|
// Clean up canceled requests
|
||||||
|
browser.webRequest.onCompleted.addListener((options) => {
|
||||||
|
if (this.canceledRequests[options.tabId]) {
|
||||||
|
delete this.canceledRequests[options.tabId];
|
||||||
|
}
|
||||||
|
},{urls: ["<all_urls>"], types: ["main_frame"]});
|
||||||
|
browser.webRequest.onErrorOccurred.addListener((options) => {
|
||||||
|
if (this.canceledRequests[options.tabId]) {
|
||||||
|
delete this.canceledRequests[options.tabId];
|
||||||
|
}
|
||||||
|
},{urls: ["<all_urls>"], types: ["main_frame"]});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _onClickedHandler(info, tab) {
|
async _onClickedHandler(info, tab) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const backgroundLogic = {
|
|||||||
"about:home",
|
"about:home",
|
||||||
"about:blank"
|
"about:blank"
|
||||||
]),
|
]),
|
||||||
|
unhideQueue: [],
|
||||||
|
|
||||||
async getExtensionInfo() {
|
async getExtensionInfo() {
|
||||||
const manifestPath = browser.extension.getURL("manifest.json");
|
const manifestPath = browser.extension.getURL("manifest.json");
|
||||||
@@ -112,6 +113,17 @@ const backgroundLogic = {
|
|||||||
return list.concat(containerState.hiddenTabs);
|
return list.concat(containerState.hiddenTabs);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async unhideContainer(cookieStoreId) {
|
||||||
|
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||||
|
this.unhideQueue.push(cookieStoreId);
|
||||||
|
await this.showTabs({
|
||||||
|
cookieStoreId
|
||||||
|
});
|
||||||
|
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
async moveTabsToWindow(options) {
|
async moveTabsToWindow(options) {
|
||||||
const requiredArguments = ["cookieStoreId", "windowId"];
|
const requiredArguments = ["cookieStoreId", "windowId"];
|
||||||
this.checkArgs(requiredArguments, options, "moveTabsToWindow");
|
this.checkArgs(requiredArguments, options, "moveTabsToWindow");
|
||||||
@@ -123,6 +135,7 @@ const backgroundLogic = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const containerState = await identityState.storageArea.get(cookieStoreId);
|
const containerState = await identityState.storageArea.get(cookieStoreId);
|
||||||
|
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
if (list.length === 0 &&
|
if (list.length === 0 &&
|
||||||
containerState.hiddenTabs.length === 0) {
|
containerState.hiddenTabs.length === 0) {
|
||||||
@@ -152,12 +165,15 @@ const backgroundLogic = {
|
|||||||
const showHiddenPromises = [];
|
const showHiddenPromises = [];
|
||||||
|
|
||||||
// Let's show the hidden tabs.
|
// Let's show the hidden tabs.
|
||||||
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||||
showHiddenPromises.push(browser.tabs.create({
|
this.unhideQueue.push(cookieStoreId);
|
||||||
url: object.url || DEFAULT_TAB,
|
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
||||||
windowId: newWindowObj.id,
|
showHiddenPromises.push(browser.tabs.create({
|
||||||
cookieStoreId
|
url: object.url || DEFAULT_TAB,
|
||||||
}));
|
windowId: newWindowObj.id,
|
||||||
|
cookieStoreId
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hiddenDefaultTabToClose) {
|
if (hiddenDefaultTabToClose) {
|
||||||
@@ -176,7 +192,9 @@ const backgroundLogic = {
|
|||||||
browser.tabs.remove(tab.id);
|
browser.tabs.remove(tab.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await identityState.storageArea.set(cookieStoreId, containerState);
|
const rv = await identityState.storageArea.set(cookieStoreId, containerState);
|
||||||
|
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||||
|
return rv;
|
||||||
},
|
},
|
||||||
|
|
||||||
async _closeTabs(userContextId, windowId = false) {
|
async _closeTabs(userContextId, windowId = false) {
|
||||||
@@ -209,7 +227,9 @@ const backgroundLogic = {
|
|||||||
});
|
});
|
||||||
identitiesOutput[cookieStoreId] = {
|
identitiesOutput[cookieStoreId] = {
|
||||||
hasHiddenTabs: !!containerState.hiddenTabs.length,
|
hasHiddenTabs: !!containerState.hiddenTabs.length,
|
||||||
hasOpenTabs: !!openTabs.length
|
hasOpenTabs: !!openTabs.length,
|
||||||
|
numberOfHiddenTabs: containerState.hiddenTabs.length,
|
||||||
|
numberOfOpenTabs: openTabs.length
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@@ -307,4 +327,3 @@ const backgroundLogic = {
|
|||||||
return `firefox-container-${userContextId}`;
|
return `firefox-container-${userContextId}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ const messageHandler = {
|
|||||||
// We use this to catch redirected tabs that have just opened
|
// We use this to catch redirected tabs that have just opened
|
||||||
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
||||||
LAST_CREATED_TAB_TIMER: 2000,
|
LAST_CREATED_TAB_TIMER: 2000,
|
||||||
unhideQueue: [],
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// Handles messages from webextension code
|
// Handles messages from webextension code
|
||||||
@@ -39,7 +38,7 @@ const messageHandler = {
|
|||||||
backgroundLogic.sortTabs();
|
backgroundLogic.sortTabs();
|
||||||
break;
|
break;
|
||||||
case "showTabs":
|
case "showTabs":
|
||||||
this.unhideContainer(m.cookieStoreId);
|
backgroundLogic.unhideContainer(m.cookieStoreId);
|
||||||
break;
|
break;
|
||||||
case "hideTabs":
|
case "hideTabs":
|
||||||
backgroundLogic.hideTabs({
|
backgroundLogic.hideTabs({
|
||||||
@@ -156,7 +155,7 @@ const messageHandler = {
|
|||||||
this.incrementCountOfContainerTabsOpened();
|
this.incrementCountOfContainerTabsOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unhideContainer(tab.cookieStoreId);
|
backgroundLogic.unhideContainer(tab.cookieStoreId);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.lastCreatedTab = null;
|
this.lastCreatedTab = null;
|
||||||
@@ -182,17 +181,6 @@ const messageHandler = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async unhideContainer(cookieStoreId) {
|
|
||||||
if (!this.unhideQueue.includes(cookieStoreId)) {
|
|
||||||
this.unhideQueue.push(cookieStoreId);
|
|
||||||
// Unhide all hidden tabs
|
|
||||||
await backgroundLogic.showTabs({
|
|
||||||
cookieStoreId
|
|
||||||
});
|
|
||||||
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async onFocusChangedCallback(windowId) {
|
async onFocusChangedCallback(windowId) {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
// browserAction loses background color in new windows ...
|
// browserAction loses background color in new windows ...
|
||||||
|
|||||||
+100
-35
@@ -162,7 +162,7 @@ const Logic = {
|
|||||||
async clearBrowserActionBadge() {
|
async clearBrowserActionBadge() {
|
||||||
const extensionInfo = await getExtensionInfo();
|
const extensionInfo = await getExtensionInfo();
|
||||||
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
||||||
browser.browserAction.setBadgeBackgroundColor({color: ""});
|
browser.browserAction.setBadgeBackgroundColor({color: null});
|
||||||
browser.browserAction.setBadgeText({text: ""});
|
browser.browserAction.setBadgeText({text: ""});
|
||||||
storage.browserActionBadgesClicked.push(extensionInfo.version);
|
storage.browserActionBadgesClicked.push(extensionInfo.version);
|
||||||
// use set and spread to create a unique array
|
// use set and spread to create a unique array
|
||||||
@@ -177,7 +177,9 @@ const Logic = {
|
|||||||
name: "Default",
|
name: "Default",
|
||||||
cookieStoreId,
|
cookieStoreId,
|
||||||
icon: "default-tab",
|
icon: "default-tab",
|
||||||
color: "default-tab"
|
color: "default-tab",
|
||||||
|
numberOfHiddenTabs: 0,
|
||||||
|
numberOfOpenTabs: 0
|
||||||
};
|
};
|
||||||
// Handle old style rejection with null and also Promise.reject new style
|
// Handle old style rejection with null and also Promise.reject new style
|
||||||
try {
|
try {
|
||||||
@@ -212,6 +214,27 @@ const Logic = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async numTabs() {
|
||||||
|
const activeTabs = await browser.tabs.query({windowId: browser.windows.WINDOW_ID_CURRENT});
|
||||||
|
return activeTabs.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
_disableMoveTabs(message) {
|
||||||
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
const incompatEl = document.createElement("div");
|
||||||
|
|
||||||
|
moveTabsEl.classList.remove("clickable");
|
||||||
|
moveTabsEl.setAttribute("title", message);
|
||||||
|
|
||||||
|
fragment.appendChild(incompatEl);
|
||||||
|
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||||
|
incompatEl.textContent = message;
|
||||||
|
incompatEl.classList.add("container-info-tab-row");
|
||||||
|
|
||||||
|
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||||
|
},
|
||||||
|
|
||||||
async refreshIdentities() {
|
async refreshIdentities() {
|
||||||
const [identities, state] = await Promise.all([
|
const [identities, state] = await Promise.all([
|
||||||
browser.contextualIdentities.query({}),
|
browser.contextualIdentities.query({}),
|
||||||
@@ -227,6 +250,8 @@ const Logic = {
|
|||||||
if (stateObject) {
|
if (stateObject) {
|
||||||
identity.hasOpenTabs = stateObject.hasOpenTabs;
|
identity.hasOpenTabs = stateObject.hasOpenTabs;
|
||||||
identity.hasHiddenTabs = stateObject.hasHiddenTabs;
|
identity.hasHiddenTabs = stateObject.hasHiddenTabs;
|
||||||
|
identity.numberOfHiddenTabs = stateObject.numberOfHiddenTabs;
|
||||||
|
identity.numberOfOpenTabs = stateObject.numberOfOpenTabs;
|
||||||
}
|
}
|
||||||
return identity;
|
return identity;
|
||||||
});
|
});
|
||||||
@@ -485,8 +510,10 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
|||||||
Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() });
|
Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() });
|
||||||
});
|
});
|
||||||
|
|
||||||
Logic.addEnterHandler(document.querySelector("#edit-containers-link"), () => {
|
Logic.addEnterHandler(document.querySelector("#edit-containers-link"), (e) => {
|
||||||
Logic.showPanel(P_CONTAINERS_EDIT);
|
if (!e.target.classList.contains("disable-edit-containers")){
|
||||||
|
Logic.showPanel(P_CONTAINERS_EDIT);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Logic.addEnterHandler(document.querySelector("#sort-containers-link"), async function () {
|
Logic.addEnterHandler(document.querySelector("#sort-containers-link"), async function () {
|
||||||
@@ -666,6 +693,13 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
|||||||
document.addEventListener("mousedown", () => {
|
document.addEventListener("mousedown", () => {
|
||||||
document.removeEventListener("focus", focusHandler);
|
document.removeEventListener("focus", focusHandler);
|
||||||
});
|
});
|
||||||
|
/* If no container is present disable the Edit Containers button */
|
||||||
|
const editContainer = document.querySelector("#edit-containers-link");
|
||||||
|
if (Logic.identities().length === 0) {
|
||||||
|
editContainer.classList.add("disable-edit-containers");
|
||||||
|
} else {
|
||||||
|
editContainer.classList.remove("disable-edit-containers");
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
@@ -698,37 +732,31 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if the user has incompatible add-ons installed
|
// Check if the user has incompatible add-ons installed
|
||||||
|
let incompatible = false;
|
||||||
try {
|
try {
|
||||||
const incompatible = await browser.runtime.sendMessage({
|
incompatible = await browser.runtime.sendMessage({
|
||||||
method: "checkIncompatibleAddons"
|
method: "checkIncompatibleAddons"
|
||||||
});
|
});
|
||||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
|
||||||
if (incompatible) {
|
|
||||||
const fragment = document.createDocumentFragment();
|
|
||||||
const incompatEl = document.createElement("div");
|
|
||||||
|
|
||||||
moveTabsEl.classList.remove("clickable");
|
|
||||||
moveTabsEl.setAttribute("title", "Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
|
||||||
|
|
||||||
fragment.appendChild(incompatEl);
|
|
||||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
|
||||||
incompatEl.textContent = "Incompatible with other Experiments.";
|
|
||||||
incompatEl.classList.add("container-info-tab-row");
|
|
||||||
|
|
||||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
|
||||||
} else {
|
|
||||||
Logic.addEnterHandler(moveTabsEl, async function () {
|
|
||||||
await browser.runtime.sendMessage({
|
|
||||||
method: "moveTabsToWindow",
|
|
||||||
windowId: browser.windows.WINDOW_ID_CURRENT,
|
|
||||||
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
|
||||||
});
|
|
||||||
window.close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Could not check for incompatible add-ons.");
|
throw new Error("Could not check for incompatible add-ons.");
|
||||||
}
|
}
|
||||||
|
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||||
|
const numTabs = await Logic.numTabs();
|
||||||
|
if (incompatible) {
|
||||||
|
Logic._disableMoveTabs("Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||||
|
return;
|
||||||
|
} else if (numTabs === 1) {
|
||||||
|
Logic._disableMoveTabs("Cannot move a tab from a single-tab window.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logic.addEnterHandler(moveTabsEl, async function () {
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
method: "moveTabsToWindow",
|
||||||
|
windowId: browser.windows.WINDOW_ID_CURRENT,
|
||||||
|
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
||||||
|
});
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// This method is called when the panel is shown.
|
// This method is called when the panel is shown.
|
||||||
@@ -777,20 +805,44 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
|||||||
tr.classList.add("container-info-tab-row");
|
tr.classList.add("container-info-tab-row");
|
||||||
tr.innerHTML = escaped`
|
tr.innerHTML = escaped`
|
||||||
<td></td>
|
<td></td>
|
||||||
<td class="container-info-tab-title truncate-text" title="${tab.url}" >${tab.title}</td>`;
|
<td class="container-info-tab-title truncate-text" title="${tab.url}" ><div class="container-tab-title">${tab.title}</div></td>`;
|
||||||
tr.querySelector("td").appendChild(Utils.createFavIconElement(tab.favIconUrl));
|
tr.querySelector("td").appendChild(Utils.createFavIconElement(tab.favIconUrl));
|
||||||
|
document.getElementById("container-info-table").appendChild(fragment);
|
||||||
|
|
||||||
// On click, we activate this tab. But only if this tab is active.
|
// On click, we activate this tab. But only if this tab is active.
|
||||||
if (!tab.hiddenState) {
|
if (!tab.hiddenState) {
|
||||||
|
const closeImage = document.createElement("img");
|
||||||
|
closeImage.src = "/img/container-close-tab.svg";
|
||||||
|
closeImage.className = "container-close-tab";
|
||||||
|
closeImage.title = "Close tab";
|
||||||
|
closeImage.id = tab.id;
|
||||||
|
const tabTitle = tr.querySelector(".container-info-tab-title");
|
||||||
|
tabTitle.appendChild(closeImage);
|
||||||
|
|
||||||
|
// On hover, we add truncate-text class to add close-tab-image after tab title truncates
|
||||||
|
const tabTitleHoverEvent = () => {
|
||||||
|
tabTitle.classList.toggle("truncate-text");
|
||||||
|
tr.querySelector(".container-tab-title").classList.toggle("truncate-text");
|
||||||
|
};
|
||||||
|
|
||||||
|
tr.addEventListener("mouseover", tabTitleHoverEvent);
|
||||||
|
tr.addEventListener("mouseout", tabTitleHoverEvent);
|
||||||
|
|
||||||
tr.classList.add("clickable");
|
tr.classList.add("clickable");
|
||||||
Logic.addEnterHandler(tr, async function () {
|
Logic.addEnterHandler(tr, async function () {
|
||||||
await browser.tabs.update(tab.id, {active: true});
|
await browser.tabs.update(tab.id, {active: true});
|
||||||
window.close();
|
window.close();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("container-info-table").appendChild(fragment);
|
const closeTab = document.getElementById(tab.id);
|
||||||
|
if (closeTab) {
|
||||||
|
Logic.addEnterHandler(closeTab, async function(e) {
|
||||||
|
await browser.tabs.remove(Number(e.target.id));
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1001,6 +1053,11 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||||||
|
|
||||||
document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
|
document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
|
||||||
document.querySelector("#edit-container-panel-usercontext-input").value = userContextId || NEW_CONTAINER_ID;
|
document.querySelector("#edit-container-panel-usercontext-input").value = userContextId || NEW_CONTAINER_ID;
|
||||||
|
const containerName = document.querySelector("#edit-container-panel-name-input");
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
containerName.select();
|
||||||
|
containerName.focus();
|
||||||
|
});
|
||||||
[...document.querySelectorAll("[name='container-color']")].forEach(colorInput => {
|
[...document.querySelectorAll("[name='container-color']")].forEach(colorInput => {
|
||||||
colorInput.checked = colorInput.value === identity.color;
|
colorInput.checked = colorInput.value === identity.color;
|
||||||
});
|
});
|
||||||
@@ -1045,9 +1102,17 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
|
|||||||
prepare() {
|
prepare() {
|
||||||
const identity = Logic.currentIdentity();
|
const identity = Logic.currentIdentity();
|
||||||
|
|
||||||
// Populating the panel: name and icon
|
// Populating the panel: name, icon, and warning message
|
||||||
document.getElementById("delete-container-name").textContent = identity.name;
|
document.getElementById("delete-container-name").textContent = identity.name;
|
||||||
|
|
||||||
|
const totalNumberOfTabs = identity.numberOfHiddenTabs + identity.numberOfOpenTabs;
|
||||||
|
let warningMessage = "";
|
||||||
|
if (totalNumberOfTabs > 0) {
|
||||||
|
const grammaticalNumTabs = totalNumberOfTabs > 1 ? "tabs" : "tab";
|
||||||
|
warningMessage = `If you remove this container now, ${totalNumberOfTabs} container ${grammaticalNumTabs} will be closed.`;
|
||||||
|
}
|
||||||
|
document.getElementById("delete-container-tab-warning").textContent = warningMessage;
|
||||||
|
|
||||||
const icon = document.getElementById("delete-container-icon");
|
const icon = document.getElementById("delete-container-icon");
|
||||||
icon.setAttribute("data-identity-icon", identity.icon);
|
icon.setAttribute("data-identity-icon", identity.icon);
|
||||||
icon.setAttribute("data-identity-color", identity.color);
|
icon.setAttribute("data-identity-color", identity.color);
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
const DEFAULT_FAVICON = "moz-icon://goat?size=16";
|
const DEFAULT_FAVICON = "/img/blank-favicon.svg";
|
||||||
|
|
||||||
// TODO use export here instead of globals
|
// TODO use export here instead of globals
|
||||||
window.Utils = {
|
window.Utils = {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Firefox Multi-Account Containers",
|
"name": "Firefox Multi-Account Containers",
|
||||||
"version": "6.0.0",
|
"version": "6.1.0",
|
||||||
|
|
||||||
"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": {
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"homepage_url": "https://testpilot.firefox.com/",
|
"homepage_url": "https://github.com/mozilla/multi-account-containers#readme",
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"<all_urls>",
|
"<all_urls>",
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-content delete-container-confirm">
|
<div class="panel-content delete-container-confirm">
|
||||||
<h4 class="delete-container-confirm-title">Remove This Container</h4>
|
<h4 class="delete-container-confirm-title">Remove This Container</h4>
|
||||||
<p>If you remove this container now, <span id="delete-container-tab-count"></span> container tabs will be closed. Are you sure you want to remove this Container?</p>
|
<p><span id="delete-container-tab-warning"></span> Are you sure you want to remove this Container?</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a href="#" class="button expanded secondary footer-button cancel-button" id="delete-container-cancel-link">Cancel</a>
|
<a href="#" class="button expanded secondary footer-button cancel-button" id="delete-container-cancel-link">Cancel</a>
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ module.exports = () => {
|
|||||||
},
|
},
|
||||||
onCompleted: {
|
onCompleted: {
|
||||||
addListener: sinon.stub()
|
addListener: sinon.stub()
|
||||||
|
},
|
||||||
|
onErrorOccurred: {
|
||||||
|
addListener: sinon.stub()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
windows: {
|
windows: {
|
||||||
|
|||||||
+9
-7
@@ -18,19 +18,21 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async openNewTab(tab, options = {isAsync: true}) {
|
async openNewTab(tab, options = {}) {
|
||||||
|
if (options.resetHistory) {
|
||||||
|
background.browser.tabs.create.resetHistory();
|
||||||
|
background.browser.tabs.remove.resetHistory();
|
||||||
|
}
|
||||||
background.browser.tabs.get.resolves(tab);
|
background.browser.tabs.get.resolves(tab);
|
||||||
background.browser.webRequest.onBeforeRequest.addListener.yield({
|
background.browser.tabs.onCreated.addListener.yield(tab);
|
||||||
|
const [promise] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
frameId: 0,
|
frameId: 0,
|
||||||
tabId: tab.id,
|
tabId: tab.id,
|
||||||
url: tab.url,
|
url: tab.url,
|
||||||
requestId: options.requestId
|
requestId: options.requestId
|
||||||
});
|
});
|
||||||
background.browser.tabs.onCreated.addListener.yield(tab);
|
|
||||||
if (!options.isAsync) {
|
return promise;
|
||||||
return;
|
|
||||||
}
|
|
||||||
await nextTick();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+139
-2
@@ -22,8 +22,7 @@ describe("#940", () => {
|
|||||||
active: true
|
active: true
|
||||||
};
|
};
|
||||||
helper.browser.openNewTab(newTab, {
|
helper.browser.openNewTab(newTab, {
|
||||||
requestId: 1,
|
requestId: 1
|
||||||
isAsync: false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// other addon sees the same request
|
// other addon sees the same request
|
||||||
@@ -40,4 +39,142 @@ describe("#940", () => {
|
|||||||
background.browser.tabs.create.should.have.been.calledOnce;
|
background.browser.tabs.create.should.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when redirects change requestId midflight", () => {
|
||||||
|
let promiseResults;
|
||||||
|
beforeEach(async () => {
|
||||||
|
// init
|
||||||
|
const activeTab = {
|
||||||
|
id: 1,
|
||||||
|
cookieStoreId: "firefox-container-1",
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
index: 0
|
||||||
|
};
|
||||||
|
await helper.browser.initializeWithTab(activeTab);
|
||||||
|
// assign the activeTab.url
|
||||||
|
await helper.popup.clickElementById("container-page-assigned");
|
||||||
|
|
||||||
|
// http://youtube.com
|
||||||
|
const newTab = {
|
||||||
|
id: 2,
|
||||||
|
cookieStoreId: "firefox-default",
|
||||||
|
url: "http://youtube.com",
|
||||||
|
index: 1,
|
||||||
|
active: true
|
||||||
|
};
|
||||||
|
const promise1 = helper.browser.openNewTab(newTab, {
|
||||||
|
requestId: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://youtube.com
|
||||||
|
const [promise2] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: newTab.id,
|
||||||
|
url: "https://youtube.com",
|
||||||
|
requestId: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://www.youtube.com
|
||||||
|
const [promise3] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: newTab.id,
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
requestId: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://www.youtube.com
|
||||||
|
const [promise4] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: newTab.id,
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
requestId: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
promiseResults = await Promise.all([promise1, promise2, promise3, promise4]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not open two confirm pages", async () => {
|
||||||
|
// http://youtube.com is not assigned, no cancel, no reopening
|
||||||
|
expect(promiseResults[0]).to.deep.equal({});
|
||||||
|
|
||||||
|
// https://youtube.com is not assigned, no cancel, no reopening
|
||||||
|
expect(promiseResults[1]).to.deep.equal({});
|
||||||
|
|
||||||
|
// https://www.youtube.com is assigned, this triggers reopening, cancel
|
||||||
|
expect(promiseResults[2]).to.deep.equal({
|
||||||
|
cancel: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://www.youtube.com is assigned, this was a redirect, cancel early, no reopening
|
||||||
|
expect(promiseResults[3]).to.deep.equal({
|
||||||
|
cancel: true
|
||||||
|
});
|
||||||
|
|
||||||
|
background.browser.tabs.create.should.have.been.calledOnce;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should uncancel after webRequest.onCompleted", async () => {
|
||||||
|
const [promise1] = background.browser.webRequest.onCompleted.addListener.yield({
|
||||||
|
tabId: 2
|
||||||
|
});
|
||||||
|
await promise1;
|
||||||
|
|
||||||
|
const [promise2] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: 2,
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
requestId: 123
|
||||||
|
});
|
||||||
|
await promise2;
|
||||||
|
|
||||||
|
background.browser.tabs.create.should.have.been.calledTwice;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should uncancel after webRequest.onErrorOccurred", async () => {
|
||||||
|
const [promise1] = background.browser.webRequest.onErrorOccurred.addListener.yield({
|
||||||
|
tabId: 2
|
||||||
|
});
|
||||||
|
await promise1;
|
||||||
|
|
||||||
|
// request to assigned url in same tab
|
||||||
|
const [promise2] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: 2,
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
requestId: 123
|
||||||
|
});
|
||||||
|
await promise2;
|
||||||
|
|
||||||
|
background.browser.tabs.create.should.have.been.calledTwice;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should uncancel after 2 seconds", async () => {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||||
|
// request to assigned url in same tab
|
||||||
|
const [promise2] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: 2,
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
requestId: 123
|
||||||
|
});
|
||||||
|
await promise2;
|
||||||
|
|
||||||
|
background.browser.tabs.create.should.have.been.calledTwice;
|
||||||
|
}).timeout(2002);
|
||||||
|
|
||||||
|
it("should not influence the canceled url in other tabs", async () => {
|
||||||
|
const newTab = {
|
||||||
|
id: 123,
|
||||||
|
cookieStoreId: "firefox-default",
|
||||||
|
url: "https://www.youtube.com",
|
||||||
|
index: 10,
|
||||||
|
active: true
|
||||||
|
};
|
||||||
|
await helper.browser.openNewTab(newTab, {
|
||||||
|
requestId: 321
|
||||||
|
});
|
||||||
|
|
||||||
|
background.browser.tabs.create.should.have.been.calledTwice;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -91,11 +91,11 @@ global.buildPopupDom = async (options = {}) => {
|
|||||||
global.afterEach(() => {
|
global.afterEach(() => {
|
||||||
if (global.background) {
|
if (global.background) {
|
||||||
global.background.dom.window.close();
|
global.background.dom.window.close();
|
||||||
delete global.background.dom;
|
delete global.background;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.popup) {
|
if (global.popup) {
|
||||||
global.popup.dom.window.close();
|
global.popup.dom.window.close();
|
||||||
delete global.popup.dom;
|
delete global.popup;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user