OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <title>required and basic valueMissing 2</title> | |
5 <script src="../../resources/js-test.js"></script> | |
6 </head> | |
7 <body> | |
8 <p id="description"></p> | |
9 <div id="console"></div> | |
10 <div id=parent> | |
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> | |
14 <option value="" /> | |
15 <option value="X" selected>X</option> | |
16 </select> | |
17 <select id="select-without-placeholder" name="victim" required> | |
18 <option value="X" selected>X</option> | |
19 <option value="" /> | |
20 </select> | |
21 <select id="select-with-fake-placeholder-size2" name="victim" size="2" required> | |
22 <option value="" /> | |
23 <option value="X" selected>X</option> | |
24 </select> | |
25 <select id="select-without-fake-placeholder-size2" name="victim" size="2" requir
ed> | |
26 <option value="X" selected>X</option> | |
27 <option value="" /> | |
28 </select> | |
29 <select id="select-with-fake-placeholder-multiple" name="victim" multiple requir
ed> | |
30 <option value="" /> | |
31 <option value="X" selected>X</option> | |
32 </select> | |
33 <select id="select-without-fake-placeholder-multiple" name="victim" multiple req
uired> | |
34 <option value="X" selected>X</option> | |
35 <option value="" /> | |
36 </select> | |
37 <select id="select-with-fake-placeholder-size2-multiple" name="victim" multiple
size="2" required> | |
38 <option value="" /> | |
39 <option value="X" selected>X</option> | |
40 </select> | |
41 <select id="select-without-fake-placeholder-size2-multiple" name="victim" multip
le size="2" required> | |
42 <option value="X" selected>X</option> | |
43 <option value="" /> | |
44 </select> | |
45 <select id=select-selecting-by-key required> | |
46 <option value="" selected/> | |
47 <option>a</option> | |
48 </select> | |
49 <select id=select-selecting-by-key-2 required> | |
50 <option value="" selected/> | |
51 <option accesskey="1">a</option> | |
52 </select> | |
53 </div> | |
54 <script language="JavaScript" type="text/javascript"> | |
55 function valueMissingFor(id) { | |
56 return document.getElementById(id).validity.valueMissing; | |
57 } | |
58 | |
59 description("This test checks validity.valueMissing with some values or opti
ons with some values selected."); | |
60 | |
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-multip
le")'); | |
71 | |
72 // Need to use eventSender instead of initKeyboardEvent() because we can't | |
73 // make an event which returns a correct value for keyCode by initKeyboardEv
ent(). | |
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")'); | |
79 select.focus(); | |
80 eventSender.keyDown("a"); | |
81 shouldBe('select.value', '"a"'); | |
82 shouldBeFalse('valueMissingFor("select-selecting-by-key")'); | |
83 | |
84 // Select by accesskey. | |
85 select = document.getElementById("select-selecting-by-key-2"); | |
86 shouldBeTrue('valueMissingFor("select-selecting-by-key-2")'); | |
87 select.focus(); | |
88 eventSender.keyDown("1", "accessKey"); | |
89 shouldBe('select.value', '"a"'); | |
90 shouldBeFalse('valueMissingFor("select-selecting-by-key-2")'); | |
91 } else { | |
92 debug('There are tests using eventSender.'); | |
93 } | |
94 | |
95 document.body.removeChild(document.getElementById('parent')); | |
96 </script> | |
97 </body> | |
98 </html> | |
OLD | NEW |