From dc75f53ea91368bfb4c623f2008a64d7301cbb0e Mon Sep 17 00:00:00 2001 From: ldm0 Date: Sat, 31 Oct 2026 01:56:25 +0800 Subject: [PATCH] test(cdp): arm prepared document.open after parser EOF Start the held Fetch from interactive readystatechange so the fixture establishes its intended defer-wait boundary. A speculative script request is not an EOF signal. Retain both normal/crashed modes and every history, adoption and result assertion without changing timeouts or retry policy. Validation (32 build jobs / test threads, zero retries): - `cargo fmt --all` - `cargo clippy --workspace --all-targets --all-features -- -D warnings` - `cargo nextest run --no-fail-fast`: Summary [ 140.487s] 22001 tests run: 22001 passed (9 slow), 19 skipped --- .../websocket/prepared_document_actions.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/moli-protocol-server/src/protocol_server/tests/websocket/prepared_document_actions.rs b/moli-protocol-server/src/protocol_server/tests/websocket/prepared_document_actions.rs index 256fe57a095..c7f754c494d 100644 --- a/moli-protocol-server/src/protocol_server/tests/websocket/prepared_document_actions.rs +++ b/moli-protocol-server/src/protocol_server/tests/websocket/prepared_document_actions.rs @@ -1421,9 +1421,21 @@ async fn websocket_cdp_prepared_document_open_does_not_append_history_on_adoptio json!({"discover": true}), ) .await; - // The asynchronous callback runs during a defer wait, outside parser - // script execution where document.open() would otherwise be ignored. - let html = "before-open"; + // A speculative script request does not prove parser EOF. Arm the + // callback at interactive so document.open() runs during the intended + // defer wait, outside the parser's script execution scope. + let html = r#"before-open +"#; let mut observed = begin_document_html(&mut socket, &session.session_id, &fixture, html).await; tokio::time::timeout(Duration::from_secs(10), fixture.requested.notified())