summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/ValidityState-valueMissing-002.html
blob: a793c397b68c5998e1ab967c350c788a941c6481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>required and basic valueMissing 2</title>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<div id=parent>
<input id="input" name="victim" value="something" required/>
<textarea id="textarea" name="victim" required>something</textarea>
<select id="select-with-placeholder" name="victim" required>
  <option value="" />
  <option value="X" selected>X</option>
</select>
<select id="select-without-placeholder" name="victim" required>
  <option value="X" selected>X</option>
  <option value="" />
</select>
<select id="select-with-fake-placeholder-size2" name="victim" size="2" required>
  <option value="" />
  <option value="X" selected>X</option>
</select>
<select id="select-without-fake-placeholder-size2" name="victim" size="2" required>
  <option value="X" selected>X</option>
  <option value="" />
</select>
<select id="select-with-fake-placeholder-multiple" name="victim" multiple required>
  <option value="" />
  <option value="X" selected>X</option>
</select>
<select id="select-without-fake-placeholder-multiple" name="victim" multiple required>
  <option value="X" selected>X</option>
  <option value="" />
</select>
<select id="select-with-fake-placeholder-size2-multiple" name="victim" multiple size="2" required>
  <option value="" />
  <option value="X" selected>X</option>
</select>
<select id="select-without-fake-placeholder-size2-multiple" name="victim" multiple size="2" required>
  <option value="X" selected>X</option>
  <option value="" />
</select>
<select id=select-selecting-by-key required>
  <option value="" selected/>
  <option>a</option>
</select>
<select id=select-selecting-by-key-2 required>
  <option value="" selected/>
  <option accesskey="1">a</option>
</select>
</div>
<script language="JavaScript" type="text/javascript">
    function valueMissingFor(id) {
        return document.getElementById(id).validity.valueMissing;
    }

    description("This test checks validity.valueMissing with some values or options with some values selected.");

    shouldBeFalse('valueMissingFor("input")');
    shouldBeFalse('valueMissingFor("textarea")');
    shouldBeFalse('valueMissingFor("select-with-placeholder")');
    shouldBeFalse('valueMissingFor("select-without-placeholder")');
    shouldBeFalse('valueMissingFor("select-with-fake-placeholder-size2")');
    shouldBeFalse('valueMissingFor("select-without-fake-placeholder-size2")');
    shouldBeFalse('valueMissingFor("select-with-fake-placeholder-multiple")');
    shouldBeFalse('valueMissingFor("select-without-fake-placeholder-multiple")');
    shouldBeFalse('valueMissingFor("select-with-fake-placeholder-size2-multiple")');
    shouldBeFalse('valueMissingFor("select-without-fake-placeholder-size2-multiple")');

    // Need to use eventSender instead of initKeyboardEvent() because we can't
    // make an event which returns a correct value for keyCode by initKeyboardEvent().
    if (window.eventSender) {
        debug("Updating valueMissing state by a key input:")
        // Select by type-ahead.
        var select = document.getElementById("select-selecting-by-key");
        shouldBeTrue('valueMissingFor("select-selecting-by-key")');
        select.focus();
        eventSender.keyDown("a");
        shouldBe('select.value', '"a"');
        shouldBeFalse('valueMissingFor("select-selecting-by-key")');

        // Select by accesskey.
        select = document.getElementById("select-selecting-by-key-2");
        shouldBeTrue('valueMissingFor("select-selecting-by-key-2")');
        select.focus();
        eventSender.keyDown("1", "accessKey");
        shouldBe('select.value', '"a"');
        shouldBeFalse('valueMissingFor("select-selecting-by-key-2")');
    } else {
        debug('There are tests using eventSender.');
    }

    document.body.removeChild(document.getElementById('parent'));
</script>
</body>
</html>