Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / ValidityState-valueMissing-002.html
blob67de1130f75af58d8a57cb667816dfdbc6d6c502
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" required>
26 <option value="X" selected>X</option>
27 <option value="" />
28 </select>
29 <select id="select-with-fake-placeholder-multiple" name="victim" multiple required>
30 <option value="" />
31 <option value="X" selected>X</option>
32 </select>
33 <select id="select-without-fake-placeholder-multiple" name="victim" multiple required>
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" multiple 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;
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")');
79 select.focus();
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")');
87 select.focus();
88 var modifiers;
89 if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
90 modifiers = ['ctrlKey', 'altKey'];
91 else
92 modifiers = ['altKey'];
93 eventSender.keyDown("1", modifiers);
94 shouldBe('select.value', '"a"');
95 shouldBeFalse('valueMissingFor("select-selecting-by-key-2")');
96 } else {
97 debug('There are tests using eventSender.');
100 document.body.removeChild(document.getElementById('parent'));
101 </script>
102 </body>
103 </html>