key-navigate-back-cross-document-helper.html (982B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script> 4 // Wait for after the load event so that the navigation doesn't get converted 5 // into a replace navigation. 6 window.onload = () => step_timeout(() => { 7 if (location.search == "?go-back") { 8 assert_equals(navigation.entries().length, 2); 9 assert_equals(navigation.currentEntry.index, 1); 10 // Step 2: Navigate back. 11 history.back(); 12 return; 13 } 14 if (top.start_key) { 15 assert_equals(navigation.entries().length, 2); 16 assert_equals(navigation.currentEntry.index, 0); 17 // Step 3: Notify parent, which will ensure the same key is used after back navigation. 18 top.finish(navigation.currentEntry.key, navigation.currentEntry.id); 19 return; 20 } 21 // Step 1: Record initial key and navigate. 22 assert_equals(navigation.entries().length, 1); 23 top.start_key = navigation.currentEntry.key; 24 top.start_id = navigation.currentEntry.id; 25 location.search = "go-back"; 26 }, 0); 27 </script>