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 / traverseTo-detach-between-navigate-and-navigatesuccess.html
blob9a9529578147b557c83a10f499227645b0ceb746
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <script src="return-value/resources/helpers.js"></script>
6 <iframe id="i" src="/common/blank.html"></iframe>
8 <script>
9 async_test(t => {
10 window.onload = t.step_func(() => {
11 const iWindow = i.contentWindow;
12 const iDOMException = iWindow.DOMException;
13 const iAppHistoryEntry = iWindow.AppHistoryEntry;
15 i.contentWindow.navigation.navigate("#1").finished.then(t.step_func(() => {
16 assert_equals(i.contentWindow.navigation.entries().length, 2);
17 let key = i.contentWindow.navigation.entries()[0].key;
19 let onnavigateerror_called = false;
20 let result;
22 i.contentWindow.navigation.onnavigate = t.step_func(e => {
23 e.transitionWhile(new Promise(resolve => () => t.step_timeout(resolve, 2)));
24 t.step_timeout(() => i.remove(), 1);
25 });
27 i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("navigatesuccess must not fire");
29 i.contentWindow.navigation.onnavigateerror = t.step_func(e => {
30 assert_false(onnavigateerror_called);
31 onnavigateerror_called = true;
32 assert_equals(e.filename, location.href);
33 assert_greater_than(e.lineno, 0);
34 assert_greater_than(e.colno, 0);
36 assertCommittedFulfillsFinishedRejectsExactly(t, result, iWindow.navigation.currentEntry, e.error, iWindow, iDOMException, iAppHistoryEntry).then(
37 () => t.done(),
38 t.step_func(err => { throw err; })
40 });
42 result = i.contentWindow.navigation.traverseTo(key);
43 }));
44 });
45 }, "Detach a window between when a traverseTo() fires navigate and navigatesuccess");
46 </script>