Support focussing the document in background windows with "focusmanager.testmode" enabled
Categories
(Core :: DOM: Core & HTML, enhancement)
Tracking
()
People
(Reporter: whimboo, Unassigned)
Details
With the FocusManager test mode we have a way to simulate that a window in the background is considered internally as the top-most window to as well receive user events. This is required by WebDriver so that we can run user interactions in multiple windows in parallel.
As I've just discovered when investigating test failures in Playwright when running them with WebDriver BiDi they also consider Nodes in those background windows as focusable. Right now this doesn't work in Firefox because the focus manager doesn't support it, and the Playwright team added the following code to their custom Firefox build to support it:
- https://github.com/microsoft/playwright/blob/f11768436ae0888fa2cc0803eb7a79e0dedb7d5b/browser_patches/firefox/patches/bootstrap.diff#L1063-L1103
- https://github.com/microsoft/playwright/blob/f11768436ae0888fa2cc0803eb7a79e0dedb7d5b/browser_patches/firefox/patches/bootstrap.diff#L778-L781
It would be great if we could support that as well.
Manually it can be reproduced with the following steps:
- Open
about:config
and setfocusmanager.testmode
totrue
- Load some web page
- Open a new window
- Open the browser toolbox and enable multi-process mode
- Select the original window with some web page as target
- Run
document.hasFocus()
in the console
With step 6 the document of the now background window has no focus but it should have.
Reporter | ||
Comment 1•13 days ago
•
|
||
Actually this is about the document to receive the focus and not about individual elements. So I'm updating the bug's summary.
The line of code that currently returns false
is:
https://searchfox.org/mozilla-central/rev/55706b888f91fffa6f045f7cbc1a7b1c34598292/dom/base/Document.cpp#4638-4640
if (!fm->IsInActiveWindow(bc)) {
return false;
}
return fm->IsSameOrAncestor(bc, fm->GetFocusedBrowsingContext());
Not sure if it would be ok to have a check for fm->IsTestMode()
added before, or if it could cause some side-effects.
Henry, do you have more details? Olli mentioned that you may still know more about the focus manager test mode these days. Thanks!
Unfortunately, I don't recall the specifics of the interaction here. My expectation is that unwanted side effects are likely, but to find out what those are, you need to try the change and experiment. Sorry.
Description
•