Skip to content

armgit / moli

Public Imported from GitHub
0

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

test(history): await child fragment traversal completion explicitly

ldm0d3f740747289
diff --git a/moli-core/tests/fixtures/runtime/window_child_browsing_context_history_go_one_fragment_traversal_events_are_window_local.html b/moli-core/tests/fixtures/runtime/window_child_browsing_context_history_go_one_fragment_traversal_events_are_window_local.html
index 6add670c9..aca5a5d46 100644
--- a/moli-core/tests/fixtures/runtime/window_child_browsing_context_history_go_one_fragment_traversal_events_are_window_local.html
+++ b/moli-core/tests/fixtures/runtime/window_child_browsing_context_history_go_one_fragment_traversal_events_are_window_local.html
@@ -98,33 +98,40 @@
String(event.navigationType)
);
};
+ childWindow.removeEventListener('hashchange', onHashchange);
+ childWindow.addEventListener(
+ 'hashchange',
+ () => {
+ setTimeout(() => {
+ document.body.setAttribute('data-top-order', topOrder.join(','));
+ document.body.setAttribute(
+ 'data-top-currententrychange',
+ String(topCurrentEntryChanges)
+ );
+ document.body.setAttribute('data-child-order', childOrder.join(','));
+ document.body.setAttribute(
+ 'data-child-property-order',
+ childPropertyOrder.join(',')
+ );
+ document.body.setAttribute(
+ 'data-child-timeout-hash',
+ childWindow.location.hash
+ );
+ document.body.setAttribute(
+ 'data-child-timeout-state',
+ String(childWindow.history.state?.step ?? 'null')
+ );
+ document.body.setAttribute('data-child-traversal-complete', 'true');
+ }, 0);
+ },
+ { once: true }
+ );
childWindow.history.go(1);
document.body.setAttribute('data-child-sync-hash', childWindow.location.hash);
document.body.setAttribute(
'data-child-sync-state',
String(childWindow.history.state?.step ?? 'null')
);
- childWindow.removeEventListener('hashchange', onHashchange);
- setTimeout(() => {
- document.body.setAttribute('data-top-order', topOrder.join(','));
- document.body.setAttribute(
- 'data-top-currententrychange',
- String(topCurrentEntryChanges)
- );
- document.body.setAttribute('data-child-order', childOrder.join(','));
- document.body.setAttribute(
- 'data-child-property-order',
- childPropertyOrder.join(',')
- );
- document.body.setAttribute(
- 'data-child-timeout-hash',
- childWindow.location.hash
- );
- document.body.setAttribute(
- 'data-child-timeout-state',
- String(childWindow.history.state?.step ?? 'null')
- );
- }, 50);
},
{ once: false }
);
diff --git a/moli-core/tests/history_child.rs b/moli-core/tests/history_child.rs
index db0fd964f..82ad241a2 100644
--- a/moli-core/tests/history_child.rs
+++ b/moli-core/tests/history_child.rs
@@ -4277,7 +4277,11 @@ async fn child_browsing_context_history_go_one_fragment_traversal_events_stay_wi
))
.await?;
browser
- .wait_for_page_delay(&mut page, Duration::from_millis(250))
+ .wait_for_selector(
+ &mut page,
+ "body[data-child-traversal-complete='true']",
+ Duration::from_secs(5),
+ )
.await?;
assert!(