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 6add670c91..aca5a5d466 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 db0fd964fb..82ad241a2e 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!(