Merge f54b6afc02
into aca51cc11c
This commit is contained in:
commit
351bfef054
5 changed files with 152 additions and 24 deletions
28
package-lock.json
generated
28
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "testpilot-containers",
|
"name": "testpilot-containers",
|
||||||
"version": "8.1.3",
|
"version": "8.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "testpilot-containers",
|
"name": "testpilot-containers",
|
||||||
"version": "8.1.1",
|
"version": "8.2.0",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"addons-linter": "^5.28.0",
|
"addons-linter": "^5.28.0",
|
||||||
|
@ -15032,8 +15032,7 @@
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||||
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"acorn-walk": {
|
"acorn-walk": {
|
||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
|
@ -17246,15 +17245,13 @@
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-4.0.2.tgz",
|
||||||
"integrity": "sha512-Pry0S9YmHoz8NCEMRQh7N0Yexh2MYCNPIlrV52hTmS7qXnTghWsjXouF08bgsrrZqaW9tt1ZiK3j5NEmPE+EjQ==",
|
"integrity": "sha512-Pry0S9YmHoz8NCEMRQh7N0Yexh2MYCNPIlrV52hTmS7qXnTghWsjXouF08bgsrrZqaW9tt1ZiK3j5NEmPE+EjQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-plugin-promise": {
|
"eslint-plugin-promise": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz",
|
||||||
"integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==",
|
"integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-scope": {
|
"eslint-scope": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
|
@ -19763,8 +19760,7 @@
|
||||||
"version": "7.5.9",
|
"version": "7.5.9",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
||||||
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -21971,8 +21967,7 @@
|
||||||
"version": "0.36.2",
|
"version": "0.36.2",
|
||||||
"resolved": "https://registry.npmjs.org/postcss-syntax/-/postcss-syntax-0.36.2.tgz",
|
"resolved": "https://registry.npmjs.org/postcss-syntax/-/postcss-syntax-0.36.2.tgz",
|
||||||
"integrity": "sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w==",
|
"integrity": "sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"postcss-value-parser": {
|
"postcss-value-parser": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
|
@ -22826,8 +22821,7 @@
|
||||||
"version": "3.7.0",
|
"version": "3.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz",
|
||||||
"integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==",
|
"integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"slash": {
|
"slash": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -23571,8 +23565,7 @@
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-3.0.0.tgz",
|
||||||
"integrity": "sha512-F6yTRuc06xr1h5Qw/ykb2LuFynJ2IxkKfCMf+1xqPffkxh0S09Zc902XCffcsw/XMFq/OzQ1w54fLIDtmRNHnQ==",
|
"integrity": "sha512-F6yTRuc06xr1h5Qw/ykb2LuFynJ2IxkKfCMf+1xqPffkxh0S09Zc902XCffcsw/XMFq/OzQ1w54fLIDtmRNHnQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"stylelint-config-standard": {
|
"stylelint-config-standard": {
|
||||||
"version": "20.0.0",
|
"version": "20.0.0",
|
||||||
|
@ -24946,8 +24939,7 @@
|
||||||
"version": "8.12.0",
|
"version": "8.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
|
||||||
"integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
|
"integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"xdg-basedir": {
|
"xdg-basedir": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit bdaa01291b7367a5e815470fd263ea36c862fe32
|
Subproject commit 7ae3edd7455fd776a25a1017c0dfac26b21d7950
|
|
@ -13,9 +13,9 @@ const backgroundLogic = {
|
||||||
]),
|
]),
|
||||||
NUMBER_OF_KEYBOARD_SHORTCUTS: 10,
|
NUMBER_OF_KEYBOARD_SHORTCUTS: 10,
|
||||||
unhideQueue: [],
|
unhideQueue: [],
|
||||||
init() {
|
|
||||||
|
|
||||||
browser.commands.onCommand.addListener(function (command) {
|
init() {
|
||||||
|
browser.commands.onCommand.addListener(async function (command) {
|
||||||
if (command === "sort_tabs") {
|
if (command === "sort_tabs") {
|
||||||
backgroundLogic.sortTabs();
|
backgroundLogic.sortTabs();
|
||||||
return;
|
return;
|
||||||
|
@ -23,10 +23,21 @@ const backgroundLogic = {
|
||||||
|
|
||||||
for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
|
for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
|
||||||
const key = "open_container_" + i;
|
const key = "open_container_" + i;
|
||||||
|
const reopenKey = "reopen_in_container_" + i;
|
||||||
const cookieStoreId = identityState.keyboardShortcut[key];
|
const cookieStoreId = identityState.keyboardShortcut[key];
|
||||||
|
|
||||||
|
if (cookieStoreId === "none") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (command === key) {
|
if (command === key) {
|
||||||
if (cookieStoreId === "none") return;
|
|
||||||
browser.tabs.create({cookieStoreId});
|
browser.tabs.create({cookieStoreId});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command === reopenKey) {
|
||||||
|
backgroundLogic.reopenInContainer(cookieStoreId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -68,12 +79,33 @@ const backgroundLogic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async reopenInContainer(cookieStoreId) {
|
||||||
|
const currentTab = await browser.tabs.query({ active: true, currentWindow: true })
|
||||||
|
|
||||||
|
if (currentTab.length > 0) {
|
||||||
|
const tab = currentTab[0];
|
||||||
|
|
||||||
|
browser.tabs.create({
|
||||||
|
url: tab.url,
|
||||||
|
cookieStoreId: cookieStoreId,
|
||||||
|
index: tab.index + 1,
|
||||||
|
active: tab.active
|
||||||
|
});
|
||||||
|
|
||||||
|
browser.tabs.remove(tab.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
updateTranslationInManifest() {
|
updateTranslationInManifest() {
|
||||||
for (let index = 0; index < 10; index++) {
|
for (let index = 0; index < 10; index++) {
|
||||||
const ajustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI.
|
const adjustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI.
|
||||||
browser.commands.update({
|
browser.commands.update({
|
||||||
name: `open_container_${index}`,
|
name: `open_container_${index}`,
|
||||||
description: browser.i18n.getMessage("containerShortcut", `${ajustedIndex}`)
|
description: browser.i18n.getMessage("containerShortcut", `${adjustedIndex}`)
|
||||||
|
});
|
||||||
|
browser.commands.update({
|
||||||
|
name: `reopen_in_container_${index}`,
|
||||||
|
description: browser.i18n.getMessage("reopenInContainerShortcut", `${adjustedIndex}`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -106,6 +106,66 @@
|
||||||
"default": "Ctrl+Shift+0"
|
"default": "Ctrl+Shift+0"
|
||||||
},
|
},
|
||||||
"description": "__MSG_containerShortcut__"
|
"description": "__MSG_containerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_0": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+1"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_1": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+2"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_2": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+3"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_3": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+4"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_4": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+5"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_5": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+6"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_6": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+7"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_7": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+8"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_8": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+9"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
|
},
|
||||||
|
"reopen_in_container_9": {
|
||||||
|
"suggested_key": {
|
||||||
|
"default": "Alt+Shift+0"
|
||||||
|
},
|
||||||
|
"description": "__MSG_reopenInContainerShortcut__"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
|
|
44
test/features/reopen-shortcuts.test.js
Normal file
44
test/features/reopen-shortcuts.test.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
const {initializeWithTab} = require("../common");
|
||||||
|
|
||||||
|
describe("Reopen Shortcuts Feature", function () {
|
||||||
|
beforeEach(async function () {
|
||||||
|
// Initialize with a tab in the default container
|
||||||
|
this.webExt = await initializeWithTab({
|
||||||
|
cookieStoreId: "firefox-default",
|
||||||
|
url: "https://example.com"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
this.webExt.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when using keyboard shortcut to reopen in container", function () {
|
||||||
|
beforeEach(async function () {
|
||||||
|
// Simulate the keyboard shortcut command
|
||||||
|
await this.webExt.background.browser.commands.onCommand.addListener.firstCall.args[0]("reopen_in_container_0");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should open the page in the assigned container and close the original tab", async function () {
|
||||||
|
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
|
||||||
|
url: "https://example.com",
|
||||||
|
cookieStoreId: "firefox-container-1",
|
||||||
|
index: 1,
|
||||||
|
active: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.webExt.background.browser.tabs.remove.should.have.been.called;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when container is set to 'none'", function () {
|
||||||
|
beforeEach(async function () {
|
||||||
|
await this.webExt.background.browser.commands.onCommand.addListener.firstCall.args[0]("reopen_in_container_9");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not reopen the tab", function () {
|
||||||
|
this.webExt.background.browser.tabs.create.should.not.have.been.called;
|
||||||
|
this.webExt.background.browser.tabs.remove.should.not.have.been.called;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue