Bug 1760181 [wpt PR 33182] - App history API to navigation API rename (2/n), a=testonly
[gecko.git] / testing / web-platform / tests / navigation-api / navigation-methods / return-value / traverseTo-transitionWhile-rejected.html
blob613531023fa4bc6455e359d59541d0602b8906d5
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <script src="resources/helpers.js"></script>
6 <script>
7 promise_test(async t => {
8 // Wait for after the load event so that the navigation doesn't get converted
9 // into a replace navigation.
10 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
12 const key0 = navigation.currentEntry.key;
14 location.href = "#1";
16 assert_equals(navigation.entries().length, 2);
17 const [entry0, entry1] = navigation.entries();
18 assert_equals((new URL(entry0.url)).hash, "");
19 assert_equals((new URL(entry1.url)).hash, "#1");
21 const err = new Error("boo!");
22 const promise = Promise.reject(err);
23 promise.catch(() => {}); // prevent unhandled rejection testharness.js errors
24 navigation.onnavigate = e => e.transitionWhile(promise);
26 const result = navigation.traverseTo(key0);
27 await assertCommittedFulfillsFinishedRejectsExactly(t, result, entry0, err);
28 assert_equals(navigation.currentEntry, entry0);
29 }, "traverseTo() promise rejection with rejected transitionWhile()");
30 </script>