| <script src="../../resources/js-test-pre.js"></script> |
| <form id=f action="interactive-validation-cancel.html"> |
| <input type=hidden name=submitted value="true"> |
| <input name=i0 required id="i0"> |
| <input type=submit id="s"> |
| description('Test if the form is not submitted even if an "invalid" event for a control is canceled.'); |
| function startOrVerify() { |
| var query = window.location.search; |
| if (query.indexOf('submitted=true') != -1) { |
| testFailed('The form should not be submitted.'); |
| shouldBeTrue('location.search.indexOf("i0=") != -1'); |
| document.getElementById('i0').addEventListener('invalid', cancel, false); |
| // HTMLFormElement::submit() skips validation. Use the submit button. |
| document.getElementById('s').click(); |
| testPassed('The form was not submitted.'); |
| testRunner.waitUntilDone(); |
| window.onload = startOrVerify; |