diff --git a/src/browser/callback_host.rs b/src/browser/callback_host.rs index 6d18b0f..2dd8a5d 100644 --- a/src/browser/callback_host.rs +++ b/src/browser/callback_host.rs @@ -1162,6 +1162,38 @@ mod tests { ); } + #[test] + fn live_callback_host_hidden_domain_sends_hide_open_page_command() { + let (ws_url, frames, handle) = start_fake_browser_status_server(); + + let result = LiveBrowserCallbackHost::start_with_browser_ws_url( + &ws_url, + "https://www.zhihu.com", + Duration::from_millis(100), + Duration::from_millis(50), + true, + ); + assert!(result.is_err(), "expected timeout because no real helper page loads"); + drop(result); + handle.join().unwrap(); + + let sent = frames.lock().unwrap().clone(); + assert!( + sent.iter().any(|frame| frame.contains("sgHideBrowerserOpenPage")), + "hidden domain bootstrap should send sgHideBrowerserOpenPage; sent frames: {sent:?}" + ); + assert!( + !sent.iter().any(|frame| { + frame.contains("\"sgBrowerserOpenPage\"") + }), + "hidden domain bootstrap should NOT send visible sgBrowerserOpenPage; sent frames: {sent:?}" + ); + assert!( + sent.iter().any(|frame| frame.contains("/sgclaw/browser-helper.html")), + "bootstrap should include the helper page URL; sent frames: {sent:?}" + ); + } + #[test] fn live_callback_host_treats_simulated_mouse_command_as_fire_and_forget() { use crate::browser::callback_backend::{