test: run WebContentsView focusOnNavigation and shell.openExternal specs serially (#54662)

* test: wait for focus event in WebContentsView focusOnNavigation spec

The WebContentsView focusOnNavigation block was not tagged serial, unlike
the equivalent block in api-web-contents.spec.ts. On macOS another
parallel worker (notably the shell.openExternal specs, which bring the
default browser to the front) can take app activation away mid-test.
The window then stops being key, ReadyToCommitNavigation skips focusing
because the owner window is inactive, and isFocused() returns false.

Run the block in the serial phase, and wait for the webContents 'focus'
event after navigating instead of checking isFocused() as soon as
loadURL resolves.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1mwQWDtyUGtjT3hFLoqms

* test: run shell.openExternal specs serially

On macOS the shell.openExternal specs launch the default browser and bring
it to the front. While they ran in the parallel phase, that took app
activation away from focus-sensitive specs in other workers (for example
the WebContentsView focusOnNavigation spec on macOS x64). Run them in the
serial phase so nothing else is running when the browser activates.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1mwQWDtyUGtjT3hFLoqms

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
claude[bot]andClaude Opus 5.5 authored and GitHub committed 2026-10-07 00:48:41 +00:00
1 parent 1a50ea1cb7
commit 6abd6a31bf
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ import { ifdescribe, ifit, listen } from './lib/spec-helpers.ts';
import { closeAllWindows } from './lib/window-helpers.ts';
describe('shell module', () => {
describe('shell.openExternal()', () => {
describe('shell.openExternal()', { tags: ['serial'] }, () => {
let envVars: Record<string, string | undefined> = {};
let server: http.Server;
+3 -1
View File
@@ -603,7 +603,7 @@ describe('WebContentsView', () => {
});
});
describe('focusOnNavigation webPreference', () => {
describe('focusOnNavigation webPreference', { tags: ['serial'] }, () => {
it('focuses the webContents on navigation by default', async () => {
const w = new BrowserWindow();
await once(w, 'focus');
@@ -614,7 +614,9 @@ describe('WebContentsView', () => {
v.webContents.openDevTools({ mode: 'right' });
await devToolsFocused;
expect(v.webContents.isFocused()).to.be.false();
const focused = once(v.webContents, 'focus');
await v.webContents.loadURL('data:text/html,<body>test</body>');
await focused;
expect(v.webContents.isFocused()).to.be.true();
});