test(navigation): await traversal and background target load

Wait for the destination traversal state and the background session load notification before inspecting document contents. A best-effort stability result or navigation acknowledgement does not establish either completion boundary.
This commit is contained in:
ldm0
2026-11-01 03:55:30 +08:00
committed by Donough Liu
parent bd1b20b974
commit b092492b97
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -2547,7 +2547,7 @@ async fn navigation_activation_cross_document_back_destination_surface() -> Resu
let dest_url =
server.url("/compat/navigation-activation-cross-document-back-destination-surface-dest");
let page = browser
let mut page = browser
.fetch_with_wait_until(
&source_url,
RenderedDomWaitUntil::DomStable,
@@ -2555,6 +2555,7 @@ async fn navigation_activation_cross_document_back_destination_surface() -> Resu
)
.await?;
wait_for_body_attribute(&browser, &mut page, "data-navigation-type", "traverse").await?;
assert_eq!(page.final_url().as_str(), source_url);
assert_cross_document_traversal_activation_destination_surface(
&page.serialize_html_async().await.unwrap(),
@@ -294,6 +294,11 @@ async fn runtime_add_binding_then_navigation_on_auto_attached_background_target_
consume_main_document_navigation_start(&mut ctx);
let navigation = take_response_by_id(&mut ctx, 10353);
assert_eq!(navigation["result"]["frameId"], json!(second_target_id));
ctx.wait_for_scheduler_message("background target load after navigation", |message| {
message["method"] == json!("Page.loadEventFired")
&& message["sessionId"].as_str() == Some(session_id.as_str())
})
.await;
ctx.take_all();
ctx.process_async(json!({