|
| 1 | +<!doctype html> |
| 2 | +<script src="/resources/testharness.js"></script> |
| 3 | +<script src="/resources/testharnessreport.js"></script> |
| 4 | +<script> |
| 5 | +promise_test(async t => { |
| 6 | + // Wait for after the load event so that the navigation doesn't get converted |
| 7 | + // into a replace navigation. |
| 8 | + await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); |
| 9 | + await appHistory.navigate("#foo").finished; |
| 10 | + assert_equals(appHistory.entries().length, 2); |
| 11 | + await appHistory.back().finished; |
| 12 | + assert_equals(appHistory.current.index, 0); |
| 13 | + |
| 14 | + // Traverse forward then immediately do a same-document push. This will |
| 15 | + // truncate the back forward list, and by the time the traverse commits, the |
| 16 | + // destination key will no longer be present in appHistory.entries(). The |
| 17 | + // traverse should abort. |
| 18 | + let forward_value = appHistory.forward(); |
| 19 | + await appHistory.navigate("#clobber").finished; |
| 20 | + assert_equals(appHistory.current.index, 1); |
| 21 | + await promise_rejects_dom(t, "AbortError", forward_value.committed); |
| 22 | + await promise_rejects_dom(t, "AbortError", forward_value.finished); |
| 23 | + |
| 24 | + // This leaves appHistory.entries() in a consistent state where traversing |
| 25 | + // back and forward still works. |
| 26 | + await appHistory.back().finished; |
| 27 | + assert_equals(appHistory.current.index, 0); |
| 28 | + await appHistory.forward().finished; |
| 29 | + assert_equals(appHistory.current.index, 1); |
| 30 | +}, "If forward pruning clobbers the target of a traverse, abort"); |
| 31 | +</script> |
0 commit comments