navigation-traverseTo-top-cancels-cross-document-child.html (1540B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="../navigation-methods/return-value/resources/helpers.js"></script> 5 <iframe id="i" src="/common/blank.html"></iframe> 6 <script> 7 promise_test(async t => { 8 let start_length = navigation.entries().length; 9 let start_index = navigation.currentEntry.index; 10 11 // Wait for after the load event so that the navigation doesn't get converted 12 // into a replace navigation. 13 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 14 await navigation.navigate("#").finished; 15 i.contentWindow.navigation.navigate("?"); 16 await new Promise(resolve => i.onload = () => t.step_timeout(resolve, 0)); 17 18 assert_equals(navigation.entries().length, start_length + 1); 19 assert_equals(i.contentWindow.navigation.entries().length, 2); 20 assert_equals(navigation.currentEntry.index, start_index + 1); 21 assert_equals(i.contentWindow.navigation.currentEntry.index, 1); 22 23 navigation.onnavigate = t.step_func(e => e.preventDefault()); 24 i.contentWindow.navigation.onnavigate = t.unreached_func("navigation should be cancelled before iframe fires navigate event"); 25 await assertBothRejectDOM(t, navigation.traverseTo(navigation.entries()[start_index].key), "AbortError"); 26 // Give the iframe time to navigate in case it was incorrectly permitted. 27 await new Promise(resolve => t.step_timeout(resolve, 50)); 28 }, "navigate.traverseTo() cancelled by top frame cancels cross-document iframe"); 29 </script>