dispose-cross-document.html (1599B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="iframe" src="/common/blank.html"></iframe> 5 <script> 6 promise_test(async (t) => { 7 // Wait for after the load event so that the navigation doesn't get converted 8 // into a replace navigation. 9 await new Promise(r => window.onload = () => t.step_timeout(r, 0)); 10 11 iframe.contentWindow.location.search = "?1"; 12 await new Promise(r => iframe.onload = () => t.step_timeout(r, 0)); 13 14 const keyFor1 = iframe.contentWindow.navigation.currentEntry.key; 15 16 iframe.contentWindow.location.search = "?2"; 17 await new Promise(r => iframe.onload = () => t.step_timeout(r, 0)); 18 iframe.contentWindow.location.search = "?3"; 19 await new Promise(r => iframe.onload = () => t.step_timeout(r, 0)); 20 21 iframe.contentWindow.navigation.traverseTo(keyFor1); 22 await new Promise(r => iframe.onload = () => t.step_timeout(r, 0)); 23 24 assert_equals((new URL(iframe.contentWindow.location.href)).search, "?1"); 25 26 assert_equals(iframe.contentWindow.navigation.entries().length, 4); 27 const [, entry2, entry3] = iframe.contentWindow.navigation.entries(); 28 29 entry2.ondispose = t.unreached_func("entry2 dispose must not fire"); 30 entry2.addEventListener("dispose", t.unreached_func("entry3 dispose must not fire")); 31 32 iframe.contentWindow.navigation.navigate("/common/blank.html?fork"); 33 await new Promise(r => iframe.onload = r); 34 35 // Test passes if we reached this point with no dispose events firing. 36 }, "No dispose events are fired due to cross-document forward pruning"); 37 </script>