Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/browsers/history/the-history-interface/back-pushstate-back-history-state.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<html>
<head>
<title>history.state is null after pushState+back+pushState+back</title>
<link rel="author" title="Euclid Ye" href="mailto:yezhizhenjiakang@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
promise_test(async t => {
history.pushState({x: 1}, "");
await new Promise(resolve => {
addEventListener("popstate", resolve, {once: true});
history.back();
});
assert_equals(history.state?.x, undefined,
"state is null after back from first pushState");
history.pushState({x: 2}, "");
await new Promise(resolve => {
addEventListener("popstate", resolve, {once: true});
history.back();
});
assert_equals(history.state?.x, undefined,
"state is null after back from second pushState");
}, "history.state is null after pushState+back+pushState+back");
</script>
</body>
</html>