Skip to content

Implement upstream PR #14821: browser extensions API (#3404) - #3423

Closed
kblok wants to merge 1 commit into
masterfrom
fix-issue-3404
Closed

kblok wants to merge 1 commit into
masterfrom
fix-issue-3404

Conversation

@kblok

@kblok kblok commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

Implements upstream PR #14821 which adds browser extension management APIs, plus fixes a prerender navigation race condition discovered during testing.

Extensions API

  • Renames GetExtensionsAsync() → ExtensionsAsync() across IBrowser/Browser/CdpBrowser/BidiBrowser
  • Adds TriggerExtensionActionAsync(Extension) to IPage/Page/CdpPage
  • Adds extension-with-page test asset with popup and service worker background
  • Adds 6 new extension tests matching upstream cdp/extensions.spec: list extensions/properties, list workers, trigger action, activate popup page, extension pages
  • Adds Pipe = true to BrowserWithExtensionOptions for test stability
  • Adds AutoAttachFilter to ChromeTargetManager to exclude page targets from initial attach (matches upstream Filter option)

Target Handling

  • Filters CdpBrowser.Targets() to only return exposed, initialized targets (avoids exposing speculative/prerender targets)
  • Adds IsTargetExposed guard to OnTargetDestroyed/OnTargetCreated handlers

Prerender Navigation Race Fix

  • Root cause: Client_MessageReceived is async void — responseReceived CDP event arrives while requestWillBeSent is still awaiting GetFrameAsync, so OnResponseReceived finds no request and drops the response
  • Fix 1: In OnResponseReceived, when request is null, queue the response event instead of dropping it
  • Fix 2: In OnRequestAsync, after storing the request, check for a queued response and process it immediately before firing the Request event
  • Fix 3: In OnResponseReceivedExtraInfoAsync, when a queued group exists but the request isn't stored yet, save the extraInfo and leave the queued group for OnRequestAsync to handle
  • Adds FrameSwappedByActivation subscription and OnRequestServedFromCache handler to LifecycleWatcher

Test plan

  • Prerender tests: 6/6 pass (1 skipped for unrelated screencast reason)
  • Navigation tests: 67/67 pass
  • Network + RequestInterception tests: 154/154 pass
  • Extension tests: 9/9 pass
  • Page tests: 183/183 pass
  • Target tests: 20/20 pass
  • Build: 0 errors, 0 warnings

🤖 Generated with Claude Code

…r navigation race

- Renames GetExtensionsAsync() to ExtensionsAsync() across IBrowser/Browser/CdpBrowser/BidiBrowser
- Adds TriggerExtensionActionAsync(Extension) to IPage/Page/CdpPage
- Adds extension-with-page test asset and 6 new extension tests (ShouldListExtensionsAndTheirProperties, ShouldListExtensionWorkers, etc.)
- Adds extension Pipe=true option to BrowserWithExtensionOptions for stability
- Filters targets in CdpBrowser.Targets() to only exposed, initialized targets
- Adds AutoAttachFilter to ChromeTargetManager to exclude page targets from initial attach
- Fixes null check in FrameManager.SwapFrameTreeAsync for frame.OnFrameSwappedByActivation()
- Fixes prerender navigation: NetworkManager race condition where responseReceived CDP event arrives before requestWillBeSent is processed due to async GetFrameAsync. Queues the response event and processes it once the request is stored.
- Fixes secondary race in OnResponseReceivedExtraInfoAsync: when request not yet stored, saves extraInfo and leaves queued group intact for OnRequestAsync to handle
- Adds FrameSwappedByActivation subscription and OnRequestServedFromCache handler to LifecycleWatcher

Fixes: CanNavigateToAPrerenderedPageViaInput prerender test regression

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kblok

kblok commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

Closing: this was created in error. The fix has been applied directly to PR #3404 (branch implement-upstream-change-14821).

@kblok kblok closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant