Bug 1757847 [wpt PR 33036] - Update wpt metadata, a=testonly
[gecko.git] / testing / web-platform / tests / app-history / navigate / disambigaute-goto-forward-multiple.html
blobf8e78c4b1d951d7c29f326bcdacbf1c688d3635c
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 promise_test(async t => {
7 // Wait for after the load event so that the navigation doesn't get converted
8 // into a replace navigation.
9 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
10 assert_equals(navigation.entries().length, 1);
11 assert_equals(i.contentWindow.navigation.entries().length, 1);
12 let initial_key = navigation.currentEntry.key;
13 await navigation.navigate("#top1").committed;
14 await navigation.navigate("#top2").committed;
15 assert_equals(navigation.entries().length, 3);
16 assert_equals(i.contentWindow.navigation.entries().length, 1);
17 await i.contentWindow.navigation.navigate("#1").committed;
18 assert_equals(navigation.entries().length, 3);
19 assert_equals(i.contentWindow.navigation.entries().length, 2);
20 assert_equals(navigation.currentEntry.index, 2);
21 assert_equals(i.contentWindow.navigation.currentEntry.index, 1);
22 assert_true(navigation.canGoBack);
23 assert_true(i.contentWindow.navigation.canGoBack);
24 let final_key = navigation.currentEntry.key;
26 await i.contentWindow.navigation.back().committed;
27 assert_equals(navigation.currentEntry.index, 2);
28 assert_equals(i.contentWindow.navigation.currentEntry.index, 0);
29 await navigation.traverseTo(initial_key).committed;
30 assert_equals(navigation.currentEntry.index, 0);
31 assert_equals(i.contentWindow.navigation.currentEntry.index, 0);
32 // There are 2 joint session history entries containing the top window's
33 // final key. Navigate to the nearest one (which navigates only the
34 // top window).
35 await navigation.traverseTo(final_key).committed;
36 assert_equals(navigation.currentEntry.index, 2);
37 assert_equals(i.contentWindow.navigation.currentEntry.index, 0);
38 }, "navigation.traverseTo() goes to the nearest entry when going forward");
39 </script>