submit-crossdocument-crossorigin.html (1119B)
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 7 <script> 8 async_test(t => { 9 const url = new URL("resources/cross-origin-iframe-helper.html", location.href); 10 url.hostname = get_host_info().REMOTE_HOST; 11 const iframe = document.createElement("iframe") 12 iframe.src = url; 13 iframe.name = "windowname"; 14 document.body.append(iframe); 15 16 const form = document.createElement("form"); 17 form.action = url; 18 form.target = iframe.name; 19 form.innerHTML = `<input type="hidden" name="postMessage-top-when-done" value="yes">`; 20 document.body.append(form); 21 22 window.onmessage = t.step_func_done(e => { 23 // If we hit onnavigate in the target window, we'll get a different message, and fail. 24 assert_equals(e.data, "DONE"); 25 }); 26 27 navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window"); 28 window.onload = t.step_func(() => form.submit()); 29 }, "submitting a <form> element that navigates cross-document targeting a cross-origin window"); 30 </script>