forked from web-platform-tests/wpt
/
navigate-transitionWhile-reject-event-order.html
40 lines (37 loc) · 1.56 KB
/
navigate-transitionWhile-reject-event-order.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
let events = [];
function finish() {
// Until https://github.com/whatwg/html/issues/1792 (see also https://crbug.com/1254926) is
// resolved, ignore the ordering of hashchange and popstate (while still testing that they are
// the last two, in some order, and come in at most one task after "finished promiserejected").
// TODO(domenic): fix the spec, write non-app history tests, then reenable these checks.
assert_array_equals(
events.slice(0, -2),
["onnavigate", "committed promisefulfilled", "onnavigateerror", "finished promiserejected"/*, "onhashchange", "onpopstate"*/]
);
t.done();
}
appHistory.onnavigate = e => {
events.push("onnavigate");
e.transitionWhile(Promise.reject());
};
appHistory.onnavigatesuccess = () => events.push("onnavigatesuccess");
appHistory.onnavigateerror = () => events.push("onnavigateerror");
window.onhashchange = () => events.push("onhashchange");
window.onpopstate = () => events.push("onpopstate");
const result = appHistory.navigate("#1");
result.committed.then(
() => events.push("committed promisefulfilled"),
() => events.push("committed promiserejected"));
result.finished.then(
() => events.push("finished promisefulfilled"),
() => {
events.push("finished promiserejected");
t.step_timeout(finish, 0);
});
}, "navigate() event ordering for same-document navigation");
</script>