Repository navigation
fix(downloads)!: set download behavior per context over the browser session - #753
Merged
Merged
Conversation
…ession Chrome applies Browser.setDownloadBehavior to a whole context, but Ferrum sent it from page sessions: only the page that set it got download events, every new page reset the path to :save_path, closing that page reset the behavior, and without :save_path no download was ever tracked. Contexts now set it over the browser session when they're created, receive every download event there and route each one to the context and the page whose frame started it, or to the opener of a popup we never connected to. set_behavior moves to context.downloads and browser.downloads, takes :allow_and_name, and needs save_path: only to allow downloads. page.downloads keeps the page's own downloads.
route
force-pushed
the
fix/download-behavior
branch
from
November 30, 2026 11:07
2a6bfed to
b43ac6d
Compare
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.
Chrome applies
Browser.setDownloadBehaviorto a whole context, but Ferrum sent it from page sessions, so:await_downloadreturnednil;:save_path, undoing an earlierset_behavior;:save_pathno download was tracked at all.Now contexts set it over the browser session when they're created, which outlives every page and receives the download events of the whole context. Each event is routed to the context and to the page whose frame started it, or to the opener of a popup we never connected to, as Playwright does. Without
:save_pathcontexts get Chrome'sdefaultbehavior with events on, so downloads show up ascanceled?instead of never.API
context.downloadslists and awaits the downloads of every page in the context and ownsset_behavior.browser.downloadsis the default context's.page.downloads(Ferrum::Page::Downloads) lists and awaits only the page's own downloads, popups it opened included.Breaking:
page.downloads.set_behavioris removed, usecontext.downloadsorbrowser.downloads.browser.downloadsis the default context's, not the page's.:allowAndNameis:allow_and_name.save_path:is required only for:allowand:allow_and_name.