tor-browser

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

commit c2079e4df72488ce4cbea17b0a0a96d7c1825d38
parent 8e4ea1b8db2fb6a878ddd6dc4a6c19ee408910a8
Author: Rebecca King <rking@mozilla.com>
Date:   Thu,  4 Dec 2025 18:05:06 +0000

Bug 2002300 - Open support help page with keypress - r=ip-protection-reviewers,kpatenio

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

Diffstat:
Mbrowser/components/ipprotection/IPProtectionPanel.sys.mjs | 7++++++-
Mbrowser/components/ipprotection/tests/browser/browser_ipprotection_header.js | 4+++-
Mbrowser/components/ipprotection/tests/browser/browser_ipprotection_keyboard_navigation.js | 11+++++++++--
3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/browser/components/ipprotection/IPProtectionPanel.sys.mjs b/browser/components/ipprotection/IPProtectionPanel.sys.mjs @@ -192,7 +192,7 @@ export class IPProtectionPanel { */ static showHelpPage(e) { let win = e.target?.ownerGlobal; - if (win && !Cu.isInAutomation) { + if (win) { win.openWebLinkIn(LINKS.SUPPORT_URL, "tab"); } @@ -289,6 +289,11 @@ export class IPProtectionPanel { ownerDocument.l10n.setAttributes(headerButton, "ipprotection-help-button"); headerButton.addEventListener("click", IPProtectionPanel.showHelpPage); + headerButton.addEventListener("keypress", e => { + if (e.code == "Space" || e.code == "Enter") { + IPProtectionPanel.showHelpPage(e); + } + }); return headerButton; } diff --git a/browser/components/ipprotection/tests/browser/browser_ipprotection_header.js b/browser/components/ipprotection/tests/browser/browser_ipprotection_header.js @@ -57,6 +57,7 @@ add_task(async function test_header_content() { * Tests that the help button functions as expected. */ add_task(async function test_help_button() { + const openLinkStub = sinon.stub(window, "openWebLinkIn"); let button = document.getElementById(lazy.IPProtectionWidget.WIDGET_ID); let panelView = PanelMultiView.getViewNode( document, @@ -82,12 +83,13 @@ add_task(async function test_help_button() { Assert.ok(helpButton, "ipprotection-header help button should be present"); let panelHiddenPromise = waitForPanelEvent(document, "popuphidden"); - helpButton.click(); await panelHiddenPromise; + Assert.ok(openLinkStub.calledOnce, "help button should open a link"); Assert.ok( !BrowserTestUtils.isVisible(helpButton), "ipprotection-header help button should have closed the panel" ); + openLinkStub.restore(); }); diff --git a/browser/components/ipprotection/tests/browser/browser_ipprotection_keyboard_navigation.js b/browser/components/ipprotection/tests/browser/browser_ipprotection_keyboard_navigation.js @@ -22,9 +22,11 @@ async function expectFocusAfterKey(aKey, aFocus) { } /** - * Tests that the panel can be navigated with Tab and Arrow keys. + * Tests that the panel can be navigated with Tab and Arrow keys + * and that the help button responds to the Enter key */ add_task(async function test_keyboard_navigation_in_panel() { + const openLinkStub = sinon.stub(window, "openWebLinkIn"); let content = await openPanel({ isSignedOut: false, }); @@ -81,5 +83,10 @@ add_task(async function test_keyboard_navigation_in_panel() { ) ); - await closePanel(); + // Check that header button responds to enter key + let panelHiddenPromise = waitForPanelEvent(document, "popuphidden"); + EventUtils.synthesizeKey("KEY_Enter", {}, window); + await panelHiddenPromise; + Assert.ok(openLinkStub.calledOnce, "help button should open a link"); + openLinkStub.restore(); });