Skip to content

[blazor] Synchronize navigation lock test with browser prompt updates - #70382

Merged
maraf merged 1 commit into
mainfrom
maraf-navigation-lock-test-failure
Nov 10, 2026
Merged

maraf merged 1 commit into
mainfrom
maraf-navigation-lock-test-failure

Conversation

@maraf

@maraf maraf commented Nov 7, 2026

Copy link
Copy Markdown
Member

[blazor] Synchronize navigation lock test with browser prompt updates

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Wait for completed browser prompt updates in the navigation lock E2E test.

Description

Harden RoutingTest.NavigationLock_CanBlockExternalNavigation against 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 last beforeunload listener 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.sh and configuring TEST_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.

@maraf maraf self-assigned this Nov 7, 2026
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Nov 7, 2026
@maraf
maraf marked this pull request as ready for review November 7, 2026 14:45
@maraf
maraf requested a review from a team as a code owner November 7, 2026 14:45
Copilot AI balanced review requested due to automatic review settings November 7, 2026 14:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@PureWeen

PureWeen commented Nov 9, 2026

Copy link
Copy Markdown
Member

/review

@PureWeen

PureWeen commented Nov 9, 2026

Copy link
Copy Markdown
Member

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 NavigationLock_CanBlockExternalNavigation remains quarantined for #66041 on the reviewed base tip. The verifier rejected the incomplete-fix claim (DROP/unestablished): the quarantine came from the base branch, and no requirement was found for this PR to remove it. This is not a confirmed defect or a request for changes.

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 agent-reviewed-approved.

Human-directed and GitHub Copilot-generated.

@dariatiurina dariatiurina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@maraf
maraf merged commit f0e16a1 into main Nov 10, 2026
41 checks passed
@maraf
maraf deleted the maraf-navigation-lock-test-failure branch November 10, 2026 11:05
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:05 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:05 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:06 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:08 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:09 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 10, 2026 11:09 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

✅ 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

  • Conceptual article: Not required — Test-only change to a Blazor E2E test; no user-visible behavior or API change.
  • Migration guidance: Not required — No upgrade-relevant behavior or defaults changed.
  • Breaking change: Not required — No compatibility impact; no shipping code changed.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — d54540ed Deployed Nov 10, 2026 by maraf via conclusion #265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewed-approved area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants