input-submit-remove-jssubmit.html (1404B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-2"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <iframe name="frame" id="frame"></iframe> 8 <form id="form" target="frame" action="does_not_exist.html"> 9 <input id="input" name="name" value="foo"> 10 <input id="submitbutton" type="submit"></input> 11 </form> 12 13 <script> 14 async_test(t => { 15 window.addEventListener('load', () => { 16 const frame = document.getElementById('frame'); 17 frame.addEventListener('load', t.step_func_done(() => { 18 const expected = (new URL("does_not_exist.html?name=bar", location.href)).href; 19 assert_equals(frame.contentWindow.location.href, expected); 20 })); 21 22 const form = document.getElementById('form'); 23 const input = document.getElementById('input'); 24 const submitButton = document.getElementById('submitbutton'); 25 submitButton.addEventListener('click', event => { 26 submitButton.remove(); 27 form.submit(); 28 input.value = "bar"; 29 form.submit(); 30 input.value = "baz"; 31 }); 32 33 submitButton.click(); 34 }); 35 }, 'This test will pass if a form navigation successfully occurs when clicking a <input type=submit> element with a onclick event handler which removes the input and then calls form.submit().'); 36 </script>