cross-origin-traversal-does-not-fire-navigate.html (1306B)
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 <script src="/common/get-host-info.sub.js"></script> 6 <script> 7 promise_test(async t => { 8 // Open a cross-origin window. 9 let w = window.open(get_host_info().HTTP_REMOTE_ORIGIN + "/navigation-api/navigate-event/resources/opener-postMessage-onpageshow.html"); 10 await new Promise(resolve => window.onmessage = resolve); 11 12 // Navigate the opened window to this origin. 13 w.location = get_host_info().ORIGIN + "/navigation-api/navigate-event/resources/opener-postMessage-onpageshow.html"; 14 await new Promise(resolve => window.onmessage = resolve); 15 assert_equals(w.navigation.entries().length, 1); 16 assert_equals(w.navigation.currentEntry.index, 0); 17 18 // Go back. This should not fire a navigate event, because the traversal is 19 // cross-origin. Note that history.back() must be used instead of 20 // navigation.back() because navigation.back() can never go cross-origin. 21 w.navigation.onnavigate = t.unreached_func("navigate should not fire"); 22 w.history.back(); 23 await new Promise(resolve => window.onmessage = resolve); 24 }, "A cross-origin traversal does not fire the navigate event"); 25 </script>