Bug 1760181 [wpt PR 33182] - App history API to navigation API rename (2/n), a=testonly
[gecko.git] / testing / web-platform / tests / navigation-api / state / cross-document-away-and-back.html
blob25d0c1e79811cea7de5b747aab2066caaceb558e
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <iframe id="i" src="/common/blank.html"></iframe>
5 <script>
6 async_test(t => {
7 window.onload = t.step_func(() => {
8 i.contentWindow.navigation.navigate("#", { replace : true, state : { data : "value" } });
9 assert_equals(i.contentWindow.navigation.entries().length, 1);
10 assert_equals(i.contentWindow.navigation.currentEntry.getState().data, "value");
12 let navigated_back = false;
13 i.contentWindow.navigation.navigate("?1");
14 i.onload = t.step_func(() => {
15 if (navigated_back) {
16 let back_entry = i.contentWindow.navigation.currentEntry;
17 assert_equals(i.contentWindow.navigation.entries().length, 2);
18 assert_equals(back_entry.index, 0);
19 assert_equals(back_entry.getState().data, "value");
20 t.done();
21 } else {
22 assert_equals(i.contentWindow.navigation.entries().length, 2);
23 assert_equals(i.contentWindow.navigation.currentEntry, i.contentWindow.navigation.entries()[1]);
24 assert_equals(i.contentWindow.navigation.currentEntry.getState(), undefined);
25 history.back();
26 navigated_back = true;
28 });
29 });
30 }, "appHistoryEntry.getState() behavior after navigating away and back");
31 </script>