mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
Merge pull request #1086 from lightpanda-io/history
Implement `History` WebAPI.
This commit is contained in:
@@ -2,23 +2,40 @@
|
||||
<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());
|
||||
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);
|
||||
testing.expectEqual(state, history.state);
|
||||
});
|
||||
|
||||
testing.expectEqual(undefined, history.go());
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user