test(history): snapshot child traversal events after completion

This commit is contained in:
ldm0
2026-10-07 16:05:33 +08:00
committed by Donough Liu
parent 991175f273
commit 3f6a8f470d
2 changed files with 13 additions and 8 deletions
@@ -17,6 +17,7 @@
document.body.setAttribute('data-done', '1');
const childWindow = iframe.contentWindow;
let finishTraversal;
childWindow.addEventListener('popstate', () => {
childOrder.push('child-popstate');
@@ -29,6 +30,7 @@
document.body.setAttribute('data-child-new', event.newURL);
queueMicrotask(() => {
childOrder.push('child-hashchange-microtask');
finishTraversal?.();
});
});
@@ -41,14 +43,19 @@
document.body.removeAttribute('data-child-old');
document.body.removeAttribute('data-child-new');
const traversalCompleted = new Promise(resolve => {
finishTraversal = resolve;
});
childWindow.history.back();
document.body.setAttribute('data-child-sync-hash', childWindow.location.hash);
setTimeout(() => {
document.body.setAttribute('data-top-order', topOrder.join(','));
document.body.setAttribute('data-child-order', childOrder.join(','));
document.body.setAttribute('data-child-timeout-hash', childWindow.location.hash);
}, 50);
traversalCompleted.then(() => {
setTimeout(() => {
document.body.setAttribute('data-top-order', topOrder.join(','));
document.body.setAttribute('data-child-order', childOrder.join(','));
document.body.setAttribute('data-child-timeout-hash', childWindow.location.hash);
}, 50);
});
}, 50);
});
</script>
+1 -3
View File
@@ -4073,9 +4073,7 @@ async fn child_browsing_context_fragment_traversal_events_stay_window_local() ->
"/compat/window-child-browsing-context-fragment-traversal-events-are-window-local",
))
.await?;
browser
.wait_for_page_delay(&mut page, Duration::from_millis(250))
.await?;
wait_for_body_attribute(&browser, &mut page, "data-child-timeout-hash", "#one").await?;
assert!(
page.serialize_html_async()