Repository navigation
[blazor] Synchronize navigation lock test with browser prompt updates - #70382
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the test-only change to synchronize navigation-lock checks with prompt registration.
No open issues 🎉
What changed in this PR
Hardens Blazor’s external-navigation lock E2E test against a browser/server synchronization race observed while investigating #70344. The change is test-only; shipping behavior is unchanged.
Changes:
- Installs a document-local observer before mounting the component to track completed navigation-prompt enable/disable calls.
- Waits for registration counts of 1, 2, 1, and 0 after checkbox changes.
- Preserves canceled-navigation checks and the final URL assertion without fixed sleeps or navigation retries.
| File | Description |
|---|---|
src/Components/test/E2ETest/Tests/RoutingTest.cs |
Adds prompt-registration observation and synchronization waits to NavigationLock_CanBlockExternalNavigation. |
Review effort: Balanced
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. Informational - unresolved quarantine follow-up: One arm noted that the Server-mode variant of Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block Human-directed and GitHub Copilot-generated. |
|
✅ No documentation PR was created. Confidence that documentation is needed: 2% No docs needed: the PR only hardens an E2E test against a timing race (tests/test infrastructure). Documentation surfaces considered
|
…pt updates (#70490) Backport of #70382. (cherry picked from commit f0e16a1) Co-authored-by: Marek Fišera <[email protected]> Co-authored-by: Copilot <[email protected]>
…pt updates (#70486) Backport of #70382. (cherry picked from commit f0e16a1) Co-authored-by: Marek Fišera <[email protected]> Co-authored-by: Copilot <[email protected]>
[blazor] Synchronize navigation lock test with browser prompt updates
Wait for completed browser prompt updates in the navigation lock E2E test.
Description
Harden
RoutingTest.NavigationLock_CanBlockExternalNavigationagainst a browser/server synchronization race observed while investigating #70344. Selenium completing a checkbox click does not mean Blazor Server has applied the corresponding navigation-prompt interop. If the final external navigation starts while the lastbeforeunloadlistener is still registered, ChromeDriver dismisses that prompt and cancels the navigation. Removing the listener afterward cannot restart the canceled navigation.Install test-local observation before mounting the component. Each wrapper calls the original prompt enable/disable function before updating the observed registration set. Wait for registration counts 1, 2, 1, and 0 after the respective checkbox changes, so navigation runs only after the synchronous browser listener updates have completed. Preserve both canceled-navigation assertions and the final URL assertion. No shipping code changes, fixed sleeps, or navigation retries.
The observer is document-local and installed before JSInterop first resolves the prompt functions. It relies on the existing enable/disable functions being synchronous.
Validation
On macOS ARM64 with the repository SDK/CoreCLR and Chrome for Testing 155, after
source activate.shand configuringTEST_CHROME_BINARY:dotnet build src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj --no-restore --nologo -v:quiet— passed, zero warnings/errors.dotnet test src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj --no-build --no-restore --filter 'FullyQualifiedName~NavigationLock_CanBlockExternalNavigation' --logger 'console;verbosity=normal'— passed for both Server and WebAssembly; ten independent paired runs passed all twenty test cases. An initial WebAssembly run was blocked before the changed scenario by missing local CustomElements JS build output; building the existing workspace and rebuilding resolved that prerequisite.dotnet test src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj --no-build --no-restore --filter 'FullyQualifiedName~NavigationLock_CanBlockExternalNavigation|FullyQualifiedName~ExternalNavigationIsLockedAfterPrerendering' --logger 'console;verbosity=normal'— passed all three tests, including the adjacent prerendered external-navigation control.git diff --check— passed.Before hardening, the unchanged Server test reproduced the reported final-URL failure on the same source snapshot. Linux Mono was not exercised locally; the exact failing CI interop ordering was not instrumented.
Fixes: N/A — no dedicated open issue identified; relates to the failure investigated on #70344.
Note
This PR description was generated with the assistance of GitHub Copilot.