tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 94eaa76b21109266a669ce7e77b4c950eee5ecfd
parent ce76403552ad9d180fe60b1a2462ff91eb132807
Author: Apurva Agrawal <apurva.agrawal3003@gmail.com>
Date:   Wed, 29 Oct 2025 12:48:47 +0000

Bug 1973318 - Make History sidebar reuse current tab instead of opening a new tab. r=kcochrane,fxview-reviewers

This patch updates `navigateToLink` to allow the caller to control whether links open in a new tab.
The History sidebar now passes `{ forceNewTab: false }` so that clicking entries reuses the current tab.
Bookmarks sidebar behavior is unchanged.

Bug 1973318 - Make History sidebar reuse current tab instead of opening a new tab. r=kcochrane

Differential Revision: https://phabricator.services.mozilla.com/D270096

Diffstat:
Mbrowser/components/firefoxview/helpers.mjs | 8++++++--
Mbrowser/components/sidebar/sidebar-history.mjs | 2+-
Mbrowser/components/sidebar/tests/browser/browser_history_keyboard_navigation.js | 14++++++--------
Mbrowser/components/sidebar/tests/browser/browser_history_sidebar.js | 8++++----
4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/browser/components/firefoxview/helpers.mjs b/browser/components/firefoxview/helpers.mjs @@ -88,7 +88,11 @@ export function escapeHtmlEntities(text) { .replace(/'/g, "&#39;"); } -export function navigateToLink(e, url = e.originalTarget.url) { +export function navigateToLink( + e, + url = e.originalTarget.url, + { forceNewTab = true } = {} +) { let currentWindow = e.target.ownerGlobal.browsingContext.embedderWindowGlobal.browsingContext .window; @@ -98,7 +102,7 @@ export function navigateToLink(e, url = e.originalTarget.url) { false, true ); - if (where == "current") { + if (where == "current" && forceNewTab) { where = "tab"; } currentWindow.openTrustedLinkIn(url, where); diff --git a/browser/components/sidebar/sidebar-history.mjs b/browser/components/sidebar/sidebar-history.mjs @@ -164,7 +164,7 @@ export class SidebarHistory extends SidebarPage { // Avoid opening multiple links at once. return; } - navigateToLink(e); + navigateToLink(e, e.originalTarget.url, { forceNewTab: false }); this.treeView.clearSelection(); } diff --git a/browser/components/sidebar/tests/browser/browser_history_keyboard_navigation.js b/browser/components/sidebar/tests/browser/browser_history_keyboard_navigation.js @@ -63,10 +63,9 @@ add_task(async function test_navigation_sort_by_date() { await focusWithKeyboard(rows[3], "KEY_ArrowUp", contentWindow); info("Open the focused link."); - await waitForPageLoadTask( - () => EventUtils.synthesizeKey("KEY_Enter", {}, contentWindow), - URLs[1] - ); + let browser = gBrowser.selectedBrowser; + EventUtils.synthesizeKey("KEY_Enter", {}, contentWindow); + await BrowserTestUtils.browserLoaded(browser, false, URLs[1]); }); add_task(async function test_navigation_left_and_right_home_and_end_keys() { @@ -185,8 +184,7 @@ add_task(async function test_navigation_sort_by_last_visited() { () => tabList.rowEls.length === URLs.length ); tabList.rowEls[0].focus(); - await waitForPageLoadTask( - () => EventUtils.synthesizeKey("KEY_Enter", {}, contentWindow), - URLs[1] - ); + let browser = gBrowser.selectedBrowser; + EventUtils.synthesizeKey("KEY_Enter", {}, contentWindow); + await BrowserTestUtils.browserLoaded(browser, false, URLs[1]); }); diff --git a/browser/components/sidebar/tests/browser/browser_history_sidebar.js b/browser/components/sidebar/tests/browser/browser_history_sidebar.js @@ -383,10 +383,10 @@ add_task(async function test_history_hover_buttons() { // a mouse user would not need these links to become focusable, therefore this rule check shall be ignored // by a11y_checks suite. Bug 1961686 is a follow up update a helper so we can later remove this. AccessibilityUtils.setEnv({ focusableRule: false }); - await waitForPageLoadTask( - () => EventUtils.synthesizeMouseAtCenter(rows[0].mainEl, {}, contentWindow), - URLs[0] - ); + const browser = gBrowser.selectedBrowser; + const loaded = BrowserTestUtils.browserLoaded(browser, false, URLs[0]); + EventUtils.synthesizeMouseAtCenter(rows[0].mainEl, {}, contentWindow); + await loaded; AccessibilityUtils.resetEnv(); info("Remove the first entry.");