2 <script src=
"/resources/testharness.js"></script>
3 <script src=
"/resources/testharnessreport.js"></script>
4 <meta name=
"variant" content=
"">
5 <meta name=
"variant" content=
"?currententrychange">
8 import { Recorder, hasVariant } from
"./resources/helpers.mjs";
9 promise_test(async t =
> {
10 // Wait for after the load event so that the navigation doesn't get converted
11 // into a replace navigation.
12 await new Promise(resolve =
> window.onload = () =
> t.step_timeout(resolve,
0));
14 const fromStart = navigation.currentEntry;
17 const recorder = new Recorder({
18 skipCurrentChange: !hasVariant(
"currententrychange"),
19 finalExpectedEvent:
"transition.finished fulfilled"
22 recorder.setUpAppHistoryListeners();
24 navigation.addEventListener(
"navigate", e =
> {
25 e.transitionWhile(new Promise(r =
> t.step_timeout(r,
1)));
27 if (location.hash ===
"#1") {
28 fromHash1 = navigation.currentEntry;
32 location.href =
"/common/blank.html#1";
33 location.href =
"/common/blank.html#2";
35 Promise.resolve().then(() =
> recorder.record(
"promise microtask"));
37 await recorder.readyToAssert;
40 /* event name, location.hash value, navigation.transition properties */
41 [
"navigate",
"", null],
42 [
"currententrychange",
"#1", { from: fromStart, navigationType:
"push" }],
43 [
"AbortSignal abort",
"#1", { from: fromStart, navigationType:
"push" }],
44 [
"navigateerror",
"#1", { from: fromStart, navigationType:
"push" }],
46 [
"navigate",
"#1", null],
47 [
"currententrychange",
"#2", { from: fromHash1, navigationType:
"push" }],
48 [
"transition.finished rejected",
"#2", { from: fromHash1, navigationType:
"push" }],
49 [
"promise microtask",
"#2", { from: fromHash1, navigationType:
"push" }],
50 [
"navigatesuccess",
"#2", { from: fromHash1, navigationType:
"push" }],
51 [
"transition.finished fulfilled",
"#2", null]
54 recorder.assertErrorsAreAbortErrors();
55 },
"event and promise ordering when location.href is set repeatedly and handled by transitionWhile()");