Repository navigation
Add the online and offline events to Microsoft.AspNetCore.Components.Platform - #70530
jsakamotoIGJP wants to merge 4 commits into
Conversation
|
Thanks for your PR, @jsakamotoIGJP. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🟡 Changes recommended
Repeated Watch clicks overwrite registration handles without removing earlier listeners, so Stop watching and component disposal leave callbacks active; registration reuse or cleanup and overlap protection are needed.
1 open issue
What changed in this PR
Adds typed online and offline window events to Components.Platform, extending the browser-context APIs through the existing event-listener infrastructure.
Changes:
- Adds
Window.OnlineEvent,Window.OfflineEvent, and an emptyEventpayload type. - Documents Interactive Server delivery limitations and updates the public API baseline.
- Adds demo controls, unit coverage, and browser tests for event delivery, listener removal, and WebAssembly network changes.
| File | Description |
|---|---|
| src/Components/Platform/testassets/PlatformTestApp.E2E.Tests/Tests/NavigatorTests.cs | Tests event delivery, removal, and browser network transitions. |
| src/Components/Platform/testassets/PlatformTestApp.Client/Components/NavigatorDemo.razor | Adds listener controls and event-status output. |
| src/Components/Platform/test/NavigatorTest.cs | Checks event names, payload shapes, and callbacks. |
| src/Components/Platform/src/WindowNavigatorExtensions.cs | Defines event keys and documents server limitations. |
| src/Components/Platform/src/PublicAPI.Unshipped.txt | Records the new public API surface. |
| src/Components/Platform/src/Event.cs | Defines the empty event payload type. |
Review effort: Balanced
|
/review |
PureWeen
left a comment
There was a problem hiding this comment.
[UNRESOLVED] New event tests use Playwright rather than the prescribed Components Selenium surface.
At 593d2d4ae4f3bb05452e38193075309cebeaaeb4, one local review arm raised this concern about src/Components/Platform/testassets/PlatformTestApp.E2E.Tests/Tests/NavigatorTests.cs:71. Its verifier returned DROP/unestablished: the repository policy establishes a suite mismatch, but no missed defect or corresponding red/green assertion evidence was established. The other two arms raised no new findings. This is not a request to move the tests.
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.
A second Watch click no longer adds another pair of online and offline listeners, and Stop removes listeners that are still being added.
|
Thanks for the review. About the note on Playwright, I'd like to keep the new tests in |
|
/review |
There was a problem hiding this comment.
Source-only review of frozen head 67eba201c60fe6e03c6821ab3b8bd6117d9b9645.
One candidate is published inline as unresolved, not as a verified defect: the source establishes that a first registration-task fault skips peer cleanup, but the selective browser/interop failure and subsequent callback delivery require external or immutable validation evidence that is not in the bundle.
Both routed guides completed with gpt-5.6-sol: CrossCuttingGuidance covered API compatibility, async/disposal, trimming, diagnostics, and tests; BlazorComponentsGuidance covered hosting modes, event/JS flow, renderer synchronization, disposal, and browser coverage. Execution of PR code, tests, CI, browser workflows, and samples was excluded; security assessment was excluded by repository guidance. Public API approval and contribution-process metadata remain unresolved human/process evidence.
Existing feedback already covers the Playwright-versus-Components-Selenium permanent-test-surface concern (review 5872006054), so it was not repeated. The earlier duplicate-registration concern (inline thread 4548177054) is addressed at this head by retaining pending/completed tasks with ??=.
No materially changed area was left without a routed guide. Proof is limited to tracked frozen source at head, merge base 9ea8a84d9c7c1a63256d2256969d5a6c66103d83, base tip/guidance commit 59835e6087e90b972a905dc303523cfbb5d828ef, the frozen diff, and feedback prepared before this review. No fresh-feedback check or runtime validation was performed; symlink, submodule, and LFS targets are inert and unavailable.
Generated by ASP.NET Core Pull Request Review for #70530 · copilot · gpt56 · 162.6 AIC · ⌖ 12.4 AIC · ⊞ 18.8K
Comment /review to run again
|
Copilot's local review panel found no issues to raise at this commit. All three local arms completed at [UNRESOLVED] Interactive Server offline events may retain pending JS interop calls while disconnected. One arm raised this diagnostic against 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. |
|
Thanks for the note on Interactive Server. I checked this case locally, and the |
…nline-events # Conflicts: # src/Components/Platform/src/Event.cs
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |

Add the online and offline events to Microsoft.AspNetCore.Components.Platform
Description
This implements the API proposal #70529, a part of the browser context family (#69872). The proposal explains the public API. This description covers the implementation.
Nothing new below the public API
The two keys are created with the existing
EventTypes.Create, asWindow.StorageEventis.Window.AddEventListenerAsync, the event listener collection, andPlatform.tsdo not change.The shape
[{}]tellsPlatform.tsto copy no property of the event object. So the listener receives an emptyEvent, and no JS object reference is created for the browser event.Trimming
The keys are static fields of
WindowNavigatorExtensions, asWindow.StorageEventis a static field ofWindowWebStorageExtensions. I checked two trimmed WebAssembly apps.Window.Navigator.GetLanguageAsync(), the keys,Event, and the whole event listener code were removed. ReadingWindow.Navigatordoes not run the static initializer of the keys.onlinelistener,Navigatorand theOfflineEventproperty were removed. The_offlineEventfield stays, because the static initializer creates both keys. That is one small object, the same as withWindow.StorageEvent.Interactive Server
The XML docs of both keys say that the events are of little use in Interactive Server. I checked this with a temporary E2E test, not in this PR, that wraps
WebSocketin the page so that a lost network behaves as it would with a remote server. Playwright's offline mode alone does not stop a WebSocket tolocalhost.offlinelistener ran only after the browser was online again, just before theonlinelistener.onlinebefore Blazor reconnected, andCircuitManager.beginInvokeDotNetFromJSsends on the current connection without queuing the call. The circuit itself reconnected and worked again.Tests
Event.onlineandofflinefrom the page's own JavaScript in both render modes, and check that a removed listener receives nothing. They use the same result marker as the other tests, so a step cannot pass on the text of the previous step.onLinetest.dotnet publish.Contributes to #70529
Contributes to #69872