Repository navigation
fix(downloads): respect BrowserProfile.accept_downloads - #6067
Open
marcardenas wants to merge 2 commits into
Open
marcardenas wants to merge 2 commits into
marcardenas wants to merge 2 commits into
Conversation
…6065) The downloads watchdog always set Browser.setDownloadBehavior to 'allow' and auto-downloaded PDFs, so accept_downloads=False had no effect. When downloads are disabled, set the behavior to 'deny' and skip PDF auto-download and network download monitoring. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
View guided diff | Re-trigger cubic
…review) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6065
Problem
BrowserProfile.accept_downloadsis never read. The downloads watchdog always callsBrowser.setDownloadBehaviorwithbehavior: 'allow', and PDF/network auto-download runs regardless, soaccept_downloads=Falsestill saves files.Change
In
DownloadsWatchdog:accept_downloads=False,attach_to_targetsetsBrowser.setDownloadBehaviortodeny(once per browser session) instead ofallow, and skips the download listeners;_is_auto_download_enabled()now requires bothaccept_downloadsandauto_download_pdfs, so PDF viewer auto-download and network-response downloads can't bypass the setting.Default behavior (
accept_downloads=True) is unchanged.Tests
tests/ci/browser/test_accept_downloads.py: launches a real headless Chromium against a localpytest-httpserverand checks the downloads directory:Content-Disposition: attachment) is saved withaccept_downloads=True;accept_downloads=False(fails onmain, passes with this change);accept_downloads=False(fails onmain, passes with this change).tests/ci/test_remote_download_complete_callback.py: theSimpleNamespaceprofile stub now carriesaccept_downloads=True(the real default), since the watchdog reads it.tests/ci/test_downloads_watchdog.py,test_agent_download_paths.py,test_remote_download_complete_callback.py,browser/test_session_start.py, and the new file: 22 passed.ruff check,ruff format --checkandpyrightclean on the touched files.Note on #5991
I found #5991 after implementing this; it addresses the same root cause with unit-level tests. This PR differs mainly in the end-to-end Chromium regression test. Happy to close this in favor of #5991, or to move the integration test over there, whichever the maintainers prefer.
AI assistance: prepared with Claude Code; I reviewed the diff and ran the tests above.
🤖 Generated with Claude Code
Summary by cubic
Fixes #6065.
BrowserProfile.accept_downloadswas never read, so files were always saved even when downloads were disabled. Now, withaccept_downloads=False, the browser refuses downloads and PDF auto-download no longer bypasses the setting. Default behavior (accept_downloads=True) is unchanged.Bug Fixes
Browser.setDownloadBehaviorwithdenyper browser session, before anydownloads_pathcheck, so a profile without a path can't fall back to the browser default.accept_downloadsandauto_download_pdfs.accept_downloads=True, and that neither is saved when downloads are disabled.Written for commit 2dc81de. Summary will update on new commits.