1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.');
12 var input
= document
.createElement('input');
14 debug('Ordinary values for input:');
15 input
.type
= "submit";
16 shouldBeEqualToString('input.formEnctype', '');
17 shouldBeEqualToString('input.formMethod', '');
18 shouldBeEqualToString('input.formTarget', '');
20 input
.setAttribute('formAction', 'http://localhost');
21 shouldBeEqualToString('input.formAction', 'http://localhost/');
22 input
.setAttribute('formAction', 'http://localhost/');
23 shouldBeEqualToString('input.formAction', 'http://localhost/');
24 input
.setAttribute('formEnctype', 'text/plain');
25 shouldBeEqualToString('input.formEnctype', 'text/plain');
26 input
.setAttribute('formEnctype', 'na');
27 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
28 input
.setAttribute('formMethod', 'GET');
29 shouldBeEqualToString('input.formMethod', 'get');
30 input
.setAttribute('formMethod', 'ni');
31 shouldBeEqualToString('input.formMethod', 'get');
32 input
.setAttribute('formTarget', '_blank');
33 shouldBeEqualToString('input.formTarget', '_blank');
34 input
.setAttribute('formTarget', 'nu');
35 shouldBeEqualToString('input.formTarget', 'nu');
37 input
.formAction
= 'http://example.com';
38 shouldBeEqualToString('input.formAction', 'http://example.com/');
39 input
.formAction
= 'http://example.com/';
40 shouldBeEqualToString('input.formAction', 'http://example.com/');
41 input
.formEnctype
= 'text/plain';
42 shouldBeEqualToString('input.formEnctype', 'text/plain');
43 input
.formEnctype
= 'nota';
44 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
45 input
.formMethod
= 'POST';
46 shouldBeEqualToString('input.formMethod', 'post');
47 input
.formMethod
= 'neta';
48 shouldBeEqualToString('input.formMethod', 'get');
49 input
.formTarget
= 'http://example.com';
50 shouldBeEqualToString('input.formTarget', 'http://example.com');
51 input
.formTarget
= 'nta';
52 shouldBeEqualToString('input.formTarget', 'nta');
55 debug('Setting null for input:');
56 input
.formEnctype
= null;
57 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
58 shouldBeEqualToString('input.getAttribute("formEnctype")', 'null');
59 input
.setAttribute('formEnctype', null);
60 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
61 input
.formMethod
= null;
62 shouldBeEqualToString('input.formMethod', 'get');
63 shouldBeEqualToString('input.getAttribute("formMethod")', 'null');
64 input
.setAttribute('formMethod', null);
65 shouldBeEqualToString('input.formMethod', 'get');
66 input
.formTarget
= null;
67 shouldBeEqualToString('input.formTarget', 'null');
68 shouldBeEqualToString('input.getAttribute("formTarget")', 'null');
69 input
.setAttribute('formTarget', null);
70 shouldBeEqualToString('input.formTarget', 'null');
73 debug('Setting undefined for input:');
74 input
.formEnctype
= undefined;
75 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
76 shouldBeEqualToString('input.getAttribute("formEnctype")', 'undefined');
77 input
.setAttribute('formEnctype', undefined);
78 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
79 input
.formMethod
= undefined;
80 shouldBeEqualToString('input.formMethod', 'get');
81 shouldBeEqualToString('input.getAttribute("formMethod")', 'undefined');
82 input
.setAttribute('formMethod', undefined);
83 shouldBeEqualToString('input.formMethod', 'get');
84 input
.formTarget
= undefined;
85 shouldBeEqualToString('input.formTarget', 'undefined');
86 shouldBeEqualToString('input.getAttribute("formTarget")', 'undefined');
87 input
.setAttribute('formTarget', undefined);
88 shouldBeEqualToString('input.formTarget', 'undefined');
91 debug('Setting non-string for input:');
92 input
.formEnctype
= 256;
93 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
94 shouldBeEqualToString('input.getAttribute("formEnctype")', '256');
95 input
.setAttribute('formEnctype', 256);
96 shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
97 input
.formMethod
= 256;
98 shouldBeEqualToString('input.formMethod', 'get');
99 shouldBeEqualToString('input.getAttribute("formMethod")', '256');
100 input
.setAttribute('formMethod', 256);
101 shouldBeEqualToString('input.formMethod', 'get');
102 input
.formTarget
= 256;
103 shouldBeEqualToString('input.formTarget', '256');
104 shouldBeEqualToString('input.getAttribute("formTarget")', '256');
105 input
.setAttribute('formTarget', 256);
106 shouldBeEqualToString('input.formTarget', '256');
108 var button
= document
.createElement('button');
110 debug('Ordinary values for button:');
111 button
.type
= "submit";
112 shouldBeEqualToString('button.formEnctype', '');
113 shouldBeEqualToString('button.formMethod', '');
114 shouldBeEqualToString('button.formTarget', '');
116 button
.setAttribute('formAction', 'http://localhost');
117 shouldBeEqualToString('button.formAction', 'http://localhost/');
118 button
.setAttribute('formAction', 'http://localhost/');
119 shouldBeEqualToString('button.formAction', 'http://localhost/');
120 button
.setAttribute('formEnctype', 'text/plain');
121 shouldBeEqualToString('button.formEnctype', 'text/plain');
122 button
.setAttribute('formEnctype', 'na');
123 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
124 button
.setAttribute('formMethod', 'GET');
125 shouldBeEqualToString('button.formMethod', 'get');
126 button
.setAttribute('formMethod', 'na');
127 shouldBeEqualToString('button.formMethod', 'get');
128 button
.setAttribute('formTarget', '_blank');
129 shouldBeEqualToString('button.formTarget', '_blank');
130 button
.setAttribute('formTarget', 'na');
131 shouldBeEqualToString('button.formTarget', 'na');
133 button
.formAction
= 'http://example.com';
134 shouldBeEqualToString('button.formAction', 'http://example.com/');
135 button
.formAction
= 'http://example.com/';
136 shouldBeEqualToString('button.formAction', 'http://example.com/');
137 button
.formEnctype
= 'text/plain';
138 shouldBeEqualToString('button.formEnctype', 'text/plain');
139 button
.formEnctype
= 'nota';
140 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
141 button
.formMethod
= 'POST';
142 shouldBeEqualToString('button.formMethod', 'post');
143 button
.formMethod
= 'nota';
144 shouldBeEqualToString('button.formMethod', 'get');
145 button
.formTarget
= 'http://example.com';
146 shouldBeEqualToString('button.formTarget', 'http://example.com');
147 button
.formTarget
= 'nota';
148 shouldBeEqualToString('button.formTarget', 'nota');
151 debug('Setting null for button:');
152 button
.formEnctype
= null;
153 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
154 shouldBeEqualToString('button.getAttribute("formEnctype")', 'null');
155 button
.setAttribute('formEnctype', null);
156 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
157 button
.formMethod
= null;
158 shouldBeEqualToString('button.formMethod', 'get');
159 shouldBeEqualToString('button.getAttribute("formMethod")', 'null');
160 button
.setAttribute('formMethod', null);
161 shouldBeEqualToString('button.formMethod', 'get');
162 button
.formTarget
= null;
163 shouldBeEqualToString('button.formTarget', 'null');
164 shouldBeEqualToString('button.getAttribute("formTarget")', 'null');
165 button
.setAttribute('formTarget', null);
166 shouldBeEqualToString('button.formTarget', 'null');
169 debug('Setting undefined for button:');
170 button
.formEnctype
= undefined;
171 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
172 shouldBeEqualToString('button.getAttribute("formEnctype")', 'undefined');
173 button
.setAttribute('formEnctype', undefined);
174 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
175 button
.formMethod
= undefined;
176 shouldBeEqualToString('button.formMethod', 'get');
177 shouldBeEqualToString('button.getAttribute("formMethod")', 'undefined');
178 button
.setAttribute('formMethod', undefined);
179 shouldBeEqualToString('button.formMethod', 'get');
180 button
.formTarget
= undefined;
181 shouldBeEqualToString('button.formTarget', 'undefined');
182 shouldBeEqualToString('button.getAttribute("formTarget")', 'undefined');
183 button
.setAttribute('formTarget', undefined);
184 shouldBeEqualToString('button.formTarget', 'undefined');
187 debug('Setting non-string for button:');
188 button
.formEnctype
= 256;
189 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
190 shouldBeEqualToString('button.getAttribute("formEnctype")', '256');
191 button
.setAttribute('formEnctype', 512);
192 shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
193 button
.formMethod
= 128;
194 shouldBeEqualToString('button.formMethod', 'get');
195 shouldBeEqualToString('button.getAttribute("formMethod")', '128');
196 button
.setAttribute('formMethod', 17);
197 shouldBeEqualToString('button.formMethod', 'get');
198 button
.formTarget
= 100;
199 shouldBeEqualToString('button.formTarget', '100');
200 shouldBeEqualToString('button.getAttribute("formTarget")', '100');
201 button
.setAttribute('formTarget', 281);
202 shouldBeEqualToString('button.formTarget', '281');