Compare commits

..

27 commits

Author SHA1 Message Date
Danny Colin
aca51cc11c
Merge pull request #2755 from apostrophest/eslint-ecmascript-2021
Increase eslint ecmaVersion to 2021
2025-05-20 15:09:33 -04:00
Danny Colin
b684ce7016
Merge pull request #2764 from apostrophest/version-upgrade-8.3.0
Version upgrade 8.3.0
2025-05-06 15:24:43 -04:00
Stephen Thompson
115d411218 Version upgrade 8.3.0
## IMPORTANT NOTE

Version 8.2.0 of this add-on configured Ctrl + Comma as the default keyboard shortcut for sorting the tab strip by container. This keyboard shortcut was removed from 8.3.0 in patch #2758. If you use Ctrl + Comma in order to quickly sort tabs by container, then you will need to explicitly reconfigure the keyboard shortcut. https://support.mozilla.org/en-US/kb/manage-extension-shortcuts-firefox

## Features
- #2753 Avoid sorting tabs in Firefox tab groups
- #2758 Removed suggested keyboard shortcut for tab sorting
- #2722 Removed Mozilla VPN logo banner

## Bugs
- #2572 Fixed add/remove site assignments logic bug
- #2754 Fixed "open/reopen in container" bug that would reopen outside of a Firefox tab group
- #2760 Removed console log spam related to context menu cleanup

## Developer
- #2671 Updated contributor documentation with tips and corrected links
- #2723 Updated GitHub Actions build image
2025-05-06 12:04:57 -04:00
Danny Colin
aec2aa5fb0
Merge pull request #2722 from mozilla/basti/remove_vpn_banner
Remove the Mozilla-VPN Banner Ad
2025-04-30 22:00:04 -04:00
Sebastian Streich
69ee83bbf6 Remove the Mozilla-VPN Banner Ad 2025-04-30 21:57:36 -04:00
Danny Colin
9434147b48
Merge pull request #2758 from apostrophest/remove-sort-tabs-suggested-key
Remove suggested key for `sort_tabs`
2025-04-30 18:13:08 -04:00
Danny Colin
d82341ce4a
Merge pull request #2760 from Rob--W/logspam-contextMenus.remove
Avoid logspam: "Cannot find menu item with id ..."
2025-04-30 18:09:22 -04:00
Rob Wu
60a6666222 Avoid logspam: "Cannot find menu item with id ..."
The extension frequently tries to remove context menus that do not
exists, which results in errors like:

> Error: Cannot find menu item with id firefox-container-1

because starting from Firefox 136, the contextMenus.remove method
rejects if the menu item does not exist. To avoid logspam, catch it.

References:

- https://bugzilla.mozilla.org/show_bug.cgi?id=1688743
- https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/136#changes_for_add-on_developers
2025-04-30 00:51:11 +02:00
Stephen Thompson
f1a24ed6fb Address code review comments for #2758
- Use `commands.reset` insead of `commands.update`
- Do not swallow errors
2025-04-29 16:36:19 -04:00
Danny Colin
0372abdc33
Merge pull request #2754 from apostrophest/issue-2747-reopen-in-container-tab-groups
Fix #2747: open/reopen container tabs in tab groups when appropriate
2025-04-28 11:04:18 -04:00
Danny Colin
366a50c8b6
Merge pull request #2753 from apostrophest/issue-2746-sort-ungrouped-tabs-only
Fix #2746: sort only ungrouped tabs
2025-04-28 11:03:46 -04:00
Stephen Thompson
e96b275e02 Remove suggested key for sort_tabs
A number of users have accidentally pressed Ctrl + Comma and sorted their tabs by container. For some of those users, they did not know what had happened.

#2492 added Ctrl + Comma as a default shortcut key for sorting tabs by container. This change was released with addon v8.2.0 in Sept 2024.

