disambigaute-traverseTo-back-multiple.html (1804B)
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 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 window.onload = () => t.step_timeout(() => { 12 assert_equals(navigation.entries().length, start_length); 13 assert_equals(i.contentWindow.navigation.entries().length, 1); 14 navigation.navigate("#top"); 15 assert_equals(navigation.entries().length, start_length+1); 16 assert_equals(i.contentWindow.navigation.entries().length, 1); 17 18 let iframe_initial_key = i.contentWindow.navigation.currentEntry.key; 19 i.contentWindow.navigation.navigate("#1"); 20 i.contentWindow.navigation.navigate("#2"); 21 assert_equals(navigation.entries().length, start_length+1); 22 assert_equals(i.contentWindow.navigation.entries().length, 3); 23 assert_equals(navigation.currentEntry.index, start_index+1); 24 assert_equals(i.contentWindow.navigation.currentEntry.index, 2); 25 assert_true(navigation.canGoBack); 26 assert_true(i.contentWindow.navigation.canGoBack); 27 28 // There are 2 joint session history entries containing the iframe's 29 // initial key. Navigate to the nearest one (which navigates the iframe 30 // but not the top window). 31 i.contentWindow.navigation.traverseTo(iframe_initial_key).committed.then(t.step_func_done(() => { 32 assert_equals(navigation.currentEntry.index, start_index+1); 33 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 34 })); 35 }, 0); 36 }, "navigation.traverseTo() goes to the nearest entry when going back"); 37 </script>