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-cross-document-preventDefault.html
blob09c91ee647ef7ffa3a9906faa4f1c14e0e830ab7
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 <iframe id="i" src="/common/blank.html"></iframe>
8 <script>
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 assert_equals(i.contentWindow.navigation.entries().length, 1);
15 let key = i.contentWindow.navigation.currentEntry.key;
17 i.contentWindow.navigation.navigate("?1");
18 await new Promise(resolve => i.onload = resolve);
20 assert_equals(i.contentWindow.navigation.entries().length, 2);
21 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[1]);
23 // This will be a noop, because navigate events are uncancelable for traversals.
24 i.contentWindow.navigation.onnavigate = e => e.preventDefault();
26 assertNeverSettles(t, i.contentWindow.navigation.traverseTo(key), i.contentWindow);
27 await new Promise(resolve => i.onload = () => t.step_timeout(resolve, 0));
28 }, "traverseTo() promise never settle when preventDefault()ing the navigate event (cross-document)");
29 </script>