tor-browser

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

commit 10d9b0bae303474b8afd08741ef21387518d7bda
parent 16616b53859b7fe5cd0b966768a11c70f5606aca
Author: Julian Descottes <jdescottes@mozilla.com>
Date:   Tue, 14 Oct 2025 13:17:58 +0000

Bug 1965131 - [devtools] Wait for focus/blur events in test_list_keyboard.html r=devtools-reviewers,nchevobbe

The test fails regularly locally in debug mode. With the change proposed in this patch it passes consistently with --repeat 50 so I assume this should fix the problem.

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

Diffstat:
Mdevtools/client/shared/components/test/chrome/test_list_keyboard.html | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/devtools/client/shared/components/test/chrome/test_list_keyboard.html b/devtools/client/shared/components/test/chrome/test_list_keyboard.html @@ -21,7 +21,7 @@ Test that List component has working keyboard interactions. "use strict"; -window.onload = function() { +window.onload = async function() { try { const { a, button, div } = require("devtools/client/shared/vendor/react-dom-factories"); @@ -67,13 +67,21 @@ window.onload = function() { const defaultFocus = listEl.ownerDocument.body; function blurEl(el) { + const onBlur = new Promise(r => { + el.addEventListener("blur", r, {once: true}); + }) // Simulate.blur does not seem to update the activeElement. el.blur(); + return onBlur; } function focusEl(el) { + const onFocus = new Promise(r => { + el.addEventListener("focus", r, {once: true}); + }) // Simulate.focus does not seem to update the activeElement. el.focus(); + return onFocus; } function getExpectedActiveElementForFinalShiftTab() { @@ -239,7 +247,7 @@ window.onload = function() { }, { name: "Current item should remain set even when the list is blured. " + "Keyboard focus should be set back to document body.", - action: () => listEl.ownerDocument.activeElement.blur(), + action: () => blurEl(listEl.ownerDocument.activeElement), state: { current: 1, active: null, }, activeElement: defaultFocus, }, { @@ -276,7 +284,7 @@ window.onload = function() { const { type, options, el } = event; Simulate[type](el, options); } else if (action) { - action(); + await action(); } if (test.activeElement) {