| 1 | mod common; |
| 2 | |
| 3 | use std::time::Duration; |
| 4 | |
| 5 | use browser::{App, BrowserEvent, LoginState, Mode, RendererState, Watchdog, WatchdogConfig}; |
| 6 | use common::harness; |
| 7 | use tokio::sync::mpsc::Receiver; |
| 8 | |
| 9 | const TEAMS: &str = "https://teams.cloud.microsoft/"; |
| 10 | const OUTLOOK: &str = "https://outlook.office.com/mail/"; |
| 11 | const PARKED_TEAMS: &str = "https://teams.cloud.microsoft/robots.txt"; |
| 12 | const PARKED_OUTLOOK: &str = "https://outlook.cloud.microsoft/owa/favicon.ico"; |
| 13 | const LOGIN: &str = "https://login.microsoftonline.com/common/oauth2/authorize?client_id=x"; |
| 14 | |
| 15 | async fn next_event(events: &mut Receiver<BrowserEvent>) -> BrowserEvent { |
| 16 | tokio::time::timeout(Duration::from_secs(30), events.recv()) |
| 17 | .await |
| 18 | .expect("no event within 30s") |
| 19 | .expect("channel closed") |
| 20 | } |
| 21 | |
| 22 | fn fast_watchdog() -> WatchdogConfig { |
| 23 | WatchdogConfig { |
| 24 | poll_interval: Duration::from_millis(50), |
| 25 | initial_backoff: Duration::from_millis(50), |
| 26 | max_backoff: Duration::from_millis(200), |
| 27 | died_wait: Duration::from_millis(30), |
| 28 | probe_interval: Duration::from_millis(50), |
| 29 | probe_failures: 2, |
| 30 | login_grace: Duration::ZERO, |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | #[tokio::test] |
| 35 | async fn status_of_a_down_browser() { |
| 36 | let harness = harness().await; |
| 37 | let status = harness.browser.status().await.unwrap(); |
| 38 | assert!(!status.running); |
| 39 | assert!(status.tabs.is_empty()); |
| 40 | assert_eq!(status.login_state, LoginState::Unknown); |
| 41 | } |
| 42 | |
| 43 | #[tokio::test] |
| 44 | async fn status_of_a_running_browser_reads_mode_file_and_tabs() { |
| 45 | let harness = harness().await; |
| 46 | harness.mock.start(&[TEAMS, OUTLOOK]).await; |
| 47 | std::fs::write(&harness.mode_file, "headless").unwrap(); |
| 48 | let status = harness.browser.status().await.unwrap(); |
| 49 | assert!(status.running); |
| 50 | assert_eq!(status.mode, Mode::Headless); |
| 51 | assert_eq!(status.tabs.len(), 2); |
| 52 | assert_eq!(status.tabs[0].app, Some(App::Teams)); |
| 53 | assert_eq!(status.login_state, LoginState::NotRequired); |
| 54 | } |
| 55 | |
| 56 | #[tokio::test] |
| 57 | async fn status_reports_login_required() { |
| 58 | let harness = harness().await; |
| 59 | harness.mock.start(&[TEAMS, LOGIN]).await; |
| 60 | let status = harness.browser.status().await.unwrap(); |
| 61 | assert_eq!(status.login_state, LoginState::Required); |
| 62 | assert_eq!(status.mode, Mode::Visible); |
| 63 | } |
| 64 | |
| 65 | #[tokio::test] |
| 66 | async fn ensure_running_starts_headless_with_the_teams_tab_only() { |
| 67 | let harness = harness().await; |
| 68 | harness.browser.ensure_running().await.unwrap(); |
| 69 | let launches = harness.launcher.requests.lock().unwrap().clone(); |
| 70 | assert_eq!(launches.len(), 1); |
| 71 | assert!(launches[0].headless); |
| 72 | assert_eq!(launches[0].start_urls, [TEAMS]); |
| 73 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 74 | assert_eq!( |
| 75 | std::fs::read_to_string(&harness.mode_file).unwrap(), |
| 76 | "headless" |
| 77 | ); |
| 78 | assert!( |
| 79 | !harness |
| 80 | .mock |
| 81 | .requests() |
| 82 | .contains(&"PUT /json/new".to_owned()) |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | #[tokio::test] |
| 87 | async fn ensure_running_on_a_running_browser_opens_only_missing_tabs() { |
| 88 | let harness = harness().await; |
| 89 | harness.mock.start(&[OUTLOOK]).await; |
| 90 | harness.browser.ensure_running().await.unwrap(); |
| 91 | assert!(harness.launcher.requests.lock().unwrap().is_empty()); |
| 92 | assert_eq!(harness.mock.urls(), [OUTLOOK, TEAMS]); |
| 93 | harness.browser.ensure_tabs().await.unwrap(); |
| 94 | assert_eq!(harness.mock.urls().len(), 2); |
| 95 | } |
| 96 | |
| 97 | #[tokio::test] |
| 98 | async fn ensure_tabs_does_not_open_tabs_while_a_login_page_is_open() { |
| 99 | let harness = harness().await; |
| 100 | harness.mock.start(&[LOGIN]).await; |
| 101 | harness.browser.ensure_tabs().await.unwrap(); |
| 102 | assert_eq!(harness.mock.urls(), [LOGIN]); |
| 103 | } |
| 104 | |
| 105 | #[tokio::test] |
| 106 | async fn launch_failure_is_reported() { |
| 107 | let harness = harness().await; |
| 108 | *harness.launcher.fail.lock().unwrap() = true; |
| 109 | assert!(harness.browser.ensure_running().await.is_err()); |
| 110 | } |
| 111 | |
| 112 | #[tokio::test] |
| 113 | async fn login_window_restarts_visible_and_headless_goes_back() { |
| 114 | let harness = harness().await; |
| 115 | harness.browser.ensure_running().await.unwrap(); |
| 116 | harness.browser.login_window().await.unwrap(); |
| 117 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 118 | let status = harness.browser.status().await.unwrap(); |
| 119 | assert_eq!(status.mode, Mode::Visible); |
| 120 | assert!( |
| 121 | !harness |
| 122 | .launcher |
| 123 | .requests |
| 124 | .lock() |
| 125 | .unwrap() |
| 126 | .last() |
| 127 | .unwrap() |
| 128 | .headless |
| 129 | ); |
| 130 | |
| 131 | // Calling login_window() again while already visible must not restart Chrome. |
| 132 | harness.browser.login_window().await.unwrap(); |
| 133 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 2); |
| 134 | |
| 135 | harness.browser.headless().await.unwrap(); |
| 136 | assert_eq!(harness.browser.status().await.unwrap().mode, Mode::Headless); |
| 137 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 3); |
| 138 | |
| 139 | harness.browser.headless().await.unwrap(); |
| 140 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 3); |
| 141 | } |
| 142 | |
| 143 | #[tokio::test] |
| 144 | async fn login_window_without_teams_tab_opens_only_teams() { |
| 145 | let harness = harness().await; |
| 146 | harness.browser.login_window().await.unwrap(); |
| 147 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 148 | |
| 149 | // Also when restarting from a headless browser stuck on the login page. |
| 150 | harness.mock.set_urls(&[LOGIN]); |
| 151 | std::fs::write(&harness.mode_file, "headless").unwrap(); |
| 152 | harness.browser.login_window().await.unwrap(); |
| 153 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 154 | } |
| 155 | |
| 156 | #[tokio::test] |
| 157 | async fn watchdog_ignores_brief_login_redirect_within_grace() { |
| 158 | let harness = harness().await; |
| 159 | harness.mock.start(&[TEAMS, OUTLOOK]).await; |
| 160 | let config = WatchdogConfig { |
| 161 | login_grace: Duration::from_millis(250), |
| 162 | ..fast_watchdog() |
| 163 | }; |
| 164 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), config); |
| 165 | assert_eq!( |
| 166 | next_event(&mut watchdog.events).await, |
| 167 | BrowserEvent::Started |
| 168 | ); |
| 169 | |
| 170 | // Brief silent SSO redirect clears before login_grace elapses. |
| 171 | harness.mock.set_urls(&[TEAMS, LOGIN]); |
| 172 | tokio::time::sleep(Duration::from_millis(120)).await; |
| 173 | harness.mock.set_urls(&[TEAMS, OUTLOOK]); |
| 174 | tokio::time::sleep(Duration::from_millis(200)).await; |
| 175 | assert!(watchdog.events.try_recv().is_err()); |
| 176 | |
| 177 | // Sustained login page past login_grace fires LoginRequired. |
| 178 | harness.mock.set_urls(&[LOGIN]); |
| 179 | assert_eq!( |
| 180 | next_event(&mut watchdog.events).await, |
| 181 | BrowserEvent::LoginRequired |
| 182 | ); |
| 183 | } |
| 184 | |
| 185 | #[tokio::test] |
| 186 | async fn stop_closes_the_browser_over_cdp() { |
| 187 | let harness = harness().await; |
| 188 | harness.browser.ensure_running().await.unwrap(); |
| 189 | harness.browser.stop().await.unwrap(); |
| 190 | assert!(!harness.browser.is_running().await); |
| 191 | harness.browser.stop().await.unwrap(); |
| 192 | } |
| 193 | |
| 194 | #[tokio::test] |
| 195 | async fn watchdog_reports_start_death_and_restart() { |
| 196 | let harness = harness().await; |
| 197 | harness.browser.ensure_running().await.unwrap(); |
| 198 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 199 | assert_eq!( |
| 200 | next_event(&mut watchdog.events).await, |
| 201 | BrowserEvent::Started |
| 202 | ); |
| 203 | |
| 204 | harness.mock.kill().await; |
| 205 | assert_eq!(next_event(&mut watchdog.events).await, BrowserEvent::Died); |
| 206 | assert_eq!( |
| 207 | next_event(&mut watchdog.events).await, |
| 208 | BrowserEvent::Restarted |
| 209 | ); |
| 210 | assert!(harness.browser.is_running().await); |
| 211 | assert!( |
| 212 | harness |
| 213 | .launcher |
| 214 | .requests |
| 215 | .lock() |
| 216 | .unwrap() |
| 217 | .last() |
| 218 | .unwrap() |
| 219 | .headless |
| 220 | ); |
| 221 | } |
| 222 | |
| 223 | #[tokio::test] |
| 224 | async fn watchdog_retries_with_backoff_until_launch_works() { |
| 225 | let harness = harness().await; |
| 226 | harness.browser.ensure_running().await.unwrap(); |
| 227 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 228 | assert_eq!( |
| 229 | next_event(&mut watchdog.events).await, |
| 230 | BrowserEvent::Started |
| 231 | ); |
| 232 | |
| 233 | *harness.launcher.fail.lock().unwrap() = true; |
| 234 | harness.mock.kill().await; |
| 235 | assert_eq!(next_event(&mut watchdog.events).await, BrowserEvent::Died); |
| 236 | // Retries must repeat, but how many fit in a stretch of wall clock depends on |
| 237 | // the runner (dead-port probes can eat their full timeout on a slow CI box), |
| 238 | // so wait for the count instead of racing a fixed sleep. |
| 239 | let deadline = tokio::time::Instant::now() + Duration::from_secs(60); |
| 240 | loop { |
| 241 | let requests = harness.launcher.requests.lock().unwrap().len(); |
| 242 | if requests >= 3 { |
| 243 | break; |
| 244 | } |
| 245 | assert!( |
| 246 | tokio::time::Instant::now() < deadline, |
| 247 | "only {requests} launch requests within 60s (is_running: {})", |
| 248 | harness.browser.is_running().await, |
| 249 | ); |
| 250 | tokio::time::sleep(Duration::from_millis(10)).await; |
| 251 | } |
| 252 | *harness.launcher.fail.lock().unwrap() = false; |
| 253 | assert_eq!( |
| 254 | next_event(&mut watchdog.events).await, |
| 255 | BrowserEvent::Restarted |
| 256 | ); |
| 257 | } |
| 258 | |
| 259 | #[tokio::test] |
| 260 | async fn watchdog_announces_login_once_per_occurrence() { |
| 261 | let harness = harness().await; |
| 262 | harness.mock.start(&[TEAMS, OUTLOOK]).await; |
| 263 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 264 | assert_eq!( |
| 265 | next_event(&mut watchdog.events).await, |
| 266 | BrowserEvent::Started |
| 267 | ); |
| 268 | |
| 269 | harness.mock.set_urls(&[LOGIN, OUTLOOK]); |
| 270 | assert_eq!( |
| 271 | next_event(&mut watchdog.events).await, |
| 272 | BrowserEvent::LoginRequired |
| 273 | ); |
| 274 | tokio::time::sleep(Duration::from_millis(300)).await; |
| 275 | assert!(watchdog.events.try_recv().is_err()); |
| 276 | |
| 277 | harness.mock.set_urls(&[TEAMS, OUTLOOK]); |
| 278 | tokio::time::sleep(Duration::from_millis(200)).await; |
| 279 | harness.mock.set_urls(&[LOGIN]); |
| 280 | assert_eq!( |
| 281 | next_event(&mut watchdog.events).await, |
| 282 | BrowserEvent::LoginRequired |
| 283 | ); |
| 284 | } |
| 285 | |
| 286 | #[tokio::test] |
| 287 | async fn watchdog_does_not_restart_after_an_explicit_stop() { |
| 288 | let harness = harness().await; |
| 289 | harness.browser.ensure_running().await.unwrap(); |
| 290 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 291 | assert_eq!( |
| 292 | next_event(&mut watchdog.events).await, |
| 293 | BrowserEvent::Started |
| 294 | ); |
| 295 | |
| 296 | harness.browser.stop().await.unwrap(); |
| 297 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 298 | assert!(watchdog.events.try_recv().is_err()); |
| 299 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 1); |
| 300 | } |
| 301 | |
| 302 | #[tokio::test] |
| 303 | async fn watchdog_ignores_the_gap_during_a_login_window_restart() { |
| 304 | let harness = harness().await; |
| 305 | harness.browser.ensure_running().await.unwrap(); |
| 306 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 307 | assert_eq!( |
| 308 | next_event(&mut watchdog.events).await, |
| 309 | BrowserEvent::Started |
| 310 | ); |
| 311 | |
| 312 | harness.browser.login_window().await.unwrap(); |
| 313 | tokio::time::sleep(Duration::from_millis(300)).await; |
| 314 | while let Ok(event) = watchdog.events.try_recv() { |
| 315 | assert_ne!(event, BrowserEvent::Died); |
| 316 | } |
| 317 | assert!( |
| 318 | !harness |
| 319 | .launcher |
| 320 | .requests |
| 321 | .lock() |
| 322 | .unwrap() |
| 323 | .iter() |
| 324 | .skip(1) |
| 325 | .any(|request| request.headless) |
| 326 | ); |
| 327 | } |
| 328 | |
| 329 | #[tokio::test] |
| 330 | async fn parked_tabs_are_the_app_tab_not_missing_and_not_login() { |
| 331 | let harness = harness().await; |
| 332 | harness.mock.start(&[PARKED_TEAMS]).await; |
| 333 | let status = harness.browser.status().await.unwrap(); |
| 334 | assert!( |
| 335 | status |
| 336 | .tabs |
| 337 | .iter() |
| 338 | .all(|tab| tab.parked && tab.app.is_some()) |
| 339 | ); |
| 340 | assert_eq!(status.login_state, LoginState::NotRequired); |
| 341 | harness.browser.ensure_running().await.unwrap(); |
| 342 | assert_eq!(harness.mock.urls(), [PARKED_TEAMS]); |
| 343 | } |
| 344 | |
| 345 | #[tokio::test] |
| 346 | async fn wake_navigates_the_parked_app_tab_to_its_start_url() { |
| 347 | let harness = harness().await; |
| 348 | harness.mock.start(&[PARKED_TEAMS, PARKED_OUTLOOK]).await; |
| 349 | harness.browser.wake(App::Teams).await.unwrap(); |
| 350 | assert_eq!(harness.mock.urls(), [TEAMS, PARKED_OUTLOOK]); |
| 351 | assert!( |
| 352 | harness |
| 353 | .mock |
| 354 | .requests() |
| 355 | .contains(&"CDP Page.navigate".to_owned()) |
| 356 | ); |
| 357 | let status = harness.browser.status().await.unwrap(); |
| 358 | assert!( |
| 359 | status |
| 360 | .tabs |
| 361 | .iter() |
| 362 | .all(|tab| tab.app.is_none() || !tab.parked) |
| 363 | ); |
| 364 | } |
| 365 | |
| 366 | #[tokio::test] |
| 367 | async fn wake_opens_the_tab_when_the_app_has_none() { |
| 368 | let harness = harness().await; |
| 369 | harness.mock.start(&[OUTLOOK]).await; |
| 370 | harness.browser.wake(App::Teams).await.unwrap(); |
| 371 | assert_eq!(harness.mock.urls(), [OUTLOOK, TEAMS]); |
| 372 | } |
| 373 | |
| 374 | #[tokio::test] |
| 375 | async fn jittered_recheck_adopts_a_chrome_another_launcher_started() { |
| 376 | let harness = harness().await; |
| 377 | let mock = harness.mock.clone(); |
| 378 | let browser = harness.browser.clone(); |
| 379 | let ensure = tokio::spawn(async move { browser.ensure_running().await }); |
| 380 | tokio::time::sleep(Duration::from_millis(2)).await; |
| 381 | mock.start(&[TEAMS, OUTLOOK]).await; |
| 382 | ensure.await.unwrap().unwrap(); |
| 383 | assert!(harness.launcher.requests.lock().unwrap().is_empty()); |
| 384 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 385 | } |
| 386 | |
| 387 | #[tokio::test] |
| 388 | async fn a_foreign_chrome_taking_the_port_during_launch_is_adopted_and_deduped() { |
| 389 | let harness = harness().await; |
| 390 | harness.mock.set_attached(&["P0"]); |
| 391 | *harness.launcher.foreign.lock().unwrap() = Some(vec![TEAMS, TEAMS, OUTLOOK]); |
| 392 | harness.browser.ensure_running().await.unwrap(); |
| 393 | assert_eq!(harness.mock.tab_ids(), ["P0"]); |
| 394 | assert_eq!(harness.mock.urls(), [TEAMS]); |
| 395 | } |
| 396 | |
| 397 | #[tokio::test] |
| 398 | async fn dedupe_closes_unattached_duplicates_after_a_launch() { |
| 399 | let harness = harness().await; |
| 400 | *harness.launcher.foreign.lock().unwrap() = Some(vec![TEAMS, TEAMS, PARKED_TEAMS]); |
| 401 | harness.mock.set_attached(&["P1"]); |
| 402 | harness.browser.ensure_running().await.unwrap(); |
| 403 | assert_eq!(harness.mock.tab_ids(), ["P1"]); |
| 404 | } |
| 405 | |
| 406 | #[tokio::test] |
| 407 | async fn dedupe_never_closes_login_or_foreign_tabs() { |
| 408 | let harness = harness().await; |
| 409 | *harness.launcher.foreign.lock().unwrap() = Some(vec![TEAMS, LOGIN, "about:blank"]); |
| 410 | harness.browser.ensure_running().await.unwrap(); |
| 411 | assert_eq!(harness.mock.urls(), [TEAMS, LOGIN, "about:blank"]); |
| 412 | } |
| 413 | |
| 414 | #[tokio::test] |
| 415 | async fn watchdog_waits_after_died_and_adopts_a_chrome_that_came_up_meanwhile() { |
| 416 | let harness = harness().await; |
| 417 | harness.browser.ensure_running().await.unwrap(); |
| 418 | let config = WatchdogConfig { |
| 419 | died_wait: Duration::from_millis(400), |
| 420 | ..fast_watchdog() |
| 421 | }; |
| 422 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), config); |
| 423 | assert_eq!( |
| 424 | next_event(&mut watchdog.events).await, |
| 425 | BrowserEvent::Started |
| 426 | ); |
| 427 | |
| 428 | harness.mock.kill().await; |
| 429 | assert_eq!(next_event(&mut watchdog.events).await, BrowserEvent::Died); |
| 430 | harness.mock.start(&[TEAMS, OUTLOOK]).await; |
| 431 | assert_eq!( |
| 432 | next_event(&mut watchdog.events).await, |
| 433 | BrowserEvent::Restarted |
| 434 | ); |
| 435 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 1); |
| 436 | } |
| 437 | |
| 438 | #[tokio::test] |
| 439 | async fn probe_reports_ok_hung_and_no_tab() { |
| 440 | let harness = harness().await; |
| 441 | harness.mock.start(&[OUTLOOK]).await; |
| 442 | assert_eq!(harness.browser.probe_renderer().await, RendererState::NoTab); |
| 443 | harness.mock.set_urls(&[TEAMS, OUTLOOK]); |
| 444 | assert_eq!(harness.browser.probe_renderer().await, RendererState::Ok); |
| 445 | harness.mock.stop_answering(false); |
| 446 | assert_eq!(harness.browser.probe_renderer().await, RendererState::Hung); |
| 447 | harness.mock.answer_again(); |
| 448 | assert_eq!(harness.browser.probe_renderer().await, RendererState::Ok); |
| 449 | } |
| 450 | |
| 451 | #[tokio::test] |
| 452 | async fn watchdog_leaves_a_responsive_renderer_alone() { |
| 453 | let harness = harness().await; |
| 454 | harness.browser.ensure_running().await.unwrap(); |
| 455 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 456 | assert_eq!( |
| 457 | next_event(&mut watchdog.events).await, |
| 458 | BrowserEvent::Started |
| 459 | ); |
| 460 | tokio::time::sleep(Duration::from_millis(500)).await; |
| 461 | assert!(watchdog.events.try_recv().is_err()); |
| 462 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 1); |
| 463 | } |
| 464 | |
| 465 | #[tokio::test] |
| 466 | async fn watchdog_restarts_a_hung_renderer_with_a_graceful_close() { |
| 467 | let harness = harness().await; |
| 468 | harness.browser.ensure_running().await.unwrap(); |
| 469 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 470 | assert_eq!( |
| 471 | next_event(&mut watchdog.events).await, |
| 472 | BrowserEvent::Started |
| 473 | ); |
| 474 | |
| 475 | harness.mock.stop_answering(false); |
| 476 | assert_eq!(next_event(&mut watchdog.events).await, BrowserEvent::Hung); |
| 477 | assert_eq!( |
| 478 | next_event(&mut watchdog.events).await, |
| 479 | BrowserEvent::Restarted |
| 480 | ); |
| 481 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 2); |
| 482 | assert_eq!(*harness.launcher.kills.lock().unwrap(), 0); |
| 483 | assert_eq!(harness.browser.probe_renderer().await, RendererState::Ok); |
| 484 | } |
| 485 | |
| 486 | #[tokio::test] |
| 487 | async fn hung_stop_falls_back_to_kill_when_close_is_ignored() { |
| 488 | let harness = harness().await; |
| 489 | harness.browser.ensure_running().await.unwrap(); |
| 490 | let mut watchdog = Watchdog::spawn(harness.browser.clone(), fast_watchdog()); |
| 491 | assert_eq!( |
| 492 | next_event(&mut watchdog.events).await, |
| 493 | BrowserEvent::Started |
| 494 | ); |
| 495 | |
| 496 | harness.mock.stop_answering(true); |
| 497 | assert_eq!(next_event(&mut watchdog.events).await, BrowserEvent::Hung); |
| 498 | assert_eq!( |
| 499 | next_event(&mut watchdog.events).await, |
| 500 | BrowserEvent::Restarted |
| 501 | ); |
| 502 | assert_eq!(*harness.launcher.kills.lock().unwrap(), 1); |
| 503 | assert_eq!(harness.launcher.requests.lock().unwrap().len(), 2); |
| 504 | } |