| <!DOCTYPE html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| |
| <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(t.step_func_done(() => { |
| assert_equals(appHistory.transition, null); |
| const from = appHistory.current; |
| |
| const events = []; |
| |
| appHistory.addEventListener("navigate", t.step_func(e => { |
| events.push("navigate"); |
| |
| e.preventDefault(); |
| assert_equals(appHistory.transition, null); |
| })); |
| |
| appHistory.addEventListener("navigateerror", t.step_func(() => { |
| events.push("navigateerror"); |
| |
| assert_equals(appHistory.transition, null); |
| })); |
| |
| location.href = "?1"; |
| assert_equals(appHistory.transition, null); |
| assert_array_equals(events, ["navigate", "navigateerror"]); |
| }), 0); |
| }, "canceled location.href navigation"); |
| </script> |