The headless browser for AI agents and web scraping
fix(cdp): route lifecycle subscriptions through stateful dispatch
SGavrlde227e911f26
diff --git a/crates/obscura-cdp/src/server.rs b/crates/obscura-cdp/src/server.rsindex cdb92d9d..f438cd4c 100644--- a/crates/obscura-cdp/src/server.rs+++ b/crates/obscura-cdp/src/server.rs@@ -1934,7 +1934,7 @@ fn fast_path_response(text: &str) -> Option<String> {let result = match req.method.as_str() {"Network.enable" | "Network.setCacheDisabled" | "Network.setRequestInterception" |- "Page.setLifecycleEventsEnabled" | "Page.setInterceptFileChooserDialog" |+ "Page.setInterceptFileChooserDialog" |"Runtime.runIfWaitingForDebugger" | "Runtime.discardConsoleEntries" |"Performance.enable" | "Log.enable" | "Security.enable" |"Emulation.setTouchEmulationEnabled" |@@ -2066,6 +2066,20 @@ mod tests {use serde_json::json;use std::collections::HashMap;+ #[test]+ fn lifecycle_subscription_commands_reach_the_stateful_dispatcher() {+ for enabled in [true, false] {+ let request = json!({+ "id": 1,+ "method": "Page.setLifecycleEventsEnabled",+ "params": {"enabled": enabled},+ "sessionId": "page-session",+ });+ assert!(super::fast_path_response(&request.to_string()).is_none(),+ "lifecycle subscriptions must not be acknowledged without updating state");+ }+ }+fn native_head(host: &str) -> String {format!("GET /devtools/browser HTTP/1.1\r\nHost: {host}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n\r\n"