From a9eb39dfba728e85d0fa195f039f57024f58ecb7 Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 17:48:47 +0100 Subject: [PATCH 1/6] Implementation of 'openTab' method --- index.js | 25 +++++++++++++++++++++++++ webextension/js/popup.js | 9 +++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e1cd577..1c46172 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,8 @@ /* global require */ const {ContextualIdentityService} = require('resource://gre/modules/ContextualIdentityService.jsm'); +const { Cc, Ci, Cu, Cr } = require('chrome'); + +Cu.import("resource://gre/modules/Services.jsm"); const tabs = require('sdk/tabs'); const webExtension = require('sdk/webextension'); @@ -167,6 +170,25 @@ const contextualIdentities = { remove: removeContainer }; +function openTab(args) { + let browserWin = Services.wm.getMostRecentWindow('navigator:browser'); + + // This should not really happen. + if (!browserWin || !browserWin.gBrowser) { + return Promise.resolve(false); + } + + let userContextId = 0; + if ('cookieStoreId' in args) { + userContextId = getContainerForCookieStoreId(args.cookieStoreId); + } + + let tab = browserWin.gBrowser.addTab(args.url || null, + { userContextId: userContextId }) + browserWin.gBrowser.selectedTab = tab; + return Promise.resolve(true); +} + function handleWebExtensionMessage(message, sender, sendReply) { switch (message.method) { case 'query': @@ -198,6 +220,9 @@ function handleWebExtensionMessage(message, sender, sendReply) { tabs.open('about:preferences#containers'); sendReply({content: 'opened'}); break; + case 'openTab': + sendReply(openTab(message)); + break; } } diff --git a/webextension/js/popup.js b/webextension/js/popup.js index fb3fbd2..e6f8387 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -31,9 +31,10 @@ function showContainerTabs(containerId) { cookieStoreId: containerId }).then(hiddenTabUrls=> { hiddenTabUrls.forEach(url=> { - browser.tabs.create({ - url: url, - cookieStoreId: containerId + browser.runtime.sendMessage({ + method: 'openTab', + cookieStoreId: containerId, + url: url }); }); }); @@ -121,7 +122,7 @@ browser.runtime.sendMessage({method: 'query'}).then(identities=> { } }); } else if (e.target.matches('.newtab-icon')) { - browser.tabs.create({cookieStoreId: containerId}); + browser.runtime.sendMessage({method: 'openTab', cookieStoreId: containerId}); window.close(); } }); From d27c86c81e4f1989c994ef8f86624a65aadd8341 Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 18:11:54 +0100 Subject: [PATCH 2/6] Method renamed (ex: query => queryIdentities) --- index.js | 16 ++++++++-------- webextension/js/popup.js | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 1c46172..18d44be 100644 --- a/index.js +++ b/index.js @@ -191,32 +191,32 @@ function openTab(args) { function handleWebExtensionMessage(message, sender, sendReply) { switch (message.method) { - case 'query': + case 'queryIdentities': sendReply(contextualIdentities.query(message.arguments)); break; - case 'hide': + case 'hideTab': identitiesState[message.cookieStoreId].hiddenTabUrls = message.tabUrlsToSave; break; - case 'show': + case 'showTab': sendReply(identitiesState[message.cookieStoreId].hiddenTabUrls); identitiesState[message.cookieStoreId].hiddenTabUrls = []; break; - case 'get': + case 'getTab': sendReply(contextualIdentities.get(message.arguments)); break; - case 'create': + case 'createTab': sendReply(contextualIdentities.create(message.arguments)); break; - case 'update': + case 'updateTab': sendReply(contextualIdentities.update(message.arguments)); break; - case 'remove': + case 'removeTab': sendReply(contextualIdentities.remove(message.arguments)); break; case 'getIdentitiesState': sendReply(identitiesState); break; - case 'open-containers-preferences': + case 'openContainersPreferences': tabs.open('about:preferences#containers'); sendReply({content: 'opened'}); break; diff --git a/webextension/js/popup.js b/webextension/js/popup.js index e6f8387..bc1cbeb 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -13,7 +13,7 @@ function hideContainerTabs(containerId) { tabUrlsToSave.push(tab.url); }); browser.runtime.sendMessage({ - method: 'hide', + method: 'hideTab', cookieStoreId: containerId, tabUrlsToSave: tabUrlsToSave }).then(()=> { @@ -27,7 +27,7 @@ function showContainerTabs(containerId) { const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`); browser.runtime.sendMessage({ - method: 'show', + method: 'showTab', cookieStoreId: containerId }).then(hiddenTabUrls=> { hiddenTabUrls.forEach(url=> { @@ -68,7 +68,7 @@ document.querySelector('#onboarding-done-button').addEventListener('click', ()=> document.querySelector('#container-panel').classList.remove('hide'); }); -browser.runtime.sendMessage({method: 'query'}).then(identities=> { +browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { const identitiesListElement = document.querySelector('.identities-list'); identities.forEach(identity=> { @@ -130,7 +130,7 @@ browser.runtime.sendMessage({method: 'query'}).then(identities=> { }); document.querySelector('#edit-containers-link').addEventListener('click', ()=> { - browser.runtime.sendMessage({method: 'open-containers-preferences'}).then(()=> { + browser.runtime.sendMessage('openContainersPreferences').then(()=> { window.close(); }); }); @@ -145,7 +145,7 @@ function moveTabs(sortedTabsArray) { } document.querySelector('#sort-containers-link').addEventListener('click', ()=> { - browser.runtime.sendMessage({method: 'query'}).then(identities=> { + browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { identities.unshift({cookieStoreId: 'firefox-default'}); browser.tabs.query({}).then(tabsArray=> { From e234c3c9f87c9dced359817ab6a0241b1eae620b Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 18:52:35 +0100 Subject: [PATCH 3/6] Query() moved to the parent process --- index.js | 46 ++++++++++++++++++++++++++++++++++++++++ webextension/js/popup.js | 12 ++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 18d44be..2179b0f 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ Cu.import("resource://gre/modules/Services.jsm"); const tabs = require('sdk/tabs'); const webExtension = require('sdk/webextension'); +const { viewFor } = require("sdk/view/core"); /* Let's start enabling Containers */ var prefs = [ @@ -26,6 +27,10 @@ const identitiesState = { }; function getCookieStoreIdForContainer(containerId) { + if (containerId == 0) { + return 'firefox-default'; + } + return CONTAINER_STORE + containerId; } @@ -189,11 +194,48 @@ function openTab(args) { return Promise.resolve(true); } +function queryTabs(args) { + return new Promise((resolve, reject) => { + let tabList = []; + + for (let tab of tabs) { + let xulTab = viewFor(tab); + let userContextId = xulTab.getAttribute('usercontextid') || 0; + let cookieStoreId = getCookieStoreIdForContainer(userContextId); + + if ("cookieStoreId" in args && args.cookieStoreId != cookieStoreId) { + continue; + } + + tabList.push({ + id: tab.id, + url: tab.url, + cookieStoreId: cookieStoreId, + }); + } + + resolve(tabList); + }); +} + +function removeTabs(ids) { + for (let tab of tabs) { + if (ids.indexOf(tab.id) != -1) { + tab.close(); + } + } + + return Promise.resolve(null); +} + function handleWebExtensionMessage(message, sender, sendReply) { switch (message.method) { case 'queryIdentities': sendReply(contextualIdentities.query(message.arguments)); break; + case 'queryTabs': + sendReply(queryTabs(message)); + break; case 'hideTab': identitiesState[message.cookieStoreId].hiddenTabUrls = message.tabUrlsToSave; break; @@ -201,6 +243,10 @@ function handleWebExtensionMessage(message, sender, sendReply) { sendReply(identitiesState[message.cookieStoreId].hiddenTabUrls); identitiesState[message.cookieStoreId].hiddenTabUrls = []; break; + case 'removeTabs': + sendReply(removeTabs(message.tabIds)); + identitiesState[message.cookieStoreId].hiddenTabUrls = []; + break; case 'getTab': sendReply(contextualIdentities.get(message.arguments)); break; diff --git a/webextension/js/popup.js b/webextension/js/popup.js index bc1cbeb..4eed73c 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -7,7 +7,10 @@ function hideContainerTabs(containerId) { const tabUrlsToSave = []; const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`); - browser.tabs.query({cookieStoreId: containerId}).then(tabs=> { + browser.runtime.sendMessage({ + method: 'queryTabs', + cookieStoreId: containerId + }).then(tabs=> { tabs.forEach(tab=> { tabIdsToRemove.push(tab.id); tabUrlsToSave.push(tab.url); @@ -17,7 +20,10 @@ function hideContainerTabs(containerId) { cookieStoreId: containerId, tabUrlsToSave: tabUrlsToSave }).then(()=> { - browser.tabs.remove(tabIdsToRemove); + browser.runtime.sendMessage({ + method: 'removeTabs', + tabIds: tabIdsToRemove + }); hideorshowIcon.src = CONTAINER_UNHIDE_SRC; }); }); @@ -148,7 +154,7 @@ document.querySelector('#sort-containers-link').addEventListener('click', ()=> { browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { identities.unshift({cookieStoreId: 'firefox-default'}); - browser.tabs.query({}).then(tabsArray=> { + browser.runtime.sendMessage({method: 'queryTabs'}).then(tabsArray=> { const sortedTabsArray = []; identities.forEach(identity=> { From 4c7d6a4c9b69eb0c280a7414da089176e952f009 Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 19:35:18 +0100 Subject: [PATCH 4/6] Migrate from cookieStoreId to userContextId --- index.js | 82 +++++++++++----------------------------- webextension/js/popup.js | 36 +++++++++--------- 2 files changed, 41 insertions(+), 77 deletions(-) diff --git a/index.js b/index.js index 2179b0f..2e95af0 100644 --- a/index.js +++ b/index.js @@ -21,63 +21,32 @@ prefs.forEach((pref) => { prefService.set(pref[0], pref[1]); }); -const CONTAINER_STORE = 'firefox-container-'; - const identitiesState = { }; -function getCookieStoreIdForContainer(containerId) { - if (containerId == 0) { - return 'firefox-default'; - } - - return CONTAINER_STORE + containerId; -} - function convert(identity) { - const cookieStoreId = getCookieStoreIdForContainer(identity.userContextId); let hiddenTabUrls = []; - if (cookieStoreId in identitiesState) { - hiddenTabUrls = identitiesState[cookieStoreId].hiddenTabUrls; + if (identity.userContextId in identitiesState) { + hiddenTabUrls = identitiesState[identity.userContextId].hiddenTabUrls; } const result = { name: ContextualIdentityService.getUserContextLabel(identity.userContextId), icon: identity.icon, color: identity.color, - cookieStoreId: cookieStoreId, + userContextId: identity.userContextId, hiddenTabUrls: hiddenTabUrls }; return result; } -function isContainerCookieStoreId(storeId) { - return storeId !== null && storeId.startsWith(CONTAINER_STORE); -} - -function getContainerForCookieStoreId(storeId) { - if (!isContainerCookieStoreId(storeId)) { - return null; - } - - const containerId = storeId.substring(CONTAINER_STORE.length); - - if (ContextualIdentityService.getIdentityFromId(containerId)) { - return parseInt(containerId, 10); - } - - return null; -} - -function getContainer(cookieStoreId) { - const containerId = getContainerForCookieStoreId(cookieStoreId); - - if (!containerId) { +function getContainer(userContextId) { + if (!userContextId) { return Promise.resolve(null); } - const identity = ContextualIdentityService.getIdentityFromId(containerId); + const identity = ContextualIdentityService.getIdentityFromId(userContextId); return Promise.resolve(convert(identity)); } @@ -94,8 +63,8 @@ function queryContainers(details) { const convertedIdentity = convert(identity); identities.push(convertedIdentity); - if (!(convertedIdentity.cookieStoreId in identitiesState)) { - identitiesState[convertedIdentity.cookieStoreId] = {hiddenTabUrls: []}; + if (!(convertedIdentity.userContextId in identitiesState)) { + identitiesState[convertedIdentity.userContextId] = {hiddenTabUrls: []}; } }); @@ -110,14 +79,12 @@ function createContainer(details) { return Promise.resolve(convert(identity)); } -function updateContainer(cookieStoreId, details) { - const containerId = getContainerForCookieStoreId(cookieStoreId); - - if (!containerId) { +function updateContainer(userContextId, details) { + if (!userContextId) { return Promise.resolve(null); } - const identity = ContextualIdentityService.getIdentityFromId(containerId); + const identity = ContextualIdentityService.getIdentityFromId(userContextId); if (!identity) { return Promise.resolve(null); @@ -144,14 +111,12 @@ function updateContainer(cookieStoreId, details) { return Promise.resolve(convert(identity)); } -function removeContainer(cookieStoreId) { - const containerId = getContainerForCookieStoreId(cookieStoreId); - - if (!containerId) { +function removeContainer(userContextId) { + if (!userContextId) { return Promise.resolve(null); } - const identity = ContextualIdentityService.getIdentityFromId(containerId); + const identity = ContextualIdentityService.getIdentityFromId(userContextId); if (!identity) { return Promise.resolve(null); @@ -184,8 +149,8 @@ function openTab(args) { } let userContextId = 0; - if ('cookieStoreId' in args) { - userContextId = getContainerForCookieStoreId(args.cookieStoreId); + if ('userContextId' in args) { + userContextId = args.userContextId; } let tab = browserWin.gBrowser.addTab(args.url || null, @@ -200,17 +165,16 @@ function queryTabs(args) { for (let tab of tabs) { let xulTab = viewFor(tab); - let userContextId = xulTab.getAttribute('usercontextid') || 0; - let cookieStoreId = getCookieStoreIdForContainer(userContextId); + let userContextId = parseInt(xulTab.getAttribute('usercontextid') || 0, 10); - if ("cookieStoreId" in args && args.cookieStoreId != cookieStoreId) { + if ("userContextId" in args && args.userContextId != userContextId) { continue; } tabList.push({ id: tab.id, url: tab.url, - cookieStoreId: cookieStoreId, + userContextId: userContextId, }); } @@ -237,15 +201,15 @@ function handleWebExtensionMessage(message, sender, sendReply) { sendReply(queryTabs(message)); break; case 'hideTab': - identitiesState[message.cookieStoreId].hiddenTabUrls = message.tabUrlsToSave; + identitiesState[message.userContextId].hiddenTabUrls = message.tabUrlsToSave; break; case 'showTab': - sendReply(identitiesState[message.cookieStoreId].hiddenTabUrls); - identitiesState[message.cookieStoreId].hiddenTabUrls = []; + sendReply(identitiesState[message.userContextId].hiddenTabUrls); + identitiesState[message.userContextId].hiddenTabUrls = []; break; case 'removeTabs': sendReply(removeTabs(message.tabIds)); - identitiesState[message.cookieStoreId].hiddenTabUrls = []; + identitiesState[message.userContextId].hiddenTabUrls = []; break; case 'getTab': sendReply(contextualIdentities.get(message.arguments)); diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 4eed73c..41bcf4f 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -2,14 +2,14 @@ const CONTAINER_HIDE_SRC = '/img/container-hide.svg'; const CONTAINER_UNHIDE_SRC = '/img/container-unhide.svg'; -function hideContainerTabs(containerId) { +function hideContainerTabs(userContextId) { const tabIdsToRemove = []; const tabUrlsToSave = []; - const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`); + const hideorshowIcon = document.querySelector(`#uci-${userContextId}-hideorshow-icon`); browser.runtime.sendMessage({ method: 'queryTabs', - cookieStoreId: containerId + userContextId: userContextId }).then(tabs=> { tabs.forEach(tab=> { tabIdsToRemove.push(tab.id); @@ -17,7 +17,7 @@ function hideContainerTabs(containerId) { }); browser.runtime.sendMessage({ method: 'hideTab', - cookieStoreId: containerId, + userContextId: userContextId, tabUrlsToSave: tabUrlsToSave }).then(()=> { browser.runtime.sendMessage({ @@ -29,17 +29,17 @@ function hideContainerTabs(containerId) { }); } -function showContainerTabs(containerId) { - const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`); +function showContainerTabs(userContextId) { + const hideorshowIcon = document.querySelector(`#uci-${userContextId}-hideorshow-icon`); browser.runtime.sendMessage({ method: 'showTab', - cookieStoreId: containerId + userContextId: userContextId }).then(hiddenTabUrls=> { hiddenTabUrls.forEach(url=> { browser.runtime.sendMessage({ method: 'openTab', - cookieStoreId: containerId, + userContextId: userContextId, url: url }); }); @@ -84,7 +84,7 @@ browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { hideOrShowIconSrc = CONTAINER_UNHIDE_SRC; } const identityRow = ` - +
{ @@ -117,18 +117,18 @@ browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { rows.forEach(row=> { row.addEventListener('click', e=> { - const containerId = e.target.parentElement.parentElement.dataset.identityCookieStoreId; + const userContextId = e.target.parentElement.parentElement.dataset.identityCookieStoreId; if (e.target.matches('.hideorshow-icon')) { browser.runtime.sendMessage({method: 'getIdentitiesState'}).then(identitiesState=> { - if (identitiesState[containerId].hiddenTabUrls.length) { - showContainerTabs(containerId); + if (identitiesState[userContextId].hiddenTabUrls.length) { + showContainerTabs(userContextId); } else { - hideContainerTabs(containerId); + hideContainerTabs(userContextId); } }); } else if (e.target.matches('.newtab-icon')) { - browser.runtime.sendMessage({method: 'openTab', cookieStoreId: containerId}); + browser.runtime.sendMessage({method: 'openTab', userContextId: userContextId}); window.close(); } }); @@ -152,14 +152,14 @@ function moveTabs(sortedTabsArray) { document.querySelector('#sort-containers-link').addEventListener('click', ()=> { browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { - identities.unshift({cookieStoreId: 'firefox-default'}); + identities.unshift({userContextId: 0}); browser.runtime.sendMessage({method: 'queryTabs'}).then(tabsArray=> { const sortedTabsArray = []; identities.forEach(identity=> { tabsArray.forEach(tab=> { - if (tab.cookieStoreId === identity.cookieStoreId) { + if (tab.userContextId === identity.userContextId) { sortedTabsArray.push(tab.id); } }); From a8fa144080693fcc32c17dafcb8c2ba3933400f8 Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 20:05:33 +0100 Subject: [PATCH 5/6] Cleaning up existing methods --- index.js | 76 ++-------------------------------------- webextension/js/popup.js | 4 +-- 2 files changed, 5 insertions(+), 75 deletions(-) diff --git a/index.js b/index.js index 2e95af0..6f71099 100644 --- a/index.js +++ b/index.js @@ -41,16 +41,6 @@ function convert(identity) { return result; } -function getContainer(userContextId) { - if (!userContextId) { - return Promise.resolve(null); - } - - const identity = ContextualIdentityService.getIdentityFromId(userContextId); - - return Promise.resolve(convert(identity)); -} - function queryContainers(details) { const identities = []; @@ -71,46 +61,6 @@ function queryContainers(details) { return Promise.resolve(identities); } -function createContainer(details) { - const identity = ContextualIdentityService.create(details.name, - details.icon, - details.color); - - return Promise.resolve(convert(identity)); -} - -function updateContainer(userContextId, details) { - if (!userContextId) { - return Promise.resolve(null); - } - - const identity = ContextualIdentityService.getIdentityFromId(userContextId); - - if (!identity) { - return Promise.resolve(null); - } - - if (details.name !== null) { - identity.name = details.name; - } - - if (details.color !== null) { - identity.color = details.color; - } - - if (details.icon !== null) { - identity.icon = details.icon; - } - - if (!ContextualIdentityService.update(identity.userContextId, - identity.name, identity.icon, - identity.color)) { - return Promise.resolve(null); - } - - return Promise.resolve(convert(identity)); -} - function removeContainer(userContextId) { if (!userContextId) { return Promise.resolve(null); @@ -132,14 +82,6 @@ function removeContainer(userContextId) { return Promise.resolve(convertedIdentity); } -const contextualIdentities = { - get: getContainer, - query: queryContainers, - create: createContainer, - update: updateContainer, - remove: removeContainer -}; - function openTab(args) { let browserWin = Services.wm.getMostRecentWindow('navigator:browser'); @@ -195,15 +137,15 @@ function removeTabs(ids) { function handleWebExtensionMessage(message, sender, sendReply) { switch (message.method) { case 'queryIdentities': - sendReply(contextualIdentities.query(message.arguments)); + sendReply(queryContainers(message.arguments)); break; case 'queryTabs': sendReply(queryTabs(message)); break; - case 'hideTab': + case 'hideTabs': identitiesState[message.userContextId].hiddenTabUrls = message.tabUrlsToSave; break; - case 'showTab': + case 'showTabs': sendReply(identitiesState[message.userContextId].hiddenTabUrls); identitiesState[message.userContextId].hiddenTabUrls = []; break; @@ -211,18 +153,6 @@ function handleWebExtensionMessage(message, sender, sendReply) { sendReply(removeTabs(message.tabIds)); identitiesState[message.userContextId].hiddenTabUrls = []; break; - case 'getTab': - sendReply(contextualIdentities.get(message.arguments)); - break; - case 'createTab': - sendReply(contextualIdentities.create(message.arguments)); - break; - case 'updateTab': - sendReply(contextualIdentities.update(message.arguments)); - break; - case 'removeTab': - sendReply(contextualIdentities.remove(message.arguments)); - break; case 'getIdentitiesState': sendReply(identitiesState); break; diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 41bcf4f..b9d318a 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -16,7 +16,7 @@ function hideContainerTabs(userContextId) { tabUrlsToSave.push(tab.url); }); browser.runtime.sendMessage({ - method: 'hideTab', + method: 'hideTabs', userContextId: userContextId, tabUrlsToSave: tabUrlsToSave }).then(()=> { @@ -33,7 +33,7 @@ function showContainerTabs(userContextId) { const hideorshowIcon = document.querySelector(`#uci-${userContextId}-hideorshow-icon`); browser.runtime.sendMessage({ - method: 'showTab', + method: 'showTabs', userContextId: userContextId }).then(hiddenTabUrls=> { hiddenTabUrls.forEach(url=> { From f29f9d00eb2fbad507f22aa9caae241a5631d42e Mon Sep 17 00:00:00 2001 From: baku Date: Fri, 6 Jan 2017 20:12:46 +0100 Subject: [PATCH 6/6] Fixing open about:preferences#containers --- index.js | 4 ---- webextension/js/popup.js | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 6f71099..be2bb05 100644 --- a/index.js +++ b/index.js @@ -156,10 +156,6 @@ function handleWebExtensionMessage(message, sender, sendReply) { case 'getIdentitiesState': sendReply(identitiesState); break; - case 'openContainersPreferences': - tabs.open('about:preferences#containers'); - sendReply({content: 'opened'}); - break; case 'openTab': sendReply(openTab(message)); break; diff --git a/webextension/js/popup.js b/webextension/js/popup.js index b9d318a..b987c53 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -136,7 +136,10 @@ browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { }); document.querySelector('#edit-containers-link').addEventListener('click', ()=> { - browser.runtime.sendMessage('openContainersPreferences').then(()=> { + browser.runtime.sendMessage({ + method: 'openTab', + url: "about:preferences#containers" + }).then(()=> { window.close(); }); });