chromium/third_party/blink/web_tests/fast/forms/interactive-validation-prevented.html

<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<form id=f action="interactive-validation-prevented.html">
<input type=hidden name=submitted value=true>
<input name=i0 required id=i0 value="abc">
<input name=i1 required id=i1 style="display:none">
<input name=i2 required id=i2>
<input type=submit id=s>
</form>
<script>
description('Test if an invalid control prevents interactive form submission, and the first invalid focusable control gets focus.');

function startOrVerify() {
    var query = window.location.search;
    if (query.indexOf('submitted=true') != -1) {
        testFailed('The form should not be submitted.');
    } else {
        // Force to render the form.
        document.getElementById("f").offsetWidth;
        // HTMLFormElement::submit() skips validation. Use the submit button.
        document.getElementById('s').click();
        testPassed('The form was not submitted');
        shouldBe('document.activeElement', 'document.getElementById("i2")');
        debug('TEST COMPLETE');
    }

    if (window.testRunner)
        testRunner.notifyDone();
}

if (window.testRunner)
    testRunner.waitUntilDone();
window.onload = startOrVerify;
</script>
</body>
</html>