Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(custom-elements): rotate registries on document navigation

ldm04fa06f0c42c4
diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_documents/commit.rs b/moli-renderer-v8/src/native_bridge/context_host/child_documents/commit.rs
index e184f54c9..b8c321a3f 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/child_documents/commit.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/child_documents/commit.rs
@@ -318,8 +318,10 @@ impl JsContextHost {
}
self.replace_child_custom_elements_registry_for_document_commit(scope, handle);
}
- FrameLocalWindowOwnerTransition::Installed { .. }
- | FrameLocalWindowOwnerTransition::Preserved { .. } => {}
+ FrameLocalWindowOwnerTransition::Preserved { .. } => {
+ self.replace_child_custom_elements_registry_for_document_commit(scope, handle);
+ }
+ FrameLocalWindowOwnerTransition::Installed { .. } => {}
FrameLocalWindowOwnerTransition::Retired { .. } => {
unreachable!("a child document commit must install a current LocalWindow")
}
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/custom_elements.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/custom_elements.rs
index d4715536e..485cef4d5 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_elements/custom_elements.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/custom_elements.rs
@@ -1921,7 +1921,7 @@ fn detached_iframe_document_keeps_content_window_custom_elements_registry() {
}
#[test]
-fn iframe_initial_srcdoc_reuses_then_later_navigation_replaces_custom_elements_registry() {
+fn iframe_document_navigation_replaces_custom_elements_registry() {
let mut vm = new_storage_test_vm("https://example.com/");
let setup = vm
@@ -1955,13 +1955,13 @@ fn iframe_initial_srcdoc_reuses_then_later_navigation_replaces_custom_elements_r
const afterFirstNavigation = childWindow.customElements;
window.__ceFirstCommittedRegistry = afterFirstNavigation;
window.__ceRetainedChildWindow = childWindow;
- const firstNavigationReused =
- afterFirstNavigation === window.__cePerDocumentBefore;
+ const firstNavigationReplaced =
+ afterFirstNavigation !== window.__cePerDocumentBefore;
childWindow.document.open();
const afterOpen = childWindow.customElements === afterFirstNavigation;
childWindow.document.close();
frame.srcdoc = "<title>later child</title>";
- return JSON.stringify({firstNavigationReused, afterOpen});
+ return JSON.stringify({firstNavigationReplaced, afterOpen});
})()
"#,
)
@@ -1969,7 +1969,7 @@ fn iframe_initial_srcdoc_reuses_then_later_navigation_replaces_custom_elements_r
assert_eq!(
first_commit,
- r#"{"firstNavigationReused":true,"afterOpen":true}"#
+ r#"{"firstNavigationReplaced":true,"afterOpen":true}"#
);
vm.drain_pending_child_frame_work_for_test();