1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
9 <input id=
"input-empty" name=
"victim" type=
"text" required
/>
10 <input id=
"input-pattern-mismatch" name=
"victim" type=
"text" pattern=
"Lorem ipsum" value=
"Loremipsum"/>
11 <textarea id=
"textarea" name=
"victim" required
></textarea>
12 <select id=
"select-no-explicit-value" required
>
13 <option>empty
</option>
14 <option>another
</option>
16 <select id=
"select-placeholder" name=
"victim" required
>
17 <option value=
"" selected
/>
18 <option value=
"X">X
</option>
20 <select id=
"select-non-placeholder" name=
"victim" required
>
21 <option value=
"X">X
</option>
22 <option value=
"" selected
/>
25 <div id=
"console"></div>
27 function checkValidityFor(id
) {
28 return document
.getElementById(id
).checkValidity();
31 description("This test checks if checkValidity() returns correctly a false (meaning error) result on invalid elements, and returns a true result on a blank but valid elements. Blank but non-placeholder label options are valid.");
33 shouldBeFalse('checkValidityFor("input-empty")');
34 shouldBeFalse('checkValidityFor("input-pattern-mismatch")');
35 shouldBeFalse('checkValidityFor("textarea")');
36 shouldBeTrue('checkValidityFor("select-no-explicit-value")');
37 shouldBeFalse('checkValidityFor("select-placeholder")');
38 shouldBeTrue('checkValidityFor("select-non-placeholder")');