anchor-jsurl-form-submit.html (1151B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> 4 <link rel="help" href="https://html.spec.whatwg.org/C/#following-hyperlinks"> 5 <title>Anchor element with onclick form submission and href to javascript: url</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <!-- When an anchor element has an onclick handler which submits a form, 10 the anchor's navigation should occur instead of the form's navigation. 11 However, if the anchor has an href which returns undefined, then the form 12 should be submitted. --> 13 14 <iframe name="test"></iframe> 15 <form target="test" action="resources/form.html"></form> 16 <a id="anchor" target="test" onclick="document.forms[0].submit()" href="javascript:void(0)">Test</a> 17 18 <script> 19 async_test(t => { 20 const anchor = document.getElementById('anchor'); 21 t.step(() => anchor.click()); 22 window.onmessage = t.step_func(event => { 23 if (typeof event.data === 'string' && event.data.includes('navigation')) { 24 assert_equals(event.data, 'form navigation'); 25 t.done(); 26 } 27 }); 28 }); 29 </script>