Skip to content

fix(chromium): gracefully handle unsupported Browser.setDownloadBehavior on CDP#40264

Closed
geun9716 wants to merge 2 commits intomicrosoft:mainfrom
geun9716:fix/handle-unsupported-setDownloadBehavior
Closed

fix(chromium): gracefully handle unsupported Browser.setDownloadBehavior on CDP#40264
geun9716 wants to merge 2 commits intomicrosoft:mainfrom
geun9716:fix/handle-unsupported-setDownloadBehavior

Conversation

@geun9716
Copy link
Copy Markdown

Motivation

When connecting to a remote browser via CDP (--cdp option), some embedded Chromium-based browsers do not implement the full Chrome DevTools Protocol. One common example is LG webOS TV, which exposes a remote Web Inspector via CDP but does not support Browser.setDownloadBehavior.

Currently, Playwright sends Browser.setDownloadBehavior unconditionally during CRBrowserContext.initialize(). If the remote browser rejects this command, the entire CDP connection fails with:

Error: Protocol error (Browser.setDownloadBehavior): Browser context management is not supported.

This blocks any use of Playwright for debugging, testing, or automation on these devices, even though download behavior management is irrelevant in that context.

Change

File: packages/playwright-core/src/server/chromium/crBrowser.ts

In CRBrowserContext.initialize(), catch the ProtocolError from Browser.setDownloadBehavior using the existing isProtocolError utility and match on e.method, then log at debug level. Any other unexpected errors are re-thrown.

Tested On

LG webOS TV (Cast shell remote debugging via CDP)

  • Before: playwright-cli attach --cdp=http://<TV_IP>: fails with Protocol error (Browser.setDownloadBehavior)
  • After: Successfully connects; snapshot, eval, click, navigation all work correctly

Standard Chrome (desktop) - No behavior change, download tests pass as before

references #40263

= and others added 2 commits April 15, 2026 09:16
…ior on CDP connect

- add exception handling on Browser.setDownloaBehavior to avoid on
  specific platform
@yury-s
Copy link
Copy Markdown
Member

yury-s commented Apr 17, 2026

#40185 is a better fix.

@yury-s yury-s closed this Apr 17, 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.

2 participants