It is useful to make the sort-tabs-by-container operation accessible by keyboard shortcut, but I think Ctrl + Comma is too close to the main Ctrl + Period shortcut for this addon. I think it's reasonable to make the default sort_tabs keyboard shortcut more complex, but in this patch, I'm recommending that we:

1. do not set a shortcut by default for any future users. Users can still configure a shortcut via Firefox's Manage Extension Shortcuts UI.
2. for existing users upgrading from 8.2.0 who configured their own, non-default keyboard shortcut for sort_tabs, keep their shortcut in place. These users demonstrated a strong interest in using the sort_tabs feature and I do not want to interfere.
3. for existing users upgrading from 8.2.0 who have the default keyboard shortcut configured, clear the shortcut. Users who did not use the sort_tabs keyboard shortcut will no longer be at risk of accidentally using it. Users who did use the default sort_tabs keyboard shortcut will be harmed, but those users can use the Manage Extension Shortcuts UI to manually configure Ctrl + Comma (or another key combination).

I am not aware of any simple ways to ensure that existing users using Ctrl + Comma can continue to do so without interruption. Ideally, I think #2492 should not have set a suggested key -- the other keyboard shortcuts are "non-destructive" and easy to understand. However, since that already happened, I think the best harm reduction approach at this point is to inconvenience existing users of Ctrl + Comma.
2025-04-25 13:08:44 -04:00
Stephen Thompson
65243e2c06 eslint ecmaVersion to 2021
CONTRIBUTING.md specifies the minimum supported Firefox version as 91.1.0.

Based on the caniuse.com data for ECMAScript features listed at https://gist.github.com/Julien-Marcou/156b19aea4704e1d2f48adafc6e2acbf, I determined the following minimum Firefox versions that support each ECMAScript version:

- ECMAScript 2018 (current setting) = Firefox 78
- ECMAScript 2019 = Firefox 64
- ECMAScript 2020 = Firefox 80
- ECMAScript 2021 = Firefox 79
- ECMAScript 2022 = Firefox 92
- ECMAScript 2023 = Firefox 104
- ECMAScript 2024 = Firefox 119+ (not exactly sure)

This project is using v7 of eslint which depends on v7 of espree for JavaScript parsing. espree v7 has a maximum ECMAScript support version of ECMAScript 2021.

Based on these findings, increasing the configured `parser.ecmaVersion` from `2018` to `2021` will allow using all JavaScript syntax supported in Firefox 91.1.0+ without raising eslint errors.
2025-04-23 15:09:26 -04:00
Stephen Thompson
ab3e1ce4d8 Address code review from @Rob--W 2025-04-23 14:31:13 -04:00
Stephen Thompson
5194fcad0e Address code review from @Rob--W 2025-04-23 14:23:07 -04:00
Stephen Thompson
b6a1bff9e8 Fix #2747: open/reopen container tabs in tab groups when appropriate
Firefox 137 introduced tab groups. Tab group web extension support is rolling out in Firefox 138 and later. Creating a new tab after the last tab in a tab group can inadvertently create the new tab outside of the tab group.

When a user opens a new tab that should be in a container, this patch will make sure that the new tab resides in the same tab group as the original tab.
2025-04-21 23:45:11 -04:00
Stephen Thompson
5ae2047b2c Fix #2746: sort only ungrouped tabs
Firefox 137 introduced tab groups. Tab group web extension support is rolling out in Firefox 138 and later. Tab movements, like the movements done when sorting tabs by container, can inadvertently add or remove tabs from tab groups.

