From d6bc5b67535c8d5a463512b011bd1221150140ec Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sun, 26 Apr 2026 12:30:12 -0500 Subject: [PATCH] test: fix race in reentrant `loadURL()` ready-to-commit test (#51323) test: fix race in reentrant loadURL() ready-to-commit test Fix 'fails if loadurl is called after the navigation is ready to commit' by using a done() callback to ensure the test waits for did-fail-load before exiting. Previously, the test would return and call afterEach(closeAllWindows), potentially destroying the window while navigation was in flight. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- spec/api-web-contents-spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 3098541792..879b3f0617 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -551,9 +551,10 @@ describe('webContents module', () => { w.loadURL('data:text/html,

HELLO

'); }); - it('fails if loadurl is called after the navigation is ready to commit', () => { + it('fails if loadurl is called after the navigation is ready to commit', (done) => { w.webContents.once('did-fail-load', (_event, _errorCode, _errorDescription, validatedURL) => { expect(validatedURL).to.contain('blank.html'); + done(); }); // @ts-expect-error internal-only event.