navigate-replace-same-document.html (966B)
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 // Wait for after the load event so that the navigation doesn't get converted 7 // into a replace navigation. 8 await new Promise(resolve => window.onload = resolve); 9 await new Promise(resolve => t.step_timeout(resolve, 0)); 10 11 let start_length = navigation.entries().length; 12 let start_history_length = history.length; 13 let key1 = navigation.currentEntry.key; 14 await navigation.navigate("#1").committed; 15 let key2 = navigation.currentEntry.key; 16 assert_not_equals(key1, key2); 17 await navigation.navigate("#2", { history: "replace" }).committed; 18 let key3 = navigation.currentEntry.key; 19 assert_equals(key2, key3); 20 assert_equals(navigation.entries().length, start_length + 1); 21 assert_equals(history.length, start_history_length + 1); 22 }, "navigate() with history: 'replace' option"); 23 </script>