tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / submit-form-attributes.js
1 description('Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.');
2
3 var input = document.createElement('input');
4
5 debug('Ordinary values for input:');
6 input.type = "submit";
7 shouldBe('input.formAction', '""');
8 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
9 shouldBe('input.formMethod', '"get"');
10 shouldBe('input.formTarget', '""');
11
12 input.setAttribute('formAction', 'http://localhost');
13 shouldBe('input.formAction', '"http://localhost/"');
14 input.setAttribute('formAction', 'http://localhost/');
15 shouldBe('input.formAction', '"http://localhost/"');
16 input.setAttribute('formEnctype', 'text/plain');
17 shouldBe('input.formEnctype', '"text/plain"');
18 input.setAttribute('formEnctype', 'na');
19 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
20 input.setAttribute('formMethod', 'GET');
21 shouldBe('input.formMethod', '"get"');
22 input.setAttribute('formMethod', 'ni');
23 shouldBe('input.formMethod', '"get"');
24 input.setAttribute('formTarget', '_blank');
25 shouldBe('input.formTarget', '"_blank"');
26 input.setAttribute('formTarget', 'nu');
27 shouldBe('input.formTarget', '"nu"');
28
29 input.formAction = 'http://example.com';
30 shouldBe('input.formAction', '"http://example.com/"');
31 input.formAction = 'http://example.com/';
32 shouldBe('input.formAction', '"http://example.com/"');
33 input.formEnctype = 'text/plain';
34 shouldBe('input.formEnctype', '"text/plain"');
35 input.formEnctype = 'nota';
36 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
37 input.formMethod = 'POST';
38 shouldBe('input.formMethod', '"post"');
39 input.formMethod = 'neta';
40 shouldBe('input.formMethod', '"get"');
41 input.formTarget = 'http://example.com';
42 shouldBe('input.formTarget', '"http://example.com"');
43 input.formTarget = 'nta';
44 shouldBe('input.formTarget', '"nta"');
45
46 debug('');
47 debug('Setting null for input:');
48 input.formEnctype = null;
49 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
50 shouldBe('input.getAttribute("formEnctype")', 'null');
51 input.setAttribute('formEnctype', null);
52 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
53 input.formMethod = null;
54 shouldBe('input.formMethod', '"get"');
55 shouldBe('input.getAttribute("formMethod")', 'null');
56 input.setAttribute('formMethod', null);
57 shouldBe('input.formMethod', '"get"');
58 input.formTarget = null;
59 shouldBe('input.formTarget', '""');
60 shouldBe('input.getAttribute("formTarget")', 'null');
61 input.setAttribute('formTarget', null);
62 shouldBe('input.formTarget', '"null"');
63
64 debug('');
65 debug('Setting undefined for input:');
66 input.formEnctype = undefined;
67 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
68 shouldBe('input.getAttribute("formEnctype")', '"undefined"');
69 input.setAttribute('formEnctype', undefined);
70 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
71 input.formMethod = undefined;
72 shouldBe('input.formMethod', '"get"');
73 shouldBe('input.getAttribute("formMethod")', '"undefined"');
74 input.setAttribute('formMethod', undefined);
75 shouldBe('input.formMethod', '"get"');
76 input.formTarget = undefined;
77 shouldBe('input.formTarget', '"undefined"');
78 shouldBe('input.getAttribute("formTarget")', '"undefined"');
79 input.setAttribute('formTarget', undefined);
80 shouldBe('input.formTarget', '"undefined"');
81
82 debug('');
83 debug('Setting non-string for input:');
84 input.formEnctype = 256;
85 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
86 shouldBe('input.getAttribute("formEnctype")', '"256"');
87 input.setAttribute('formEnctype', 256);
88 shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
89 input.formMethod = 256;
90 shouldBe('input.formMethod', '"get"');
91 shouldBe('input.getAttribute("formMethod")', '"256"');
92 input.setAttribute('formMethod', 256);
93 shouldBe('input.formMethod', '"get"');
94 input.formTarget = 256;
95 shouldBe('input.formTarget', '"256"');
96 shouldBe('input.getAttribute("formTarget")', '"256"');
97 input.setAttribute('formTarget', 256);
98 shouldBe('input.formTarget', '"256"');
99
100 var button = document.createElement('button');
101 debug('');
102 debug('Ordinary values for button:');
103 button.type = "submit";
104 shouldBe('button.formAction', '""');
105 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
106 shouldBe('button.formMethod', '"get"');
107 shouldBe('button.formTarget', '""');
108
109 button.setAttribute('formAction', 'http://localhost');
110 shouldBe('button.formAction', '"http://localhost/"');
111 button.setAttribute('formAction', 'http://localhost/');
112 shouldBe('button.formAction', '"http://localhost/"');
113 button.setAttribute('formEnctype', 'text/plain');
114 shouldBe('button.formEnctype', '"text/plain"');
115 button.setAttribute('formEnctype', 'na');
116 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
117 button.setAttribute('formMethod', 'GET');
118 shouldBe('button.formMethod', '"get"');
119 button.setAttribute('formMethod', 'na');
120 shouldBe('button.formMethod', '"get"');
121 button.setAttribute('formTarget', '_blank');
122 shouldBe('button.formTarget', '"_blank"');
123 button.setAttribute('formTarget', 'na');
124 shouldBe('button.formTarget', '"na"');
125
126 button.formAction = 'http://example.com';
127 shouldBe('button.formAction', '"http://example.com/"');
128 button.formAction = 'http://example.com/';
129 shouldBe('button.formAction', '"http://example.com/"');
130 button.formEnctype = 'text/plain';
131 shouldBe('button.formEnctype', '"text/plain"');
132 button.formEnctype = 'nota';
133 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
134 button.formMethod = 'POST';
135 shouldBe('button.formMethod', '"post"');
136 button.formMethod = 'nota';
137 shouldBe('button.formMethod', '"get"');
138 button.formTarget = 'http://example.com';
139 shouldBe('button.formTarget', '"http://example.com"');
140 button.formTarget = 'nota';
141 shouldBe('button.formTarget', '"nota"');
142
143 debug('');
144 debug('Setting null for button:');
145 button.formEnctype = null;
146 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
147 shouldBe('button.getAttribute("formEnctype")', 'null');
148 button.setAttribute('formEnctype', null);
149 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
150 button.formMethod = null;
151 shouldBe('button.formMethod', '"get"');
152 shouldBe('button.getAttribute("formMethod")', 'null');
153 button.setAttribute('formMethod', null);
154 shouldBe('button.formMethod', '"get"');
155 button.formTarget = null;
156 shouldBe('button.formTarget', '""');
157 shouldBe('button.getAttribute("formTarget")', 'null');
158 button.setAttribute('formTarget', null);
159 shouldBe('button.formTarget', '"null"');
160
161 debug('');
162 debug('Setting undefined for button:');
163 button.formEnctype = undefined;
164 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
165 shouldBe('button.getAttribute("formEnctype")', '"undefined"');
166 button.setAttribute('formEnctype', undefined);
167 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
168 button.formMethod = undefined;
169 shouldBe('button.formMethod', '"get"');
170 shouldBe('button.getAttribute("formMethod")', '"undefined"');
171 button.setAttribute('formMethod', undefined);
172 shouldBe('button.formMethod', '"get"');
173 button.formTarget = undefined;
174 shouldBe('button.formTarget', '"undefined"');
175 shouldBe('button.getAttribute("formTarget")', '"undefined"');
176 button.setAttribute('formTarget', undefined);
177 shouldBe('button.formTarget', '"undefined"');
178
179 debug('');
180 debug('Setting non-string for button:');
181 button.formEnctype = 256;
182 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
183 shouldBe('button.getAttribute("formEnctype")', '"256"');
184 button.setAttribute('formEnctype', 512);
185 shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
186 button.formMethod = 128;
187 shouldBe('button.formMethod', '"get"');
188 shouldBe('button.getAttribute("formMethod")', '"128"');
189 button.setAttribute('formMethod', 17);
190 shouldBe('button.formMethod', '"get"');
191 button.formTarget = 100;
192 shouldBe('button.formTarget', '"100"');
193 shouldBe('button.getAttribute("formTarget")', '"100"');
194 button.setAttribute('formTarget', 281);
195 shouldBe('button.formTarget', '"281"');