tor-browser

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

commit 8e259787b0af8b5bf09262b0e0403302940add28
parent 1e563824a211ab253715b1407e9161db30a818cd
Author: Tim Giles <tgiles@mozilla.com>
Date:   Mon, 15 Dec 2025 18:47:53 +0000

Bug 2002921 - Make keyboardNavigate a global function in box group test. r=akulyk

Instead of having two instances of the `keyboardNavigate` function, I
moved it to a global function.

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

Diffstat:
Mtoolkit/content/tests/widgets/test_moz_box_group.html | 70+++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 31 insertions(+), 39 deletions(-)

diff --git a/toolkit/content/tests/widgets/test_moz_box_group.html b/toolkit/content/tests/widgets/test_moz_box_group.html @@ -19,6 +19,13 @@ let html; let testHelpers = new LitTestHelpers(); + async function keyboardNavigate(direction, boxGroup) { + let keyCode = `KEY_Arrow${ + direction.charAt(0).toUpperCase() + direction.slice(1) + }`; + synthesizeKey(keyCode); + await boxGroup.updateComplete; + } add_setup(async function setup() { ({ html } = await testHelpers.setupLit()); let templateFn = () => html` @@ -227,14 +234,6 @@ "moz-box-item, moz-box-button, moz-box-link" ); - async function keyboardNavigate(direction) { - let keyCode = `KEY_Arrow${ - direction.charAt(0).toUpperCase() + direction.slice(1) - }`; - synthesizeKey(keyCode); - await boxGroup.updateComplete; - } - isnot(document.activeElement, boxGroup, "Box group is not focused."); beforeButton.focus(); @@ -260,28 +259,28 @@ "Focus moves to the second button action element in the moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector(".first-button"), "Focus moves to the first button action element in moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in the moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector(".second-button"), @@ -391,28 +390,28 @@ "Focus moves to the second button action element in the moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector(".first-button"), "Focus moves to the first button action element in moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector(".second-button"), @@ -440,7 +439,7 @@ "Focus moves to the last element in the group." ); - await keyboardNavigate("up"); + await keyboardNavigate("up", boxGroup); is( document.activeElement, footerButton, @@ -454,49 +453,49 @@ "Focus moves to the last element in the list." ); - await keyboardNavigate("up"); + await keyboardNavigate("up", boxGroup); is( document.activeElement, boxLink, "Focus moves to the moz-box-link element." ); - await keyboardNavigate("up"); + await keyboardNavigate("up", boxGroup); is( document.activeElement, boxItem.querySelector(".second-button"), "Focus moves to the second button action element in the moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in the moz-box-item." ); - await keyboardNavigate("up"); + await keyboardNavigate("up", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Up arrow key does not move focus out of the group from the first item." ); - await keyboardNavigate("down"); + await keyboardNavigate("down", boxGroup); is( document.activeElement, boxLink, "Focus moves to the moz-box-link element." ); - await keyboardNavigate("down"); + await keyboardNavigate("down", boxGroup); is( document.activeElement, boxButton, "Focus moves to the moz-box-button element." ); - await keyboardNavigate("down"); + await keyboardNavigate("down", boxGroup); is( document.activeElement, boxButton, @@ -509,8 +508,8 @@ }); // Navigate up to focus moz-box-item - await keyboardNavigate("up"); - await keyboardNavigate("up"); + await keyboardNavigate("up", boxGroup); + await keyboardNavigate("up", boxGroup); is( document.activeElement, @@ -518,21 +517,21 @@ "Focus moves to the second button action element in the moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), "Focus moves to the toggle action element in the moz-box-item." ); - await keyboardNavigate("right"); + await keyboardNavigate("right", boxGroup); is( document.activeElement, boxItem.querySelector(".first-button"), "Focus moves to the first button action element in the moz-box-item." ); - await keyboardNavigate("left"); + await keyboardNavigate("left", boxGroup); is( document.activeElement, boxItem.querySelector("moz-toggle"), @@ -728,19 +727,12 @@ // move focus via the Tab key. beforeButton.focus(); await synthesizeKey("KEY_Tab"); - async function keyboardNavigate(direction) { - let keyCode = `KEY_Arrow${ - direction.charAt(0).toUpperCase() + direction.slice(1) - }`; - synthesizeKey(keyCode); - await boxGroup.updateComplete; - } // Move through the list until we reach the item that can be // removed. - await keyboardNavigate("down"); - await keyboardNavigate("down"); - await keyboardNavigate("down"); + await keyboardNavigate("down", boxGroup); + await keyboardNavigate("down", boxGroup); + await keyboardNavigate("down", boxGroup); is( document.activeElement.label, "item 3 action 1",