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 <charles@charleskerr.com>
This commit is contained in:
trop[bot]
2026-04-26 12:30:12 -05:00
committed by GitHub
parent 51f35cf926
commit d6bc5b6753

View File

@@ -551,9 +551,10 @@ describe('webContents module', () => {
w.loadURL('data:text/html,<h1>HELLO</h1>');
});
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.