traverseTo-multiple-steps.html (1324B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script> 5 promise_test(async t => { 6 let start_length = navigation.entries().length; 7 let start_index = navigation.currentEntry.index; 8 // Wait for after the load event so that the navigation doesn't get converted 9 // into a replace navigation. 10 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 11 assert_equals(navigation.entries().length, start_length); 12 let key0 = navigation.currentEntry.key; 13 await navigation.navigate("#1").committed; 14 await navigation.navigate("#2").committed; 15 let key2 = navigation.currentEntry.key; 16 assert_equals(navigation.entries().length, start_length + 2); 17 18 await navigation.traverseTo(key0).committed; 19 assert_equals(navigation.entries().length, start_length + 2); 20 assert_equals(navigation.currentEntry, navigation.entries()[start_index]); 21 assert_equals(key0, navigation.currentEntry.key); 22 await navigation.traverseTo(key2).committed; 23 assert_equals(navigation.entries().length, start_length + 2); 24 assert_equals(navigation.currentEntry, navigation.entries()[start_index+2]); 25 assert_equals(key2, navigation.currentEntry.key); 26 }, "goto() can precisely traverse multiple steps in the joint session history"); 27 </script>