fix: re-apply download behavior on recording context (#1019)
* fix: re-apply download behavior on recording context record start creates a new browser context via Target.createBrowserContext. Browser.setDownloadBehavior called at launch only applies to the default context, so downloads in the recording context are silently dropped. Fix: 1. Store download_path on BrowserManager (from LaunchOptions) 2. After creating the recording context, call Browser.setDownloadBehavior with the new browserContextId This ensures downloads work during recording. Fixes #1018 * fix: add download_path to third BrowserManager constructor (auto_connect_cdp)
This commit is contained in:
@@ -3489,6 +3489,25 @@ async fn handle_recording_start(cmd: &Value, state: &mut DaemonState) -> Result<
|
||||
let new_session_id = attach_result.session_id.clone();
|
||||
mgr.enable_domains_pub(&new_session_id).await?;
|
||||
|
||||
// Re-apply download behavior to the recording context.
|
||||
// Without this, downloads in the recording context are silently dropped
|
||||
// because Browser.setDownloadBehavior at launch only applies to the default context.
|
||||
if let Some(ref dl_path) = mgr.download_path {
|
||||
let _ = mgr
|
||||
.client
|
||||
.send_command(
|
||||
"Browser.setDownloadBehavior",
|
||||
Some(json!({
|
||||
"behavior": "allow",
|
||||
"downloadPath": dl_path,
|
||||
"browserContextId": context_id,
|
||||
"eventsEnabled": true
|
||||
})),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
// Transfer cookies to new context
|
||||
if let Some(ref cr) = cookies_result {
|
||||
if let Some(cookie_arr) = cr.get("cookies").and_then(|v| v.as_array()) {
|
||||
|
||||
Reference in New Issue
Block a user