In order to keep users' tab groups intact, this patch only sorts tabs outside of tab groups. Due to the lack of the tabGroups web extensions API as of Firefox 138, this patch cannot move tab groups, so all ungrouped tabs move to the end of the tab strip. That means after sorting, all tab groups will move to the beginning of the tab strip.
2025-04-21 23:44:13 -04:00
Danny Colin
a60f5bb1be
Merge pull request #2723 from mozilla/basti/update_ci
Update CI actions/upload-artifact to v4
2025-02-25 11:17:38 -05:00
Sebastian Streich
c8c4e0f0c5
Update CI actions/upload-artifact to v4 2025-02-25 13:56:52 +01:00
Andrea Marchesini
037a804725
Merge pull request #2572 from Cimbali/main
Small fixes
2024-09-26 15:13:51 +02:00
Cimbali
6fcb828e1d Fix error in function name 2024-09-26 13:10:25 +01:00
Cimbali
aa9bb41305 Do not resolve promise twice 2024-09-26 13:10:25 +01:00
luke crouch
546ee7a098
Merge pull request #2671 from kelimuttu/community-docs
Community documentation update
2024-09-25 06:12:58 -05:00
kelimuttu
d8cff7ca41 tidy up links 2024-09-25 14:37:53 +07:00
kelimuttu
e6e7d5178e remove discourse and redirect to GH discussions board 2024-09-25 14:32:18 +07:00
kelimuttu
7767bb0c58 update the contributor guidelines 2024-09-25 14:30:48 +07:00
Rafee Rahman
580fb5234b
Merge pull request #2663 from mozilla/version-upgrade
Version upgrade
2024-09-10 11:04:30 -04:00
15 changed files with 207 additions and 123 deletions

View file

@ -1,6 +1,6 @@
module.exports = {
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2021
},
"env": {
"browser": true,

View file

@ -26,7 +26,7 @@ jobs:
./bin/build-addon.sh nightly.xpi
- name: Uploading
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{matrix.config.name}} Build
path: src/web-ext-artifacts

View file

