diff --git a/index.js b/index.js index 46338e7..8df8bc6 100644 --- a/index.js +++ b/index.js @@ -649,7 +649,7 @@ const ContainerService = { const source = ("source" in args) ? args.source : null; // Only send telemetry for tabs opened by UI - i.e., not via showTabs - if (source) { + if (source && userContextId) { this.sendTelemetryPayload({ "event": "open-tab", "eventSource": source, @@ -658,10 +658,19 @@ const ContainerService = { }); } - const tab = browserWin.gBrowser.addTab(args.url || DEFAULT_TAB, { userContextId }); - browserWin.gBrowser.selectedTab = tab; - browserWin.focusAndSelectUrlBar(); - return true; + let promise; + if (userContextId) { + promise = this.showTabs(args); + } else { + promise = Promise.resolve(null); + } + + return promise.then(() => { + const tab = browserWin.gBrowser.addTab(args.url || DEFAULT_TAB, { userContextId }); + browserWin.gBrowser.selectedTab = tab; + browserWin.focusAndSelectUrlBar(); + return true; + }); }).catch(() => false); }, diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 31219ef..5c2c8af 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -247,14 +247,9 @@ Logic.registerPanel(P_CONTAINERS_LIST, { tr.addEventListener("click", e => { if (e.target.matches(".open-newtab")) { browser.runtime.sendMessage({ - method: "showTabs", - userContextId: identity.userContextId - }).then(() => { - return browser.runtime.sendMessage({ - method: "openTab", - userContextId: identity.userContextId, - source: "pop-up" - }); + method: "openTab", + userContextId: identity.userContextId, + source: "pop-up" }).then(() => { window.close(); }).catch(() => {