add history tests

This commit is contained in:
Muki Kiboigo
2025-09-23 23:37:50 -07:00
parent 05e7079178
commit 464f42a121
3 changed files with 52 additions and 21 deletions

View File

@@ -2,30 +2,30 @@
<script src="../testing.js"></script>
<script id=history>
testing.expectEqual('auto', history.scrollRestoration);
testing.expectEqual('auto', history.scrollRestoration);
history.scrollRestoration = 'manual';
history.scrollRestoration = 'foo';
testing.expectEqual('manual', history.scrollRestoration);
history.scrollRestoration = 'manual';
history.scrollRestoration = 'foo';
testing.expectEqual('manual', history.scrollRestoration);
history.scrollRestoration = 'auto';
testing.expectEqual('auto', history.scrollRestoration);
history.scrollRestoration = 'auto';
testing.expectEqual('auto', history.scrollRestoration);
testing.expectEqual(null, history.state)
testing.expectEqual(null, history.state)
history.pushState({ testInProgress: true }, null, 'http://127.0.0.1:9582/xhr/json');
testing.expectEqual({ testInProgress: true }, history.state);
history.pushState({}, null, '');
history.replaceState({}, null, '');
history.replaceState({ "new": "field", testComplete: true }, null);
let state = { "new": "field", testComplete: true };
testing.expectEqual(state, history.state);
testing.expectEqual(undefined, history.go());
testing.expectEqual(undefined, history.go(1));
testing.expectEqual(undefined, history.go(-1));
testing.expectEqual(undefined, history.forward());
testing.expectEqual(undefined, history.back());
</script>
<script id=history-states>
testing.expectEqual(null, history.state)
history.pushState({}, { "abc": "def" }, '');
testing.expectEqual({ "abc": "def"}, history.state);
testing.expectEqual(undefined, history.back());
testing.expectEqual(undefined, history.forward());
testing.onPageWait(() => {
testing.expectEqual(true, history.state && history.state.testComplete);
testing.expectEqual(state, history.state);
});
testing.expectEqual(undefined, history.go());
</script>