@ -32,7 +32,23 @@ repository like any other. Before editing files in this folder, you need to:
You can then [open a pull request][pr] on [the l10n repository][l10n].
## Tips for contributing
1. Choose [an issue][issues] that you would like to work on.
2. Fork the repository and follow the instructions for setting it up locally.
3. Run the add-on locally and try reproducing the issue.
4. Debug add-ons by clicking the “Settings” icon in about:addons, and then clicking “Debug Add-ons”
5. Click “Inspect” on the MAC add-on to open developer tools for the popup extension (see [this documentation][extension-doc] for more information)
6. Once you have a fix ready, commit your changes with the following commit message template: “Fix #<insert issue id #>: <short description>
7. Push your changes and open a pull request for review.
If you run into an issue, you can always ask the other community members in the [discussions board][discussions].
<!-- Please keep the list in alphabetical order -->
[discussions]: https://github.com/mozilla/multi-account-containers/discussions
[extension-doc]: https://extensionworkshop.com/documentation/develop/debugging/
[fork]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
[issues]: https://github.com/mozilla/multi-account-containers/issues
[l10n]: https://github.com/mozilla-l10n/multi-account-containers-l10n/
[pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
[web-ext]: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext
[web-ext]: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext

View file

@ -13,7 +13,7 @@ Everyone is welcome to contribute to Multi-Account Containers. To learn how
to contribute a patch to Multi-Account Container, please
[read our contributing guide][contributing].
You can also chat with us on [our Matrix room][matrix] or [our forum][forum].
You can also chat with us on [our Matrix room][matrix] or ask in [our discussions board][discussions].
This repository is governed by Mozilla's code of conduct and etiquette
guidelines. For more details, [please read the Mozilla Community Participation Guidelines][cpg].
@ -29,4 +29,5 @@ file, You can obtain one at https://mozilla.org/MPL/2.0/.
[cpg]: https://www.mozilla.org/about/governance/policies/participation/
[enduser]: https://support.mozilla.org/en-US/kb/containers
[forum]: https://discourse.mozilla.org/c/containers/223
[discussions]: https://github.com/mozilla/multi-account-containers/discussions
[matrix]: https://matrix.to/#/#containers:mozilla.org

View file

@ -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": "8.2.0",
"version": "8.3.0",
"author": "Andrea Marchesini, Luke Crouch, Lesley Norton, Kendall Werts, Maxx Crawford, Jonathan Kingston",
"bugs": {
"url": "https://github.com/mozilla/multi-account-containers/issues"

View file

@ -110,7 +110,6 @@
--usercontext-bg-hover-color: #f0f0fa;
--usercontext-bg-focus-color: #e0e0e6;
--usercontext-bg-active-color: #cfcfd8;
--moz-vpn-tout-shadow: 0 0 7px 0 #9498a25e;
}
[data-theme="dark"] {
@ -180,7 +179,6 @@
--usercontext-bg-active-color: #5b5b66;
--usercontext-bg-focus-color: #2b2a33;
--usercontext-bg-hover-color: #52525e;
--moz-vpn-tout-shadow: 0 0 7px 0 #7478825e;
}
/* General Rules and Resets */
@ -635,37 +633,8 @@ input:checked:hover:focus + .slider {
background-color: var(--button-bg-active-color-primary);
}
/* Mozilla VPN tout */
#moz-vpn-tout {
opacity: 0;
background-color: var(--panel-bg-color);
visibility: visible;
max-block-size: 500px;
position: absolute;
inset-block-end: var(--footerHeight);
inset-inline-start: 0;
inset-inline-end: 0;
box-shadow: var(--moz-vpn-tout-shadow);
animation: appear 0.2s ease-out 0.5s forwards;
transition: opacity 0.1s ease-in-out, max-height 0.3s ease-in-out;
}
@keyframes appear {
0% {
opacity: 0;
transform: translateY(10%);
}
100% {
opacity: 1;
transform: translateY(0%);
}
}
/* Mozilla VPN Controller UI in Container Management Panel */
.moz-vpn-content,
.moz-vpn-controller-content {
display: flex;
position: relative;
@ -1053,7 +1022,6 @@ input.proxies {
/* Mozilla VPN Server list */
.moz-vpn-logo,
.moz-vpn-logotype {
color: var(--text-color-primary);
background-image: var(--logoMozillaVpn);

View file

@ -61,8 +61,9 @@ window.assignManager = {
this.area.get([siteStoreKey]).then((storageResponse) => {
if (storageResponse && siteStoreKey in storageResponse) {
resolve(storageResponse[siteStoreKey]);
} else {
resolve(null);
}
resolve(null);
}).catch((e) => {
reject(e);
});
@ -325,7 +326,8 @@ window.assignManager = {
options.url,
tab.index + 1,
tab.active,
openTabId
openTabId,
tab.groupId
);
} else {
this.reloadPageInContainer(
@ -335,7 +337,8 @@ window.assignManager = {
tab.index + 1,
tab.active,
siteSettings.neverAsk,
openTabId
openTabId,
tab.groupId
);
}
this.calculateContextMenu(tab);
@ -480,9 +483,7 @@ window.assignManager = {
},
contextualIdentityRemoved(changeInfo) {
browser.contextMenus.remove(
changeInfo.contextualIdentity.cookieStoreId
);
this.removeMenuItem(changeInfo.contextualIdentity.cookieStoreId);
},
async _onClickedHandler(info, tab) {
@ -638,7 +639,7 @@ window.assignManager = {
},
async _maybeRemoveSiteIsolation(userContextId) {
const assignments = await this.storageArea.getByContainer(userContextId);
const assignments = await this.storageArea.getAssignedSites(userContextId);
const hasAssignments = assignments && Object.keys(assignments).length > 0;
if (hasAssignments) {
return;
@ -669,11 +670,11 @@ window.assignManager = {
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1215376#c16
// We also can't change for always private mode
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1352102
browser.contextMenus.remove(this.MENU_ASSIGN_ID);
browser.contextMenus.remove(this.MENU_REMOVE_ID);
browser.contextMenus.remove(this.MENU_SEPARATOR_ID);
browser.contextMenus.remove(this.MENU_HIDE_ID);
browser.contextMenus.remove(this.MENU_MOVE_ID);
this.removeMenuItem(this.MENU_ASSIGN_ID);
this.removeMenuItem(this.MENU_REMOVE_ID);
this.removeMenuItem(this.MENU_SEPARATOR_ID);
this.removeMenuItem(this.MENU_HIDE_ID);
this.removeMenuItem(this.MENU_MOVE_ID);
},
async calculateContextMenu(tab) {
@ -726,7 +727,15 @@ window.assignManager = {
});
},
reloadPageInDefaultContainer(url, index, active, openerTabId) {
/**
* @param {string} url
* @param {number} index
* @param {boolean} active
* @param {number} [openerTabId]
* @param {number} [groupId]
* @returns {void}
*/
reloadPageInDefaultContainer(url, index, active, openerTabId, groupId) {
// To create a new tab in the default container, it is easiest just to omit the
// cookieStoreId entirely.
//
@ -745,16 +754,58 @@ window.assignManager = {
// does not automatically return to the original opener tab. To get this desired behaviour,
// we MUST specify the openerTabId when creating the new tab.
const cookieStoreId = "firefox-default";
browser.tabs.create({url, cookieStoreId, index, active, openerTabId});
this.createTabWrapper(url, cookieStoreId, index, active, openerTabId, groupId);
},
reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false, openerTabId = null) {
/**
* Wraps around `browser.tabs.create` and `browser.tabs.group` to create a
* tab and ensure that it ends up in the requested tab group, if applicable.
*
* @param {string} url
* @param {string} cookieStoreId
* @param {number} index
* @param {boolean} active
* @param {number} openerTabId
* @param {number} [groupId] Tab group ID
* @returns {Promise<Tab>}
*/
async createTabWrapper(url, cookieStoreId, index, active, openerTabId, groupId) {
const newTab = await browser.tabs.create({
url,
cookieStoreId,
index,
active,
openerTabId,
});
if (groupId >= 0) {
// If the original tab was in a tab group, make sure that the reopened tab
// stays in the same tab group.
await browser.tabs.group({ groupId, tabIds: newTab.id });
}
return newTab;
},
/**
* @param {string} url
* @param {string} currentUserContextId
* @param {string} userContextId
* @param {number} index
* @param {boolean} active
* @param {boolean} [neverAsk=false]
* @param {number} [openerTabId=null]
* @param {number} [groupId]
* @returns {Promise<Tab>}
*/
reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false, openerTabId = null, groupId = undefined) {
const cookieStoreId = backgroundLogic.cookieStoreId(userContextId);
const loadPage = browser.runtime.getURL("confirm-page.html");
// False represents assignment is not permitted
// If the user has explicitly checked "Never Ask Again" on the warning page we will send them straight there
if (neverAsk) {
return browser.tabs.create({url, cookieStoreId, index, active, openerTabId});
return this.createTabWrapper(url, cookieStoreId, index, active, openerTabId, groupId);
} else {
let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`;
let currentCookieStoreId;
@ -762,13 +813,14 @@ window.assignManager = {
currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId);
confirmUrl += `&currentCookieStoreId=${currentCookieStoreId}`;
}
return browser.tabs.create({
url: confirmUrl,
cookieStoreId: currentCookieStoreId,
openerTabId,
return this.createTabWrapper(
confirmUrl,
currentCookieStoreId,
index,
active
}).then(() => {
active,
openerTabId,
groupId
).then(() => {
// We don't want to sync this URL ever nor clutter the users history
browser.history.deleteUrl({url: confirmUrl});
}).catch((e) => {
@ -796,12 +848,19 @@ window.assignManager = {
},
async removeBookmarksMenu() {
browser.contextMenus.remove(this.OPEN_IN_CONTAINER);
this.removeMenuItem(this.OPEN_IN_CONTAINER);
const identities = await browser.contextualIdentities.query({});
for (const identity of identities) {
browser.contextMenus.remove(identity.cookieStoreId);
this.removeMenuItem(identity.cookieStoreId);
}
},
removeMenuItem(menuItemId) {
// Callers do not check whether the menu exists before attempting to remove
// it. contextMenus.remove rejects when the menu does not exist, so we need
// to catch and swallow the error to avoid logspam.
browser.contextMenus.remove(menuItemId).catch(() => {});
}
};
assignManager.init();

View file

@ -35,10 +35,39 @@ const backgroundLogic = {
browser.permissions.onRemoved.addListener(permissions => this.resetPermissions(permissions));
// Update Translation in Manifest
browser.runtime.onInstalled.addListener(this.updateTranslationInManifest);
browser.runtime.onInstalled.addListener((details) => {
this.updateTranslationInManifest();
this._undoDefault820SortTabsKeyboardShortcut(details);
});
browser.runtime.onStartup.addListener(this.updateTranslationInManifest);
},
/**
* One-time migration after updating from v8.2.0:
* Unset the default keyboard shortcut (Ctrl+Comma) for the `sort_tabs`
* command if it was set in v8.2.0 of this addon. If the user remapped
* a different shortcut manually, retain their shortcut. Users who used
* the default keyboard shortcut will need to manually set a shortcut.
* See https://support.mozilla.org/en-US/kb/manage-extension-shortcuts-firefox
*
* @param {{reason: runtime.OnInstalledReason, previousVersion?: string}} details
*/
async _undoDefault820SortTabsKeyboardShortcut(details) {
if (details.reason === "update" && details.previousVersion === "8.2.0") {
const commands = await browser.commands.getAll();
const sortTabsCommand = commands.find(command => command.name === "sort_tabs");
if (sortTabsCommand) {
const previouslySuggestedKeys = [
"Ctrl+Comma", // "default"
"MacCtrl+Comma", // "mac"
];
if (previouslySuggestedKeys.includes(sortTabsCommand.shortcut)) {
browser.commands.reset("sort_tabs");
}
}
}
},
updateTranslationInManifest() {
for (let index = 0; index < 10; index++) {
const ajustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI.
@ -343,7 +372,13 @@ const backgroundLogic = {
let pos = 0;
// Let's collect UCIs/tabs for this window.
/** @type {Map<string, {order: string, tabs: Tab[]}>} */
const map = new Map;
const lastTab = tabs.at(-1);
/** @type {boolean} */
let lastTabIsInTabGroup = !!lastTab && lastTab.groupId >= 0;
for (const tab of tabs) {
if (pinnedTabs && !tab.pinned) {
// We don't have, or we already handled all the pinned tabs.
@ -356,6 +391,11 @@ const backgroundLogic = {
continue;
}
if (tab.groupId >= 0) {
// Skip over tabs in tab groups until it's possible to handle them better.
continue;
}
if (!map.has(tab.cookieStoreId)) {
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(tab.cookieStoreId);
map.set(tab.cookieStoreId, { order: userContextId, tabs: [] });
@ -377,15 +417,25 @@ const backgroundLogic = {
const sortMap = new Map([...map.entries()].sort((a, b) => a[1].order > b[1].order));
// Let's move tabs.
sortMap.forEach(obj => {
for (const tab of obj.tabs) {
for (const { tabs } of sortMap.values()) {
for (const tab of tabs) {
++pos;
browser.tabs.move(tab.id, {
windowId: windowObj.id,
index: pos
index: pinnedTabs ? pos : -1
});
// Pinned tabs are never grouped and always inserted in the front.
if (!pinnedTabs && lastTabIsInTabGroup && browser.tabs.ungroup) {
// If the last item in the tab strip is a grouped tab, moving a tab
// to its position will also add it to the tab group. Since this code
// is only sorting ungrouped tabs, this forcibly ungroups the first
// tab to be moved. All subsequent iterations will only be moving
// ungrouped tabs to the position of other ungrouped tabs.
lastTabIsInTabGroup = false;
browser.tabs.ungroup(tab.id);
}
}
});
}
},
async hideTabs(options) {

View file

@ -91,7 +91,9 @@ const messageHandler = {
m.newUserContextId,
m.tabIndex,
m.active,
true
true,
null,
m.groupId
);
break;
case "assignAndReloadInContainer":
@ -101,7 +103,9 @@ const messageHandler = {
m.newUserContextId,
m.tabIndex,
m.active,
true
true,
null,
m.groupId
);
// m.tabId is used for where to place the in content message
// m.url is the assignment to be removed/added

View file

@ -69,11 +69,15 @@ function confirmSubmit(redirectUrl, cookieStoreId) {
openInContainer(redirectUrl, cookieStoreId);
}
function getCurrentTab() {
return browser.tabs.query({
/**
* @returns {Promise<Tab>}
*/
async function getCurrentTab() {
const tabs = await browser.tabs.query({
active: true,
windowId: browser.windows.WINDOW_ID_CURRENT
});
return tabs[0];
}
async function denySubmit(redirectUrl, currentCookieStoreId) {
@ -93,7 +97,7 @@ async function denySubmit(redirectUrl, currentCookieStoreId) {
await browser.runtime.sendMessage({
method: "exemptContainerAssignment",
tabId: tab[0].id,
tabId: tab.id,
pageUrl: redirectUrl
});
document.location.replace(redirectUrl);
@ -103,12 +107,15 @@ load();
async function openInContainer(redirectUrl, cookieStoreId) {
const tab = await getCurrentTab();
await browser.tabs.create({
index: tab[0].index + 1,
const reopenedTab = await browser.tabs.create({
index: tab.index + 1,
cookieStoreId,
url: redirectUrl
});
if (tab.length > 0) {
browser.tabs.remove(tab[0].id);
if (tab.groupId >= 0) {
// If the original tab was in a tab group, make sure that the reopened tab
// stays in the same tab group.
await browser.tabs.group({ groupId: tab.groupId, tabIds: reopenedTab.id });
}
await browser.tabs.remove(tab.id);
}

View file

@ -767,7 +767,6 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
}
});
const mozillaVpnToutName = "moz-tout-main-panel";
const mozillaVpnPermissionsWarningDotName = "moz-permissions-warning-dot";
let { mozillaVpnHiddenToutsList } = await browser.storage.local.get("mozillaVpnHiddenToutsList");
@ -776,31 +775,6 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
mozillaVpnHiddenToutsList = [];
}
// Decide whether to show Mozilla VPN tout
const mozVpnTout = document.getElementById("moz-vpn-tout");
const mozillaVpnInstalled = await browser.runtime.sendMessage({ method: "MozillaVPN_getInstallationStatus" });
const mozillaVpnToutShouldBeHidden = mozillaVpnHiddenToutsList.find(tout => tout.name === mozillaVpnToutName);
if (mozillaVpnInstalled || mozillaVpnToutShouldBeHidden) {
mozVpnTout.remove();
}
// Add handlers if tout is visible
const mozVpnDismissTout = document.querySelector(".dismiss-moz-vpn-tout");
if (mozVpnDismissTout) {
Utils.addEnterHandler((mozVpnDismissTout), async() => {
mozVpnTout.remove();
mozillaVpnHiddenToutsList.push({
name: mozillaVpnToutName
});
await browser.storage.local.set({ mozillaVpnHiddenToutsList });
});
Utils.addEnterHandler(document.querySelector("#moz-vpn-learn-more"), () => {
MozillaVPN.handleMozillaCtaClick("mac-main-panel-btn");
window.close();
});
}
// Badge Options icon if both nativeMessaging and/or proxy permissions are disabled
const bothMozillaVpnPermissionsEnabled = await MozillaVPN.bothPermissionsEnabled();
const warningDotShouldBeHidden = mozillaVpnHiddenToutsList.find(tout => tout.name === mozillaVpnPermissionsWarningDotName);
@ -1306,7 +1280,8 @@ Logic.registerPanel(REOPEN_IN_CONTAINER_PICKER, {
false,
newUserContextId,
currentTab.index + 1,
currentTab.active
currentTab.active,
currentTab.groupId
);
window.close();
};
@ -1336,7 +1311,8 @@ Logic.registerPanel(REOPEN_IN_CONTAINER_PICKER, {
false,
0,
currentTab.index + 1,
currentTab.active
currentTab.active,
currentTab.groupId
);
window.close();
});

View file

@ -94,6 +94,9 @@ const Utils = {
return result.join("");
},
/**
* @returns {Promise<Tab|false>}
*/
async currentTab() {
const activeTabs = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT });
if (activeTabs.length > 0) {
@ -146,14 +149,24 @@ const Utils = {
});
},
async reloadInContainer(url, currentUserContextId, newUserContextId, tabIndex, active) {
/**
* @param {string} url
* @param {string} currentUserContextId
* @param {string} newUserContextId
* @param {number} tabIndex
* @param {boolean} active
* @param {number} [groupId]
* @returns {Promise<any>}
*/
async reloadInContainer(url, currentUserContextId, newUserContextId, tabIndex, active, groupId = undefined) {
return await browser.runtime.sendMessage({
method: "reloadInContainer",
url,
currentUserContextId,
newUserContextId,
tabIndex,
active
active,
groupId
});
},
@ -167,7 +180,8 @@ const Utils = {
currentUserContextId: false,
newUserContextId: assignedUserContextId,
tabIndex: currentTab.index +1,
active:currentTab.active
active: currentTab.active,
groupId: currentTab.groupId
});
}
await Utils.setOrRemoveAssignment(

View file

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Firefox Multi-Account Containers",
"version": "8.2.0",
"version": "8.3.0",
"incognito": "not_allowed",
"description": "__MSG_extensionDescription__",
"icons": {
@ -45,10 +45,6 @@
"description": "__MSG_openContainerPanel__"
},
"sort_tabs": {
"suggested_key": {
"default": "Ctrl+Comma",
"mac": "MacCtrl+Comma"
},
"description": "__MSG_sortTabsByContainer__"
},
"open_container_0": {

View file

@ -192,18 +192,7 @@
</tr>
</table>
</div>
<div id="moz-vpn-tout" class="moz-vpn-content expanded">
<div class="flx-row button-wrapper">
<h4 class="moz-vpn-logo">Mozilla VPN</h4>
<button class="controller dismiss-moz-vpn-tout" tab-index="0"></button>
</div>
<div class="collapsible-content flx-col controller-collapsible-content">
<div class="flx-row flx-space-between">
<span class="moz-vpn-subtitle" data-i18n-message-id="integrateContainers"></span>
</div>
<button id="moz-vpn-learn-more" class="moz-vpn-cta primary-cta" data-i18n-message-id="getMozillaVpn"></button>
</div>
</div>
<v-padding-hack-footer></v-padding-hack-footer> <!--prevents last container from getting covered up by the 'manage containers button' when list is long-->
<div class="bottom-btn keyboard-nav controller" id="manage-containers-link" tabindex="0" data-i18n-message-id="manageContainers"></div>
</div>

View file

@ -32,6 +32,10 @@ const buildDom = async ({background = {}, popup = {}}) => {
window.crypto = {
getRandomValues: arr => crypto.randomBytes(arr.length),
};
// By default, the mock contextMenus.remove() returns undefined;
// Let it return a Promise instead, so that .then() calls chained to
// it (in src/js/background/assignManager.js) do not fail.
window.browser.contextMenus.remove.resolves();
}
}
};