test(history): await child fragment traversal completion explicitly

This commit is contained in:
ldm0
2026-10-05 05:17:00 +08:00
committed by Donough Liu
parent fc2a45a9eb
commit d3f7407472
2 changed files with 33 additions and 22 deletions
@@ -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 }
);
+5 -1
View File
@@ -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!(