navigate-navigation-back-cross-document.html (1540B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="i" src="/common/blank.html"></iframe> 5 <script> 6 async_test(t => { 7 window.onload = t.step_func(() => { 8 let target_key = i.contentWindow.navigation.currentEntry.key; 9 let target_id = i.contentWindow.navigation.currentEntry.id; 10 i.contentWindow.navigation.navigate("?foo"); 11 i.onload = t.step_func(() => { 12 let beforeunload_called = false; 13 i.contentWindow.navigation.onnavigate = t.step_func_done(e => { 14 assert_true(beforeunload_called); 15 assert_equals(e.navigationType, "traverse"); 16 assert_false(e.cancelable); 17 assert_false(e.canIntercept); 18 assert_false(e.userInitiated); 19 assert_false(e.hashChange); 20 assert_equals(e.downloadRequest, null); 21 assert_equals(new URL(e.destination.url).pathname, "/common/blank.html"); 22 assert_false(e.destination.sameDocument); 23 assert_equals(e.destination.key, target_key); 24 assert_equals(e.destination.id, target_id); 25 assert_equals(e.destination.index, 0); 26 assert_equals(e.formData, null); 27 assert_equals(e.info, "hi"); 28 assert_equals(e.sourceElement, null); 29 }); 30 i.contentWindow.onbeforeunload = () => beforeunload_called = true; 31 assert_true(i.contentWindow.navigation.canGoBack); 32 i.contentWindow.navigation.back({ info: "hi" }); 33 }) 34 }); 35 }, "navigate event for navigation.back() - cross-document"); 36 </script>