submit-samedocument-crossorigin.html (1611B)
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 url.hash = "#foo"; 17 const form = document.createElement("form"); 18 form.action = url; 19 form.target = iframe.name; 20 document.body.append(form); 21 22 window.onmessage = t.step_func_done(e => { 23 assert_equals(e.data.navigationType, "push", "navigationType"); 24 assert_true(e.data.cancelable, "cancelable"); 25 assert_true(e.data.canIntercept, "canIntercept"); 26 assert_false(e.data.userInitiated, "userInitiated"); 27 assert_true(e.data.hashChange, "hashChange"); 28 assert_equals(e.data.formData, null, "formData"); 29 assert_equals(e.data.destination.url, form.action, "destination.url"); 30 assert_true(e.data.destination.sameDocument, "destination.sameDocument"); 31 assert_equals(e.data.destination.key, "", "destination.key"); 32 assert_equals(e.data.destination.id, "", "destination.id"); 33 assert_equals(e.data.destination.index, -1, "destination.index"); 34 }); 35 36 navigation.onnavigate = t.unreached_func("onnavigate must not fire in the source window"); 37 window.onload = t.step_func(() => form.submit()); 38 }, "submitting a <form> element that navigates same-document targeting a cross-origin window"); 39 </script>