Bug 1757847 [wpt PR 33036] - Update wpt metadata, a=testonly
[gecko.git] / testing / web-platform / tests / app-history / ordering-and-transition / location-href-double-transitionWhile.html
blob6e7c89502d60844035eea74f35530e81d63402cd
1 <!doctype html>
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">
7 <script type="module">
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;
15 let fromHash1;
17 const recorder = new Recorder({
18 skipCurrentChange: !hasVariant("currententrychange"),
19 finalExpectedEvent: "transition.finished fulfilled"
20 });
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;
30 });
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;
39 recorder.assert([
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]
52 ]);
54 recorder.assertErrorsAreAbortErrors();
55 }, "event and promise ordering when location.href is set repeatedly and handled by transitionWhile()");
56 </script>