summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/submit-form-attributes.html
blob: 7cdc8f35a25f55cf5986e2783b2b51a4827e91c8 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.');

var input = document.createElement('input');

debug('Ordinary values for input:');
input.type = "submit";
shouldBeEqualToString('input.formEnctype', '');
shouldBeEqualToString('input.formMethod', '');
shouldBeEqualToString('input.formTarget', '');

input.setAttribute('formAction', 'http://localhost');
shouldBeEqualToString('input.formAction', 'http://localhost/');
input.setAttribute('formAction', 'http://localhost/');
shouldBeEqualToString('input.formAction', 'http://localhost/');
input.setAttribute('formEnctype', 'text/plain');
shouldBeEqualToString('input.formEnctype', 'text/plain');
input.setAttribute('formEnctype', 'na');
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
input.setAttribute('formMethod', 'GET');
shouldBeEqualToString('input.formMethod', 'get');
input.setAttribute('formMethod', 'ni');
shouldBeEqualToString('input.formMethod', 'get');
input.setAttribute('formTarget', '_blank');
shouldBeEqualToString('input.formTarget', '_blank');
input.setAttribute('formTarget', 'nu');
shouldBeEqualToString('input.formTarget', 'nu');

input.formAction = 'http://example.com';
shouldBeEqualToString('input.formAction', 'http://example.com/');
input.formAction = 'http://example.com/';
shouldBeEqualToString('input.formAction', 'http://example.com/');
input.formEnctype = 'text/plain';
shouldBeEqualToString('input.formEnctype', 'text/plain');
input.formEnctype = 'nota';
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
input.formMethod = 'POST';
shouldBeEqualToString('input.formMethod', 'post');
input.formMethod = 'neta';
shouldBeEqualToString('input.formMethod', 'get');
input.formTarget = 'http://example.com';
shouldBeEqualToString('input.formTarget', 'http://example.com');
input.formTarget = 'nta';
shouldBeEqualToString('input.formTarget', 'nta');

debug('');
debug('Setting null for input:');
input.formEnctype = null;
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('input.getAttribute("formEnctype")', 'null');
input.setAttribute('formEnctype', null);
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
input.formMethod = null;
shouldBeEqualToString('input.formMethod', 'get');
shouldBeEqualToString('input.getAttribute("formMethod")', 'null');
input.setAttribute('formMethod', null);
shouldBeEqualToString('input.formMethod', 'get');
input.formTarget = null;
shouldBeEqualToString('input.formTarget', 'null');
shouldBeEqualToString('input.getAttribute("formTarget")', 'null');
input.setAttribute('formTarget', null);
shouldBeEqualToString('input.formTarget', 'null');

debug('');
debug('Setting undefined for input:');
input.formEnctype = undefined;
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('input.getAttribute("formEnctype")', 'undefined');
input.setAttribute('formEnctype', undefined);
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
input.formMethod = undefined;
shouldBeEqualToString('input.formMethod', 'get');
shouldBeEqualToString('input.getAttribute("formMethod")', 'undefined');
input.setAttribute('formMethod', undefined);
shouldBeEqualToString('input.formMethod', 'get');
input.formTarget = undefined;
shouldBeEqualToString('input.formTarget', 'undefined');
shouldBeEqualToString('input.getAttribute("formTarget")', 'undefined');
input.setAttribute('formTarget', undefined);
shouldBeEqualToString('input.formTarget', 'undefined');

debug('');
debug('Setting non-string for input:');
input.formEnctype = 256;
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('input.getAttribute("formEnctype")', '256');
input.setAttribute('formEnctype', 256);
shouldBeEqualToString('input.formEnctype', 'application/x-www-form-urlencoded');
input.formMethod = 256;
shouldBeEqualToString('input.formMethod', 'get');
shouldBeEqualToString('input.getAttribute("formMethod")', '256');
input.setAttribute('formMethod', 256);
shouldBeEqualToString('input.formMethod', 'get');
input.formTarget = 256;
shouldBeEqualToString('input.formTarget', '256');
shouldBeEqualToString('input.getAttribute("formTarget")', '256');
input.setAttribute('formTarget', 256);
shouldBeEqualToString('input.formTarget', '256');

