disambigaute-traverseTo-forward-multiple.html (2151B)
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 let start_length = navigation.entries().length; 8 let start_index = navigation.currentEntry.index; 9 // Wait for after the load event so that the navigation doesn't get converted 10 // into a replace navigation. 11 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 12 assert_equals(navigation.entries().length, start_length); 13 assert_equals(i.contentWindow.navigation.entries().length, 1); 14 let initial_key = navigation.currentEntry.key; 15 await navigation.navigate("#top1").committed; 16 await navigation.navigate("#top2").committed; 17 assert_equals(navigation.entries().length, start_length+2); 18 assert_equals(i.contentWindow.navigation.entries().length, 1); 19 await i.contentWindow.navigation.navigate("#1").committed; 20 assert_equals(navigation.entries().length, start_length+2); 21 assert_equals(i.contentWindow.navigation.entries().length, 2); 22 assert_equals(navigation.currentEntry.index, start_index+2); 23 assert_equals(i.contentWindow.navigation.currentEntry.index, 1); 24 assert_true(navigation.canGoBack); 25 assert_true(i.contentWindow.navigation.canGoBack); 26 let final_key = navigation.currentEntry.key; 27 28 await i.contentWindow.navigation.back().committed; 29 assert_equals(navigation.currentEntry.index, start_index+2); 30 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 31 await navigation.traverseTo(initial_key).committed; 32 assert_equals(navigation.currentEntry.index, start_index); 33 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 34 // There are 2 joint session history entries containing the top window's 35 // final key. Navigate to the nearest one (which navigates only the 36 // top window). 37 await navigation.traverseTo(final_key).committed; 38 assert_equals(navigation.currentEntry.index, start_index+2); 39 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 40 }, "navigation.traverseTo() goes to the nearest entry when going forward"); 41 </script>