forked from web-platform-tests/wpt
/
navigateerror-ordering-transitionWhile-reentrant.html
52 lines (44 loc) · 1.78 KB
/
navigateerror-ordering-transitionWhile-reentrant.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
41
42
43
44
45
46
47
48
49
50
51
52
<!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 = [];
let first_onnavigate = true;
let p2;
appHistory.onnavigatesuccess = () => events.push("navigatesuccess");
appHistory.onnavigateerror = t.step_func(() => {
events.push("navigateerror");
assert_equals(location.hash, "");
});
appHistory.onnavigate = t.step_func(e => {
assert_equals(location.href, start_href);
events.push("navigate");
e.signal.onabort = () => events.push("abort");
e.transitionWhile(new Promise(resolve => t.step_timeout(resolve, 2)));
if (first_onnavigate) {
first_onnavigate = false;
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"));
}
});
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"));
await Promise.all([p1, p2]);
assert_array_equals(events, [
"navigate",
"abort",
"navigateerror",
"navigate",
"result2 committed fulfill",
"result1 committed reject",
"result1 finished reject",
"navigatesuccess",
"result2 finished fulfill"
]);
}, "navigateerror ordering when navigate() is called reentrantly and handled by transitionWhile()");
</script>