submission-checks.window.js (2107B)
1 async_test(t => { 2 const frame = document.createElement("frame"), 3 form = document.createElement("form"); 4 t.add_cleanup(() => frame.remove()); 5 form.action = "/common/blank.html"; 6 form.target = "doesnotmattertwobits"; 7 frame.name = "doesnotmattertwobits"; 8 document.body.appendChild(frame); 9 frame.onload = t.step_func(() => { 10 if(frame.contentWindow.location.href === "about:blank") 11 return; 12 assert_unreached(); 13 }); 14 form.submit(); 15 t.step_timeout(() => { 16 assert_equals(frame.contentWindow.location.href, "about:blank"); 17 t.done(); 18 }, 500); 19 }, "<form> not connected to a document cannot navigate"); 20 21 async_test(t => { 22 const frame = document.createElement("frame"), 23 form = document.createElement("form"); 24 t.add_cleanup(() => frame.remove()); 25 form.action = "/common/blank.html"; 26 form.target = "doesnotmattertwoqbits"; 27 form.onsubmit = t.step_func(() => form.remove()); 28 frame.name = "doesnotmattertwoqbits"; 29 document.body.appendChild(frame); 30 document.body.appendChild(form); 31 frame.onload = t.step_func(() => { 32 if(frame.contentWindow.location.href === "about:blank") 33 return; 34 assert_unreached(); 35 }); 36 const submit = form.appendChild(document.createElement("input")); 37 submit.type = "submit" 38 submit.click(); 39 t.step_timeout(() => { 40 assert_equals(frame.contentWindow.location.href, "about:blank"); 41 t.done(); 42 }, 500); 43 }, "<form> not connected to a document after submit event cannot navigate"); 44 45 async_test(t => { 46 const frame = document.createElement("frame"), 47 form = document.createElement("form"); 48 t.add_cleanup(() => frame.remove()); 49 form.action = "/"; 50 document.body.appendChild(frame); 51 frame.contentDocument.body.appendChild(form); 52 frame.onload = t.step_func(() => { 53 if(frame.contentWindow.location.href === "about:blank") 54 return; 55 form.submit(); 56 t.step_timeout(() => { 57 assert_equals(frame.contentWindow.location.pathname, "/common/blank.html"); 58 t.done(); 59 }, 500) 60 }); 61 frame.src = "/common/blank.html"; 62 }, "<form> in a navigated document cannot navigate");