var button = document.createElement('button');
debug('');
debug('Ordinary values for button:');
button.type = "submit";
shouldBeEqualToString('button.formEnctype', '');
shouldBeEqualToString('button.formMethod', '');
shouldBeEqualToString('button.formTarget', '');

button.setAttribute('formAction', 'http://localhost');
shouldBeEqualToString('button.formAction', 'http://localhost/');
button.setAttribute('formAction', 'http://localhost/');
shouldBeEqualToString('button.formAction', 'http://localhost/');
button.setAttribute('formEnctype', 'text/plain');
shouldBeEqualToString('button.formEnctype', 'text/plain');
button.setAttribute('formEnctype', 'na');
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
button.setAttribute('formMethod', 'GET');
shouldBeEqualToString('button.formMethod', 'get');
button.setAttribute('formMethod', 'na');
shouldBeEqualToString('button.formMethod', 'get');
button.setAttribute('formTarget', '_blank');
shouldBeEqualToString('button.formTarget', '_blank');
button.setAttribute('formTarget', 'na');
shouldBeEqualToString('button.formTarget', 'na');

button.formAction = 'http://example.com';
shouldBeEqualToString('button.formAction', 'http://example.com/');
button.formAction = 'http://example.com/';
shouldBeEqualToString('button.formAction', 'http://example.com/');
button.formEnctype = 'text/plain';
shouldBeEqualToString('button.formEnctype', 'text/plain');
button.formEnctype = 'nota';
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
button.formMethod = 'POST';
shouldBeEqualToString('button.formMethod', 'post');
button.formMethod = 'nota';
shouldBeEqualToString('button.formMethod', 'get');
button.formTarget = 'http://example.com';
shouldBeEqualToString('button.formTarget', 'http://example.com');
button.formTarget = 'nota';
shouldBeEqualToString('button.formTarget', 'nota');

debug('');
debug('Setting null for button:');
button.formEnctype = null;
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('button.getAttribute("formEnctype")', 'null');
button.setAttribute('formEnctype', null);
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
button.formMethod = null;
shouldBeEqualToString('button.formMethod', 'get');
shouldBeEqualToString('button.getAttribute("formMethod")', 'null');
button.setAttribute('formMethod', null);
shouldBeEqualToString('button.formMethod', 'get');
button.formTarget = null;
shouldBeEqualToString('button.formTarget', 'null');
shouldBeEqualToString('button.getAttribute("formTarget")', 'null');
button.setAttribute('formTarget', null);
shouldBeEqualToString('button.formTarget', 'null');

debug('');
debug('Setting undefined for button:');
button.formEnctype = undefined;
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('button.getAttribute("formEnctype")', 'undefined');
button.setAttribute('formEnctype', undefined);
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
button.formMethod = undefined;
shouldBeEqualToString('button.formMethod', 'get');
shouldBeEqualToString('button.getAttribute("formMethod")', 'undefined');
button.setAttribute('formMethod', undefined);
shouldBeEqualToString('button.formMethod', 'get');
button.formTarget = undefined;
shouldBeEqualToString('button.formTarget', 'undefined');
shouldBeEqualToString('button.getAttribute("formTarget")', 'undefined');
button.setAttribute('formTarget', undefined);
shouldBeEqualToString('button.formTarget', 'undefined');

debug('');
debug('Setting non-string for button:');
button.formEnctype = 256;
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
shouldBeEqualToString('button.getAttribute("formEnctype")', '256');
button.setAttribute('formEnctype', 512);
shouldBeEqualToString('button.formEnctype', 'application/x-www-form-urlencoded');
button.formMethod = 128;
shouldBeEqualToString('button.formMethod', 'get');
shouldBeEqualToString('button.getAttribute("formMethod")', '128');
button.setAttribute('formMethod', 17);
shouldBeEqualToString('button.formMethod', 'get');
button.formTarget = 100;
shouldBeEqualToString('button.formTarget', '100');
shouldBeEqualToString('button.getAttribute("formTarget")', '100');
button.setAttribute('formTarget', 281);
shouldBeEqualToString('button.formTarget', '281');
</script>
</body>
</html>