1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <title>required and basic valueMissing
2</title>
5 <script src=
"../../resources/js-test.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
11 <input id=
"input" name=
"victim" value=
"something" required
/>
12 <textarea id=
"textarea" name=
"victim" required
>something
</textarea>
13 <select id=
"select-with-placeholder" name=
"victim" required
>
15 <option value=
"X" selected
>X
</option>
17 <select id=
"select-without-placeholder" name=
"victim" required
>
18 <option value=
"X" selected
>X
</option>
21 <select id=
"select-with-fake-placeholder-size2" name=
"victim" size=
"2" required
>
23 <option value=
"X" selected
>X
</option>
25 <select id=
"select-without-fake-placeholder-size2" name=
"victim" size=
"2" required
>
26 <option value=
"X" selected
>X
</option>
29 <select id=
"select-with-fake-placeholder-multiple" name=
"victim" multiple required
>
31 <option value=
"X" selected
>X
</option>
33 <select id=
"select-without-fake-placeholder-multiple" name=
"victim" multiple required
>
34 <option value=
"X" selected
>X
</option>
37 <select id=
"select-with-fake-placeholder-size2-multiple" name=
"victim" multiple
size=
"2" required
>
39 <option value=
"X" selected
>X
</option>
41 <select id=
"select-without-fake-placeholder-size2-multiple" name=
"victim" multiple
size=
"2" required
>
42 <option value=
"X" selected
>X
</option>
45 <select id=select-selecting-by-key required
>
46 <option value=
"" selected
/>
49 <select id=select-selecting-by-key-
2 required
>
50 <option value=
"" selected
/>
51 <option accesskey=
"1">a
</option>
54 <script language=
"JavaScript" type=
"text/javascript">
55 function valueMissingFor(id
) {
56 return document
.getElementById(id
).validity
.valueMissing
;
59 description("This test checks validity.valueMissing with some values or options with some values selected.");
61 shouldBeFalse('valueMissingFor("input")');
62 shouldBeFalse('valueMissingFor("textarea")');
63 shouldBeFalse('valueMissingFor("select-with-placeholder")');
64 shouldBeFalse('valueMissingFor("select-without-placeholder")');
65 shouldBeFalse('valueMissingFor("select-with-fake-placeholder-size2")');
66 shouldBeFalse('valueMissingFor("select-without-fake-placeholder-size2")');
67 shouldBeFalse('valueMissingFor("select-with-fake-placeholder-multiple")');
68 shouldBeFalse('valueMissingFor("select-without-fake-placeholder-multiple")');
69 shouldBeFalse('valueMissingFor("select-with-fake-placeholder-size2-multiple")');
70 shouldBeFalse('valueMissingFor("select-without-fake-placeholder-size2-multiple")');
72 // Need to use eventSender instead of initKeyboardEvent() because we can't
73 // make an event which returns a correct value for keyCode by initKeyboardEvent().
74 if (window
.eventSender
) {
75 debug("Updating valueMissing state by a key input:")
76 // Select by type-ahead.
77 var select
= document
.getElementById("select-selecting-by-key");
78 shouldBeTrue('valueMissingFor("select-selecting-by-key")');
80 eventSender
.keyDown("a");
81 shouldBe('select.value', '"a"');
82 shouldBeFalse('valueMissingFor("select-selecting-by-key")');
84 // Select by accesskey.
85 select
= document
.getElementById("select-selecting-by-key-2");
86 shouldBeTrue('valueMissingFor("select-selecting-by-key-2")');
89 if (navigator
.userAgent
.search(/\bMac OS X\b/) != -1)
90 modifiers
= ['ctrlKey', 'altKey'];
92 modifiers
= ['altKey'];
93 eventSender
.keyDown("1", modifiers
);
94 shouldBe('select.value', '"a"');
95 shouldBeFalse('valueMissingFor("select-selecting-by-key-2")');
97 debug('There are tests using eventSender.');
100 document
.body
.removeChild(document
.getElementById('parent'));