ckerr

#54728: test: run focus-dependent specs serially

Merged
Created: Oct 7, 2026, 3:53:01 PM
Merged: Oct 8, 2026, 7:46:04 AM
5 comments
Target: main

Description of Change

Run the specs that need OS focus serially, and wait for focus where they assumed it.
Under the parallel runner, another worker's window can take focus away from them.

  • api-web-contents-view.spec.ts, "does not crash when closed via window.close()": waits for 'blur', which only fires if the view had focus.
    Contents only get initial focus in an active window.
  • api-web-frame-main.spec.ts, "keeps a single instance when mainFrame is touched from focus/blur during a cross-origin swap": needs the view focused before the swap.
    It now waits for isFocused() instead of assuming focus() is synchronous.
  • api-web-contents.spec.ts:
    • The win32 test "keeps the page focused when the window is re-activated while the prompt is pending" now waits for focus instead of sleeping 100 ms.
    • The setIgnoreMenuShortcuts(ignore) block sends real menu shortcuts.
      "honors the initial ignoreMenuShortcuts preference" now waits for focus before sending them.
      Downstream CI hits this test on 43-x-y and 44-x-y.
    • "reveals paths under a registered workspace folder without executing them" opens a real Finder or Explorer window, which takes focus and stays open.

All of these are tagged serial.
Only test code changes.

Validation

Ran on a local Linux testing build of main under Xvfb:

  • e test --files spec/api-web-contents-view.spec.ts spec/api-web-frame-main.spec.ts spec/api-web-contents.spec.ts -g "does not crash when closed via window.close|keeps a single instance when mainFrame is touched|setIgnoreMenuShortcuts": 7 passed in the serial phase, and 3 of 3 runs passed.
  • The win32 and non-Linux tests aren't exercised on Linux.
  • script/lint.js --js and tsc -p tsconfig.spec.json pass.

🤖 Generated with Claude Code

Checklist

Release Notes

Notes: none

Backports

42-x-y
Pending
Waiting for a manual backport
43-x-y
Pending
Waiting for a manual backport
44-x-y
Merged
PR Number
#54745
Merged At
Oct 8, 2026, 8:56:17 AM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#54746
Merged At
Oct 8, 2026, 8:56:37 AM
Released In
v45.0.0-beta.1
Release Date
Oct 8, 2026, 7:07:44 PM

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

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