mirror of
https://github.com/lexmount/moli.git
synced 2026-11-14 00:08:12 +00:00
fix(dom): restore copied document URL after cloned base removal
fix(dom): restore copied document URL after cloned base removal.
Extracted from development commit 77ef817c7e8 and adapted to main.
Validation (32 build jobs and test threads): cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast.
Summary [ 140.724s] 22165 tests run: 22165 passed (9 slow), 20 skipped
This commit is contained in:
@@ -85,6 +85,15 @@ fn clone_detached_document_shell<'s>(
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// Browser Document clones fall back to their copied URL/about base URL
|
||||
// when a copied <base> is removed. The native clone helper also serves
|
||||
// callers that need a frozen computed base; do not expose that override.
|
||||
unsafe { &mut *clone_runtime }
|
||||
.dom_host_mut()
|
||||
.node_mut(clone_handle)?
|
||||
.data_mut()
|
||||
.as_document_mut()?
|
||||
.set_base_url_override(None);
|
||||
if !deep {
|
||||
return Some(cloned);
|
||||
}
|
||||
|
||||
+21
-3
@@ -45,7 +45,7 @@ fn detached_document_clones_keep_url_and_document_uri_in_sync_with_native_metada
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn document_clone_base_uri_survives_base_element_removal() {
|
||||
fn document_clone_base_uri_falls_back_to_copied_url_after_base_removal() {
|
||||
let mut vm = new_storage_test_vm("https://document-clone-base.test/path/page.html");
|
||||
let result = vm
|
||||
.eval(
|
||||
@@ -80,8 +80,26 @@ fn document_clone_base_uri_survives_base_element_removal() {
|
||||
"#,
|
||||
)
|
||||
.expect("document clone base URI probe should evaluate");
|
||||
let row = r#"["https://cdn.example/assets/","https://other.example/","https://cdn.example/assets/","https://cdn.example/assets/image.png","https://cdn.example/assets/"]"#;
|
||||
assert_eq!(result, format!("[{row},{row}]"));
|
||||
let fallback = "https://document-clone-base.test/path/page.html";
|
||||
assert_eq!(
|
||||
serde_json::from_str::<serde_json::Value>(&result).unwrap(),
|
||||
serde_json::json!([
|
||||
[
|
||||
fallback,
|
||||
"https://other.example/",
|
||||
fallback,
|
||||
"https://document-clone-base.test/path/image.png",
|
||||
fallback
|
||||
],
|
||||
[
|
||||
"https://cdn.example/assets/",
|
||||
"https://other.example/",
|
||||
fallback,
|
||||
"https://document-clone-base.test/path/image.png",
|
||||
fallback
|
||||
],
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user