[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 46/73: Bug 1784432 - allow opening list all tabs menu using the keyboard, r=mhowell a=RyanVM
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.
commit 157e78f73c5bfde24b98297ae8ddbee458415bbb
Author: Gijs Kruitbosch <gijskruitbosch@xxxxxxxxx>
AuthorDate: Mon Aug 29 20:50:46 2022 +0000
Bug 1784432 - allow opening list all tabs menu using the keyboard, r=mhowell a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D155868
---
browser/base/content/browser-allTabsMenu.js | 6 ++++
browser/base/content/navigator-toolbox.inc.xhtml | 1 +
browser/base/content/test/tabs/browser.ini | 1 +
.../tabs/browser_tab_manager_keyboard_access.js | 37 ++++++++++++++++++++++
4 files changed, 45 insertions(+)
diff --git a/browser/base/content/browser-allTabsMenu.js b/browser/base/content/browser-allTabsMenu.js
index 851e0bfbac31f..bc1c07b5f7268 100644
--- a/browser/base/content/browser-allTabsMenu.js
+++ b/browser/base/content/browser-allTabsMenu.js
@@ -139,6 +139,12 @@ var gTabsPanel = {
},
showAllTabsPanel(event) {
+ // Note that event may be null.
+
+ // Only space and enter should open the popup, ignore other keypresses:
+ if (event?.type == "keypress" && event.key != "Enter" && event.key != " ") {
+ return;
+ }
this.init();
if (this.canOpen) {
PanelUI.showSubView(
diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml
index 5f1113e1111ef..316d3ef98371d 100644
--- a/browser/base/content/navigator-toolbox.inc.xhtml
+++ b/browser/base/content/navigator-toolbox.inc.xhtml
@@ -80,6 +80,7 @@
<toolbarbutton id="alltabs-button"
class="toolbarbutton-1 chromeclass-toolbar-additional tabs-alltabs-button"
badged="true"
+ onkeypress="gTabsPanel.showAllTabsPanel(event);"
onmousedown="gTabsPanel.showAllTabsPanel(event);"
data-l10n-id="tabs-toolbar-list-all-tabs"
removable="false"/>
diff --git a/browser/base/content/test/tabs/browser.ini b/browser/base/content/test/tabs/browser.ini
index 8607042000b40..f12018025b39e 100644
--- a/browser/base/content/test/tabs/browser.ini
+++ b/browser/base/content/test/tabs/browser.ini
@@ -61,6 +61,7 @@ support-files = tab_that_closes.html
[browser_multiselect_tabs_move_to_another_window_drag.js]
[browser_multiselect_tabs_move_to_new_window_contextmenu.js]
https_first_disabled = true
+[browser_tab_manager_keyboard_access.js]
[browser_tab_play.js]
[browser_multiselect_tabs_move.js]
[browser_multiselect_tabs_mute_unmute.js]
diff --git a/browser/base/content/test/tabs/browser_tab_manager_keyboard_access.js b/browser/base/content/test/tabs/browser_tab_manager_keyboard_access.js
new file mode 100644
index 0000000000000..039e49fa5bfe9
--- /dev/null
+++ b/browser/base/content/test/tabs/browser_tab_manager_keyboard_access.js
@@ -0,0 +1,37 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Check we can open the tab manager using the keyboard.
+ * Note that navigation to buttons in the toolbar is covered
+ * by other tests.
+ */
+add_task(async function test_open_tabmanager_keyboard() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.tabs.tabmanager.enabled", true]],
+ });
+ let newWindow = await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();
+ let elem = newWindow.document.getElementById("alltabs-button");
+
+ // Borrowed from forceFocus() in the keyboard directory head.js
+ elem.setAttribute("tabindex", "-1");
+ elem.focus();
+ elem.removeAttribute("tabindex");
+
+ let focused = BrowserTestUtils.waitForEvent(newWindow, "focus", true);
+ EventUtils.synthesizeKey(" ", {}, newWindow);
+ let event = await focused;
+ ok(
+ event.originalTarget.closest("#allTabsMenu-allTabsView"),
+ "Focus inside all tabs menu after toolbar button pressed"
+ );
+ let hidden = BrowserTestUtils.waitForEvent(
+ event.target.closest("panel"),
+ "popuphidden"
+ );
+ EventUtils.synthesizeKey("KEY_Escape", { shiftKey: false }, newWindow);
+ await hidden;
+ await BrowserTestUtils.closeWindow(newWindow);
+});
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits