disambigaute-back.html (1641B)
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 i.contentWindow.navigation.navigate("#1"); 18 assert_equals(navigation.entries().length, start_length+1); 19 assert_equals(i.contentWindow.navigation.entries().length, 2); 20 assert_equals(navigation.currentEntry.index, start_index+1); 21 assert_equals(i.contentWindow.navigation.currentEntry.index, 1); 22 assert_true(navigation.canGoBack); 23 assert_true(i.contentWindow.navigation.canGoBack); 24 25 // There are 2 joint session history entries containing the iframe's 26 // previous key. Navigate to the nearest one (which navigates the iframe 27 // but not the top window). 28 i.contentWindow.navigation.back().committed.then(t.step_func_done(() => { 29 assert_equals(navigation.currentEntry.index, start_index+1); 30 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 31 })); 32 }, 0); 33 }, "navigation.back() goes to the nearest back entry"); 34 </script>