Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /navigation-api/navigate-event/navigate-destination-getState-fragment-via-navigate.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<button id="a">#foo</button>
<script>
async_test(t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
window.onload = () => t.step_timeout(() => {
const navState = { carryOver: "carriedOver" };
navigation.updateCurrentEntry({ state: navState });
navigation.onnavigate = t.step_func_done(e => {
assert_equals(e.navigationType, "push");
assert_not_equals(e.destination, null);
assert_equals(e.destination.getState(), null);
assert_equals(e.destination.getState()?.carryOver, undefined);
});
// Compared to location.href="#foo", <a href="#foo">, this will not cause
// carry-over from active entry.
navigation.navigate("#foo", { state: null });
}, 0);
}, "navigate event destination.getState() carries over the previous entry's " +
"state on a user-initiated fragment navigation");
</script>