#56045: test: fix flaky fullscreen load and child WebContentsView focus specs
Description of Change
Two BrowserWindow specs started failing jobs once retry: 0 landed for api-browser-window.spec.ts (#56022):
should be able to load a URL while transitioning to fullscreen (macOS, MAS arm64 on main and on the 46-x-y backport)
This is the only fullscreen spec that asks for fullscreen from the constructor, before the window is shown. NativeWindowMac::SetFullScreen marks the window as mid-transition and calls [super toggleFullScreen:] on the hidden window. If AppKit drops that request without a will-enter or did-fail callback, enter-full-screen never fires. The window then stays marked as mid-transition, so any later setFullScreen call is only queued behind it. Leaving the parent's fullscreen in the borderless-child spec (#56022) was not enough; the spec still timed out right after it (job).
The likely trigger is that the app isn't active when the window is created: an earlier fullscreen spec can leave another app frontmost (see #55230). Specs that go fullscreen after showing their window activate the app first. The spec now:
- waits until
app.isActive()is true, callingapp.focus({ steal: true })until it is, before creating the window; - registers its listeners before
loadFile; - fails after 15s with which events arrived, plus
isFullScreen()andapp.isActive(), instead of a bare 30s timeout. If the activation explanation is wrong, the next failure will say why.
keeps focus in a child WebContentsView when the window regains focus (Linux)
On 44-x-y this failed on linux-arm64, including the end-of-job isolated re-run (job). child.webContents.isFocused() was false right after await refocused, though it used to pass on an in-file retry. The spec read focus at the instant the window's focus event fired. On X11 the activation Electron reports and the views focus restore can land in separate tasks. The spec now waits up to 5s for the child to have focus back, then asserts { child: true, primary: false } in one assertion. If focus really ends up in the primary webContents, it still fails and the message shows where focus went.
Neither failure reproduces locally, so both fixes are untested until this PR's CI runs.
Checklist
- I have filled out the PR description
- I have reviewed and verified the changes
- tests are changed or added
🤖 Generated with Claude Code
Notes: none
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron