fix(window): retain the name of closed auxiliary windows

Validation on the original split base: cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings.
Nextest and WPT reruns omitted at the user's request.
This commit is contained in:
ldm0
2026-10-11 01:44:57 +08:00
committed by Donough Liu
parent f7a49daf6a
commit 5f5e1fff36
2 changed files with 20 additions and 7 deletions
@@ -668,7 +668,24 @@ async fn auxiliary_initial_history_stays_provisional_until_document_navigation()
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn closed_auxiliary_name_reads_empty_and_ignores_writes_after_conversion() {
async fn auxiliary_initial_document_adoption_keeps_closed_window_name() {
let (addr, server) = spawn_test_protocol_server().await;
let (mut browser, _) =
connect_async(format!("ws://{addr}/devtools/browser/{DEFAULT_BROWSER_ID}"))
.await
.unwrap();
let opener_id = create_dynamic_target(&mut browser, 1).await;
let mut opener = connect_dynamic_page(addr, &opener_id).await;
let (_, _child) = open_auxiliary(addr, &mut opener, "").await;
assert_eq!(
evaluate_window_name_probe(&mut opener, 4, "p.close();p.name").await,
json!("actual-page"),
);
abort_test_cdp_server(server).await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn closed_auxiliary_name_is_retained_and_ignores_writes_after_conversion() {
let (fixture_addr, _fixture) = spawn_dedicated_fixture_server(
Router::new().fallback(get(|| async { axum::response::Html("<p>parent</p>") })),
"auxiliary-closed-name",
@@ -720,7 +737,7 @@ async fn closed_auxiliary_name_reads_empty_and_ignores_writes_after_conversion()
})()"#
)
.await,
json!([true, "", "", 1])
json!([true, "kept", "kept", 1])
);
}
abort_test_cdp_server(server).await;
@@ -881,11 +881,7 @@ fn window_name_runtime_getter<'s>(
&& let Some(host_ptr) = context_host_ptr_from_global_bridge(scope)
{
let host = unsafe { &*host_ptr };
let name = if host.browsing_context_is_closed() {
String::new()
} else {
host.browsing_context_name().get()
};
let name = host.browsing_context_name().get();
rv.set(v8::String::new(scope, &name).unwrap().into());
return;
}