| <!doctype html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script> |
| promise_test(async t => { |
| await new Promise(resolve => window.onload = resolve); |
| let start_href = location.href; |
| let events = []; |
| |
| appHistory.onnavigatesuccess = () => events.push("navigatesuccess"); |
| appHistory.onnavigateerror = t.step_func(() => { |
| events.push("navigateerror"); |
| assert_equals(location.hash, "#1"); |
| }); |
| |
| appHistory.onnavigate = t.step_func(e => { |
| events.push("navigate"); |
| |
| e.signal.onabort = () => events.push("abort"); |
| |
| e.transitionWhile(new Promise(resolve => t.step_timeout(resolve, 2))); |
| }); |
| |
| const result1 = appHistory.navigate("#1"); |
| result1.committed.then(() => events.push("result1 committed fulfill"), () => events.push("result1 committed reject")); |
| const p1 = result1.finished.then(() => events.push("result1 finished fulfill"), () => events.push("result1 finished reject")); |
| |
| const result2 = appHistory.navigate("#2"); |
| result2.committed.then(() => events.push("result2 committed fulfill"), () => events.push("result2 committed reject")); |
| p2 = result2.finished.then(() => events.push("result2 finished fulfill"), () => events.push("result2 finished reject")); |
| |
| await Promise.all([p1, p2]); |
| assert_equals(location.hash, "#2"); |
| assert_array_equals(events, [ |
| "navigate", |
| "abort", |
| "navigateerror", |
| "navigate", |
| "result1 committed fulfill", |
| "result1 finished reject", |
| "result2 committed fulfill", |
| "navigatesuccess", |
| "result2 finished fulfill" |
| ]); |
| }, "navigateerror ordering when navigate() is called repeatedly and handled by transitionWhile()"); |
| </script> |