You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement upstream PR #14821: browser extensions API (#3404)
* Implement upstream PR #14821: browser extensions API
Ports puppeteer/puppeteer#14821 to PuppeteerSharp.
- Rename GetExtensionsAsync to ExtensionsAsync (IBrowser, Browser,
CdpBrowser, BidiBrowser, IsolatedWorld) to match upstream naming.
- Add TriggerExtensionActionAsync abstract method (IPage, Page,
CdpPage; BidiPage throws NotSupportedException).
- Filter extension targets in CdpBrowser.Targets() and target event
handlers via IsTargetExposed.
- Use AsPageAsync (with try/catch for closed targets) in
CdpExtension.PagesAsync.
- Add ExtensionsTests covering the new API surface.
- Add extension-with-page test asset (background.js, manifest.json,
popup.html).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: wire tab->page session hierarchy and fix prerender swap hang
Extensions.triggerAction expects a tab target id, but Page._tabId was
falling back to the page's own session because pages auto-attached at
the connection level. Adding `{type:'page', exclude:true}` to the
browser-level setAutoAttach matches upstream and routes pages through
their owning tab session, so TabId is now correct.
That change exposed two latent bugs:
- Prerender activation re-emits a navigation request on the new session
but never produces an HTTP response, so LifecycleWatcher hung waiting
on _navigationResponseReceived. FrameSwapped now resolves it.
- Connection.Dispose can be re-entered from the Disconnected callback
while a message is mid-flight, deadlocking on the TaskQueue
semaphore. Bounded the dispose wait to 1s; in-flight tasks already
tolerate a disposed semaphore.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: don't force DevTools tab target to Type=Other; sync TargetManager test
With the previous commit's filter, tab targets auto-attach. The DevTools
tab target's URL matches isDevToolsPageTarget so we wrap it as a
CdpDevToolsTarget — and that class hard-overrode Type to TargetType.Other,
making Targets()/PagesAsync() treat the tab as a page, then try to send
Page.enable on a tab session. Removing the override matches upstream
(DevToolsTarget extends PageTarget with no type override).
ShouldHandleTargets was written for the pre-filter world where tabs
weren't attached. Synced it to upstream's version, which accounts for the
tab/page pair on each new page.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments