Skip to content

armgit / moli

Public Imported from GitHub
0

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

test(modulepreload): select the pending owner notification task

ldm0306e090e978d
diff --git a/moli-renderer-v8/src/runtime/page_vm/test_support.rs b/moli-renderer-v8/src/runtime/page_vm/test_support.rs
index 66bc7751d..2e8583a77 100644
--- a/moli-renderer-v8/src/runtime/page_vm/test_support.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/test_support.rs
@@ -216,6 +216,23 @@ impl PageVmTaskExecutorTestHarness {
.await
}
+ /// Execute one exact main-Document native-module owner notification.
+ /// Tests use this after asserting that such a notification is ready so an
+ /// older unrelated Page task cannot obscure the modulepreload follow-up.
+ pub(crate) async fn run_one_native_module_owner_event_task_executor_turn(
+ &mut self,
+ loader: &ResourceRequestClient,
+ ) -> anyhow::Result<bool> {
+ self.selected_task_local_set
+ .run_until(self.page_vm.run_exact_selected_page_task_for_test(
+ PageSelectedTaskTestSelector::MainDocumentRuntime(
+ crate::page_task_queue::PageMainDocumentRuntimeActionKind::NativeModuleOwnerEvent,
+ ),
+ loader,
+ ))
+ .await
+ }
+
/// Advance Page timers only through the production selected-task
/// dispatcher.
///
diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rs
index cf35192fb..b3dc8a838 100644
--- a/moli-renderer-v8/src/script_vm/tests/mod.rs
+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs
@@ -14307,7 +14307,7 @@ async fn in_flight_connected_modulepreload_does_not_delay_window_load() {
"the module-map terminal must publish its joined link-client notification"
);
assert!(
- vm.run_one_oldest_ready_page_task_executor_turn(&loader)
+ vm.run_one_native_module_owner_event_task_executor_turn(&loader)
.await
.expect("modulepreload owner-notification turn"),
"the joined link client must be notified in a later selected task"