add popstate event for History

This commit is contained in:
Muki Kiboigo
2025-09-24 00:20:34 -07:00
parent 464f42a121
commit e74d7fa454
6 changed files with 98 additions and 8 deletions

View File

@@ -19,8 +19,18 @@
let state = { "new": "field", testComplete: true };
testing.expectEqual(state, history.state);
testing.expectEqual(undefined, history.back());
testing.expectEqual(undefined, history.forward());
let popstateEventFired = false;
let popstateEventState = null;
window.addEventListener('popstate', (event) => {
popstateEventFired = true;
popstateEventState = event.state;
});
testing.eventually(() => {
testing.expectEqual(true, popstateEventFired);
testing.expectEqual(state, popstateEventState);
})
testing.onPageWait(() => {
testing.expectEqual(true, history.state && history.state.testComplete);