Problem
Session-scoped CDP settings are applied individually at browser launch and must be manually re-applied whenever a new CDP session is created (e.g., record start). This is error-prone — each new session-scoped setting requires a matching re-application in every code path that creates a new session, and omissions cause silent failures.
#1178 fixed this for Security.setIgnoreCertificateErrors, matching the earlier fix for Browser.setDownloadBehavior. But two other launch-time settings have the same gap today:
| Setting |
Applied at launch |
Re-applied to recording context |
Emulation.setUserAgentOverride (--user-agent) |
Yes (browser.rs:302) |
No |
Emulation.setEmulatedMedia (--color-scheme) |
Yes (browser.rs:313) |
No |
Any future session-scoped setting added to launch() will silently break in recording contexts unless someone remembers to add the corresponding re-application in handle_recording_start.
Proposed fix
Extract a single apply_session_settings(&self, session_id) method on BrowserManager that applies all session-scoped settings (ignore_https_errors, user_agent, color_scheme, and any future additions). Call it from both:
launch() — after initial target discovery
handle_recording_start() — after attaching to the new recording session
This eliminates the duplication and ensures new settings are automatically covered in all contexts.
Scope
- Store
user_agent: Option<String> and color_scheme: Option<String> on BrowserManager (same pattern as ignore_https_errors and download_path)
- Create
apply_session_settings that applies all session-scoped CDP commands
- Replace the inline calls in
launch() and handle_recording_start() with a single call to the new method
- Add a code comment on the method noting that any new session-scoped CDP setting should be added here
Context
Problem
Session-scoped CDP settings are applied individually at browser launch and must be manually re-applied whenever a new CDP session is created (e.g.,
record start). This is error-prone — each new session-scoped setting requires a matching re-application in every code path that creates a new session, and omissions cause silent failures.#1178 fixed this for
Security.setIgnoreCertificateErrors, matching the earlier fix forBrowser.setDownloadBehavior. But two other launch-time settings have the same gap today:Emulation.setUserAgentOverride(--user-agent)browser.rs:302)Emulation.setEmulatedMedia(--color-scheme)browser.rs:313)Any future session-scoped setting added to
launch()will silently break in recording contexts unless someone remembers to add the corresponding re-application inhandle_recording_start.Proposed fix
Extract a single
apply_session_settings(&self, session_id)method onBrowserManagerthat applies all session-scoped settings (ignore_https_errors,user_agent,color_scheme, and any future additions). Call it from both:launch()— after initial target discoveryhandle_recording_start()— after attaching to the new recording sessionThis eliminates the duplication and ensures new settings are automatically covered in all contexts.
Scope
user_agent: Option<String>andcolor_scheme: Option<String>onBrowserManager(same pattern asignore_https_errorsanddownload_path)apply_session_settingsthat applies all session-scoped CDP commandslaunch()andhandle_recording_start()with a single call to the new methodContext
ignore_https_errors