Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(renderer): materialize empty named child worlds
ldm0f6802502496b
diff --git a/moli-renderer-v8/src/script_vm/child_frame_realm_materialization.rs b/moli-renderer-v8/src/script_vm/child_frame_realm_materialization.rsindex 70c5e0c9f..a994b2fee 100644--- a/moli-renderer-v8/src/script_vm/child_frame_realm_materialization.rs+++ b/moli-renderer-v8/src/script_vm/child_frame_realm_materialization.rs@@ -517,9 +517,6 @@ impl ScriptVm {.into_iter().filter(|script| script.world_name.is_some()){- if script.source.trim().is_empty() {- continue;- }if !self.child_materialization_owner_is_current(handle, owner) {break;}@@ -550,6 +547,13 @@ impl ScriptVm {continue;}};+ // Chromium uses an empty world-scoped script as a declaration+ // that the isolated world must exist in every new document.+ // Playwright relies on that contract for its utility world, so+ // creating the context cannot be conditional on script contents.+ if script.source.trim().is_empty() {+ continue;+ }activity = ChildRealmMaterializationBodyActivity::DocumentStartScript;if let Err(error) = self.exec_in_execution_context(execution_context_id, &script.source){diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rsindex 77b3ccc9d..4435180f0 100644--- a/moli-renderer-v8/src/script_vm/tests/mod.rs+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs@@ -6410,6 +6410,47 @@ async fn pending_child_navigation_does_not_materialize_initial_empty_preload_rea);}+#[tokio::test]+async fn empty_named_preload_materializes_child_isolated_world() {+ let mut vm = new_storage_test_vm("https://child-empty-named-preload.test/");+ vm.set_stored_document_start_scripts(&[crate::DocumentStartScript {+ registry_key: Some("empty-utility-world".to_owned()),+ devtools_session: None,+ source: String::new(),+ world_name: Some("playwright-utility".to_owned()),+ has_bidi_channel_argument: false,+ bidi_channel_handoffs: Vec::new(),+ }]);++ vm.eval(+ r#"+(() => {+ const frame = document.createElement("iframe");+ frame.srcdoc = "<!doctype html><body>child</body>";+ (document.body || document.documentElement || document).appendChild(frame);+})()+"#,+ )+ .expect("empty named preload child setup should evaluate");++ run_child_navigation_commit_and_host_load_for_test(+ &mut vm,+ "empty named preload child document",+ )+ .await;+ let frame_id = {+ let host = vm._context_host.borrow();+ let handles = host.child_browsing_context_handles_in_document_order();+ assert_eq!(handles.len(), 1, "expected one child browsing context");+ host.child_browsing_context_frame_id_by_owner_node_id(handles[0])+ .expect("child browsing context should have a frame id")+ };+ assert!(+ vm.has_isolated_world_named_for_frame(&frame_id, "playwright-utility"),+ "an empty world-scoped preload must still declare the child isolated world"+ );+}+#[tokio::test]async fn child_body_onload_materializes_default_context_at_host_load() {let mut vm = new_storage_test_vm("https://child-body-onload-lazy.test/");