traverseTo-with-cross-origin-in-history.html (1585B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/common/get-host-info.sub.js"></script> 5 <body> 6 <script> 7 async_test(t => { 8 let cross_origin_url = new URL(get_host_info().HTTPS_REMOTE_ORIGIN); 9 cross_origin_url.pathname = "/common/blank.html"; 10 let i = document.createElement("iframe"); 11 i.src = cross_origin_url; 12 document.body.appendChild(i); 13 14 let start_length = history.length; 15 16 // Wait for after the load event so that the navigation doesn't get converted 17 // into a replace navigation. 18 window.onload = () => t.step_timeout(() => { 19 i.contentWindow.location = "/common/blank.html"; 20 i.onload = () => t.step_timeout(() => { 21 assert_equals(history.length, start_length + 1); 22 assert_equals(i.contentWindow.navigation.entries().length, 1); 23 i.contentWindow.navigation.navigate("#fragment"); 24 assert_equals(i.contentWindow.navigation.entries().length, 2); 25 i.contentWindow.navigation.back().committed.then(t.step_func(() => { 26 assert_equals(i.contentWindow.navigation.entries().length, 2); 27 assert_equals(i.contentWindow.navigation.currentEntry.index, 0); 28 return i.contentWindow.navigation.forward().committed; 29 })).then(t.step_func_done(() => { 30 assert_equals(i.contentWindow.navigation.entries().length, 2); 31 assert_equals(i.contentWindow.navigation.currentEntry.index, 1); 32 })); 33 }, 0); 34 }, 0); 35 }, "navigation.traverseTo() should work in an iframe that has navigated across origins"); 36 </script> 37 </body>