forked from web-platform-tests/wpt
/
navigate-same-document-event-order.html
30 lines (29 loc) · 1.28 KB
/
navigate-same-document-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
<!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 "promisefulfilled").
// TODO(domenic): fix the spec, write non-app history tests, then reenable these checks.
assert_array_equals(
events.slice(0, -2),
["onnavigate", "onnavigatesuccess", "promisefulfilled"/*, "onpopstate", "onhashchange"*/]
);
t.done();
}
appHistory.onnavigate = () => events.push("onnavigate");
appHistory.onnavigatesuccess = () => events.push("onnavigatesuccess");
appHistory.onnavigateerror = () => events.push("onnavigateerror");
window.onhashchange = t.step_func(() => {
events.push("onhashchange");
t.step_timeout(finish, 0);
});
window.onpopstate = () => events.push("onpopstate");
appHistory.navigate("#1").committed.then(
() => events.push("promisefulfilled"), () => events.push("promiserejected"));
}, "navigate() event ordering for same-document navigation");
</script>