entries-after-cross-document-forward-pruning.html (1330B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="resources/is_uuid.js"></script> 5 <iframe id="i" src="/common/blank.html"></iframe> 6 <script> 7 promise_test(async (t) => { 8 // Wait for after the load event so that the navigation doesn't get converted 9 // into a replace navigation. 10 await new Promise(r => window.onload = () => t.step_timeout(r, 0)); 11 12 i.contentWindow.location.search = "?2"; 13 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 14 15 i.contentWindow.location.search = "?3"; 16 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 17 18 i.contentWindow.history.back(); 19 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 20 21 i.contentWindow.history.back(); 22 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 23 24 i.contentWindow.location.search = "?fork"; 25 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 26 27 const entries = i.contentWindow.navigation.entries(); 28 const searches = entries.map(e => (new URL(e.url)).search); 29 assert_array_equals(searches, ["", "?fork"]); 30 31 assert_equals(i.contentWindow.navigation.entries().at(-1), i.contentWindow.navigation.currentEntry); 32 }, "navigation.entries() behavior after forward-pruning due to cross-document navs"); 33 </script>