From 90fca607f85129ce5f5bfeee619ffe0ffb374d8b Mon Sep 17 00:00:00 2001 From: "Robert.Clark" Date: Thu, 5 Oct 2023 10:10:20 -0400 Subject: [PATCH] Handle duplicate tab from Firefox Containers --- src/background.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index 05dc59fdc..097c70381 100644 --- a/src/background.js +++ b/src/background.js @@ -320,7 +320,7 @@ async function maybeReopenTab (url, tab, request) { return {cancel: true}; } - await browser.tabs.create({ + const newTab = await browser.tabs.create({ url, cookieStoreId, active: tab.active, @@ -329,6 +329,13 @@ async function maybeReopenTab (url, tab, request) { }); browser.tabs.remove(tab.id); + const matchingTabs = await browser.tabs.query({url: newTab.url}); + + if (!newTab.active && matchingTabs.length > 1) { + // Close new tab to prevent multiple reopenings when request origin container also opens new tab + browser.tabs.remove(newTab.id); + } + return {cancel: true}; }