Skip to content

fix(browser): honor accept_downloads=False for CDP and fetch downloads - #6195

Open
ninglinLiu wants to merge 5 commits into
browser-use:mainfrom
ninglinLiu:fix/honor-accept-downloads-false
Open

ninglinLiu wants to merge 5 commits into
browser-use:mainfrom
ninglinLiu:fix/honor-accept-downloads-false

Conversation

@ninglinLiu

@ninglinLiu ninglinLiu commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

BrowserProfile.accept_downloads was documented and plumbed through session/beta APIs, but DownloadsWatchdog.attach_to_target always called CDP Browser.setDownloadBehavior with behavior: 'allow'. Setting accept_downloads=False therefore still accepted downloads for local CDP sessions.

Changes

  • Set CDP download behavior to deny when accept_downloads is false (keep allow as the default).
  • Treat accept_downloads=False as disabling network auto-fetch (_is_auto_download_enabled and download_file_from_url).
  • Add unit tests covering deny/allow CDP params, fetch skip, and auto-download gating.

Test plan

  • uv run pytest tests/ci/test_accept_downloads_false.py -q -o addopts='' --noconftest (4 passed)

Fixes #6065


Summary by cubic

Fixes BrowserProfile.accept_downloads=False having no effect: CDP Browser.setDownloadBehavior always passed behavior: 'allow', so local sessions still accepted downloads despite the flag. It now passes 'deny' when the flag is false and disables network auto-fetch and download_file_from_url the same way.

Written for commit 8f68af8. Summary will update on new commits.

View guided diff

Browser.setDownloadBehavior always used behavior=allow, so accept_downloads=False
had no effect for local CDP sessions. Deny downloads when the flag is false, gate
network auto-fetch the same way, and add regression tests.

Fixes browser-use#6065
@mintlify

mintlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 8f68af8.

Approve preview

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/ci/test_accept_downloads_false.py Resolved
ninglinLiu and others added 3 commits October 24, 2026 07:19
…load test

Keep an explicit AsyncMock for setDownloadBehavior so pyright sees
assert_awaited/await_args, collapse the ruff-format one-liner, and set
accept_downloads=True on the remote-download SimpleNamespace profile so
attach_to_target still reaches the progress-handler path.
Returning None is also the fetch-failure path. Require that
get_or_create_cdp_session was not awaited so the regression covers the
early return.

Co-authored-by: NingLin Liu <[email protected]>
Narrow await_args None checks and isinstance(AsyncMock) so
code-style/type-checker pass on the strengthened CDP-skip assert.

This branch has not been deployed

No deployments
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.

Bug: Browser parameter accept_downloads is nonfunctional when running Browser-use locally

2 participants