Repository navigation
test: wait for navigation to settle in loadURL tests - #51579
Conversation
deepak1556
left a comment
There was a problem hiding this comment.
The tests added in https://github.com/electron/electron/pull/48004/changes with goal that we actually don't trigger a secondary navigation and abort earlier with the did-fail-load event, either the fix is incomplete or it should be incorrect that there is a secondary navigation from these tests. Could we confirm the source ?
6f85824 to
a7dc509
Compare
You're right, the secondary navigation was a red herring. Waiting for navigation to settle was still the right answer, but not for the reason I described. I've revised the branch and the PR description. |
The three reentrant loadURL tests could call done() while the primary navigation was still in-flight. When the reentrant loadURL call is rejected by the guard in WebContents::LoadURL(), it emits did-fail-load synchronously. If the test exits on did-fail-load alone, the afterEach() call to closeAllWindows() can destroy the window while that primary navigation still has in-flight events. Fix by using Promise.all() to wait for both did-fail-load and did-stop-loading before the test exits, ensuring the primary navigation has fully settled. The tests are also converted from done-callback style to async/await for clarity. Co-authored-by: GitHub Copilot <[email protected]>
a7dc509 to
c483daa
Compare
deepak1556
left a comment
There was a problem hiding this comment.
Thanks!
The PR description could use some update to match the latest commit description.
Done. I thought I'd done that yesterday, but apparently my mouse didn't find the "Update comment" button 😵 |
|
No Release Notes |
|
I have automatically backported this PR to "40-x-y", please check out #51641 |
|
I have automatically backported this PR to "41-x-y", please check out #51642 |
|
I have automatically backported this PR to "43-x-y", please check out #51643 |
|
I have automatically backported this PR to "42-x-y", please check out #51644 |
Description of Change
Followup to #51315, which was a partial fix but missed another way for these tests to break.
The three
loadURL()tests could calldone()while the primary navigation was still in-flight. When the secondloadURL()call is rejected by the guard inWebContents::LoadURL(), it emitsdid-fail-loadsynchronously. If the test exits ondid-fail-loadalone, theafterEach()call tocloseAllWindows()can destroy the window while that primary navigation still has in-flight events.Fix by using
Promise.all()to wait for bothdid-fail-loadanddid-stop-loadingbefore the test exits, ensuring the primary navigation has fully settled.Sample log of this failure, seen in a downstream CI run for
v41.5.1:Checklist
npm testpassesRelease Notes
Notes: none