From d2b03308791b9259ad62f1a717c79d57ba47a269 Mon Sep 17 00:00:00 2001 From: petoncle Date: Wed, 25 Oct 2023 00:13:19 +0200 Subject: [PATCH 1/2] Fix wrong behavior of :tabopen with containers --- src/excmds.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index bdc844cf..0a8004b5 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -2806,16 +2806,9 @@ export async function tabopen_helper({ addressarr = [], waitForDom = false }): P } if (typeof maybeURL === "object") { - if (await firefoxVersionAtLeast(80)) { - // work around #2695 until we can work out what is going on - if (args.active === false || args.cookieStoreId !== undefined || waitForDom === true) { - throw new Error("Firefox search engines do not support containers or background tabs in FF >80. `:set searchengine google` or see issue https://github.com/tridactyl/tridactyl/issues/2695") - } - - // This ignores :set tabopenpos / issue #342. TODO: fix that somehow. - return browser.search.search(maybeURL) - } - return openInNewTab(null, args, waitForDom).then(tab => browser.search.search({ tabId: tab.id, ...maybeURL })) + return openInNewTab(null, args, waitForDom) + .then(tab => browser.tabs.get(tab.id)) + .then(tab => browser.search.search({tabId: tab.id, ...maybeURL})) } // Fall back to about:newtab From af799bdec7c29ca8bf8c10323b6b6257e7cc5e50 Mon Sep 17 00:00:00 2001 From: petoncle Date: Wed, 25 Oct 2023 13:50:26 +0200 Subject: [PATCH 2/2] Add explanation about browser.tabs.get() --- src/excmds.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/excmds.ts b/src/excmds.ts index 0a8004b5..c7f6e6fd 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -2806,6 +2806,10 @@ export async function tabopen_helper({ addressarr = [], waitForDom = false }): P } if (typeof maybeURL === "object") { + // browser.search.search(tabId, ...) sometimes does not work when it is executed + // right after openInNewTab(). Calling browser.tabs.get() between openInNewTab() + // and browser.search.search() seems to fix that problem. + // See https://github.com/tridactyl/tridactyl/pull/4791. return openInNewTab(null, args, waitForDom) .then(tab => browser.tabs.get(tab.id)) .then(tab => browser.search.search({tabId: tab.id, ...maybeURL}))