6de7a3c82559810fd06757a2dc132f8f71f6222f
[WebKit.git] / LayoutTests / fast / forms / ValidityState-customError.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
5 <script src="../../fast/js/resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <fieldset name="set" id="fieldset-set"></fieldset>
12 <button   name="set" id="button-set"></button>
13 <button   name="set" id="button-button-set" type="button"></button>
14 <button   name="set" id="button-reset-set" type="reset"></button>
15 <select   name="set" id="select-set"></select>
16 <textarea name="set" id="textarea-set"></textarea>
17 <input    name="set" id="input-set" />
18 <input    name="set" id="input-submit-set" type="submit" />
19
20 <fieldset name="set-and-empty" id="fieldset-set-and-empty"></fieldset>
21 <button   name="set-and-empty" id="button-set-and-empty"></button>
22 <button   name="set-and-empty" id="button-button-set-and-empty" type="button"></button>
23 <button   name="set-and-empty" id="button-reset-set-and-empty" type="reset"></button>
24 <select   name="set-and-empty" id="select-set-and-empty"></select>
25 <textarea name="set-and-empty" id="textarea-set-and-empty"></textarea>
26 <input    name="set-and-empty" id="input-set-and-empty" />
27 <input    name="set-and-empty" id="input-submit-set-and-empty" type="submit" />
28
29 <fieldset name="no-changes" id="fieldset-no-changes"></fieldset>
30 <button   name="no-changes" id="button-no-changes"></button>
31 <button   name="no-changes" id="button-button-no-changes" type="button"></button>
32 <button   name="no-changes" id="button-reset-no-changes" type="reset"></button>
33 <select   name="no-changes" id="select-no-changes"></select>
34 <textarea name="no-changes" id="textarea-no-changes"></textarea>
35 <input    name="no-changes" id="input-no-changes" />
36 <input    name="no-changes" id="input-submit-no-changes" type="submit" />
37
38 <fieldset name="many-changes" id="fieldset-many-changes"></fieldset>
39 <button   name="many-changes" id="button-many-changes"></button>
40 <button   name="many-changes" id="button-button-many-changes" type="button"></button>
41 <button   name="many-changes" id="button-reset-many-changes" type="reset"></button>
42 <select   name="many-changes" id="select-many-changes"></select>
43 <textarea name="many-changes" id="textarea-many-changes"></textarea>
44 <input    name="many-changes" id="input-many-changes" />
45 <input    name="many-changes" id="input-submit-many-changes" type="submit" />
46
47 <script language="JavaScript" type="text/javascript">
48 function customErrorFor(id) {
49     return document.getElementById(id).validity.customError;
50 }
51
52 description("This test checks validity.customError.");
53
54 debug('Set some value for customError.');
55 v = document.getElementsByName("set");
56 for (i = 0; i < v.length; i++)
57     v[i].setCustomValidity("Custom validation message");
58 shouldBeTrue('customErrorFor("fieldset-set")');
59 shouldBeTrue('customErrorFor("button-set")');
60 shouldBeTrue('customErrorFor("button-button-set")');
61 shouldBeTrue('customErrorFor("button-reset-set")');
62 shouldBeTrue('customErrorFor("select-set")');
63 shouldBeTrue('customErrorFor("textarea-set")');
64 shouldBeTrue('customErrorFor("input-set")');
65 shouldBeTrue('customErrorFor("input-submit-set")');
66
67 debug('');
68 debug('Set some value for customError, and clear it.');
69 v = document.getElementsByName("set-and-empty");
70 for (i = 0; i < v.length; i++)
71     v[i].setCustomValidity("Custom validation message");
72 for (i = 0; i < v.length; i++)
73     v[i].setCustomValidity("");
74 shouldBeFalse('customErrorFor("fieldset-set-and-empty")');
75 shouldBeFalse('customErrorFor("button-set-and-empty")');
76 shouldBeFalse('customErrorFor("button-button-set-and-empty")');
77 shouldBeFalse('customErrorFor("button-reset-set-and-empty")');
78 shouldBeFalse('customErrorFor("select-set-and-empty")');
79 shouldBeFalse('customErrorFor("textarea-set-and-empty")');
80 shouldBeFalse('customErrorFor("input-set-and-empty")');
81 shouldBeFalse('customErrorFor("input-submit-set-and-empty")');
82
83 debug('');
84 debug('Not any changes for customError.');
85 shouldBeFalse('customErrorFor("fieldset-no-changes")');
86 shouldBeFalse('customErrorFor("button-no-changes")');
87 shouldBeFalse('customErrorFor("button-button-no-changes")');
88 shouldBeFalse('customErrorFor("button-reset-no-changes")');
89 shouldBeFalse('customErrorFor("select-no-changes")');
90 shouldBeFalse('customErrorFor("textarea-no-changes")');
91 shouldBeFalse('customErrorFor("input-no-changes")');
92 shouldBeFalse('customErrorFor("input-submit-no-changes")');
93
94 debug('');
95 debug('Many changes for customError:');
96 debug('Set some value, and set with no arguments.');
97 v = document.getElementsByName("many-changes");
98 for (i = 0; i < v.length; i++) {
99     v[i].setCustomValidity("Custom string");
100     v[i].setCustomValidity();
101 }
102 shouldBeFalse('customErrorFor("fieldset-many-changes")');
103 shouldBeFalse('customErrorFor("button-many-changes")');
104 shouldBeFalse('customErrorFor("button-button-many-changes")');
105 shouldBeFalse('customErrorFor("button-reset-many-changes")');
106 shouldBeFalse('customErrorFor("select-many-changes")');
107 shouldBeFalse('customErrorFor("textarea-many-changes")');
108 shouldBeFalse('customErrorFor("input-many-changes")');
109 shouldBeFalse('customErrorFor("input-submit-many-changes")');
110
111 debug('Set with three arguments.');
112 for (i = 0; i < v.length; i++)
113     v[i].setCustomValidity("one", "two", "three");
114 shouldBeTrue('customErrorFor("fieldset-many-changes")');
115 shouldBeTrue('customErrorFor("button-many-changes")');
116 shouldBeTrue('customErrorFor("button-button-many-changes")');
117 shouldBeTrue('customErrorFor("button-reset-many-changes")');
118 shouldBeTrue('customErrorFor("select-many-changes")');
119 shouldBeTrue('customErrorFor("textarea-many-changes")');
120 shouldBeTrue('customErrorFor("input-many-changes")');
121 shouldBeTrue('customErrorFor("input-submit-many-changes")');
122
123 debug('Set null.');
124 for (i = 0; i < v.length; i++)
125     v[i].setCustomValidity(null);
126 shouldBeFalse('customErrorFor("fieldset-many-changes")');
127 shouldBeFalse('customErrorFor("button-many-changes")');
128 shouldBeFalse('customErrorFor("button-button-many-changes")');
129 shouldBeFalse('customErrorFor("button-reset-many-changes")');
130 shouldBeFalse('customErrorFor("select-many-changes")');
131 shouldBeFalse('customErrorFor("textarea-many-changes")');
132 shouldBeFalse('customErrorFor("input-many-changes")');
133 shouldBeFalse('customErrorFor("input-submit-many-changes")');
134
135 debug('Set some value, and set undefined.');
136 for (i = 0; i < v.length; i++) {
137     v[i].setCustomValidity("Custom string");
138     v[i].setCustomValidity(undefined);
139 }
140 shouldBeFalse('customErrorFor("fieldset-many-changes")');
141 shouldBeFalse('customErrorFor("button-many-changes")');
142 shouldBeFalse('customErrorFor("button-button-many-changes")');
143 shouldBeFalse('customErrorFor("button-reset-many-changes")');
144 shouldBeFalse('customErrorFor("select-many-changes")');
145 shouldBeFalse('customErrorFor("textarea-many-changes")');
146 shouldBeFalse('customErrorFor("input-many-changes")');
147 shouldBeFalse('customErrorFor("input-submit-many-changes")');
148
149 debug('');
150
151 var successfullyParsed = true;
152 </script>
153 <script src="../../fast/js/resources/js-test-post.js"></script>
154 </body>
155 </html>