content/base/test/test_bug433533.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:6d72dca273dc
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=433533
5 -->
6 <head>
7 <title>Test for Bug 433533</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=433533">Mozilla Bug 433533</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
15
16 </div>
17 <pre id="test">
18 <script class="testbody" type="text/javascript">
19
20 /** Test for Bug 433533 **/
21
22 var input = document.createElement("input");
23 input.setAttribute("type", "hidden");
24 is(input.getAttribute("type"), "hidden", "Setting type attribute didn't work!");
25 input.setAttribute("type", "hiDDen");
26 is(input.getAttribute("type"), "hiDDen", "Type attribute didn't store the original value");
27 is(input.type, "hidden", "Wrong input.type!");
28 input.setAttribute("type", "HIDDEN");
29 is(input.getAttribute("type"), "HIDDEN", "Type attribute didn't store the original value");
30 is(input.type, "hidden", "Wrong input.type!");
31
32 var td = document.createElement("td");
33 td.setAttribute("scope", "rOW");
34 is(td.getAttribute("scope"), "rOW", "Scope attribute didn't store the original value");
35 td.setAttribute("scope", "row");
36 is(td.getAttribute("scope"), "row", "Scope attribute didn't store the original value");
37 td.setAttribute("colspan", "100k");
38 is(td.getAttribute("colspan"), "100k", "Colspan attribute didn't store the original value");
39 td.setAttribute("colspan", " 100 ");
40 is(td.getAttribute("colspan"), " 100 ", "Colspan attribute didn't store the original value");
41 td.setAttribute("colspan", "100");
42 is(td.getAttribute("colspan"), "100", "Colspan attribute didn't store the original value");
43
44 // Note, if colspan is negative, it is set to 1, because of backwards compatibility.
45 // @see nsHTMLTableCellElement::ParseAttribute
46 td.setAttribute("colspan", "-100k");
47 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
48 td.setAttribute("colspan", " -100 ");
49 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
50 td.setAttribute("colspan", "-100");
51 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
52
53
54 td.setAttribute("colspan", "foobar");
55 is(td.getAttribute("colspan"), "foobar", "Colspan attribute didn't store the original value");
56
57 var iframe = document.createElement("iframe");
58 iframe.setAttribute("marginwidth", "50%");
59 is(iframe.getAttribute("marginwidth"), "50%",
60 "Marginwidth attribute didn't store the original value");
61 iframe.setAttribute("marginwidth", "50");
62 is(iframe.getAttribute("marginwidth"), "50",
63 "Marginwidth attribute didn't store the original value");
64 iframe.setAttribute("marginwidth", "0");
65 is(iframe.getAttribute("marginwidth"), "0",
66 "Marginwidth attribute didn't store the original value");
67 iframe.setAttribute("marginwidth", "0%");
68 is(iframe.getAttribute("marginwidth"), "0%",
69 "Marginwidth attribute didn't store the original value");
70
71 iframe.setAttribute("marginwidth", "9999999999999999999999");
72 is(iframe.getAttribute("marginwidth"), "9999999999999999999999",
73 "Marginwidth attribute didn't store the original value");
74 iframe.setAttribute("marginwidth", "9999999999999999999999%");
75 is(iframe.getAttribute("marginwidth"), "9999999999999999999999%",
76 "Marginwidth attribute didn't store the original value");
77
78 iframe.setAttribute("marginwidth", "-9999999999999999999999");
79 is(iframe.getAttribute("marginwidth"), "-9999999999999999999999",
80 "Marginwidth attribute didn't store the original value");
81 iframe.setAttribute("marginwidth", "-9999999999999999999999%");
82 is(iframe.getAttribute("marginwidth"), "-9999999999999999999999%",
83 "Marginwidth attribute didn't store the original value");
84
85
86 // Test PRInt32 min/max value
87 iframe.setAttribute("marginwidth", "2147483647");
88 is(iframe.getAttribute("marginwidth"), "2147483647",
89 "Marginwidth attribute didn't store the original value");
90 iframe.setAttribute("marginwidth", "2147483647%");
91 is(iframe.getAttribute("marginwidth"), "2147483647%",
92 "Marginwidth attribute didn't store the original value");
93
94 iframe.setAttribute("marginwidth", "-2147483648");
95 is(iframe.getAttribute("marginwidth"), "-2147483648",
96 "Marginwidth attribute didn't store the original value");
97 iframe.setAttribute("marginwidth", "-2147483648%");
98 is(iframe.getAttribute("marginwidth"), "-2147483648%",
99 "Marginwidth attribute didn't store the original value");
100
101 iframe.setAttribute("marginwidth", "2147483646");
102 is(iframe.getAttribute("marginwidth"), "2147483646",
103 "Marginwidth attribute didn't store the original value");
104 iframe.setAttribute("marginwidth", "2147483647%");
105 is(iframe.getAttribute("marginwidth"), "2147483647%",
106 "Marginwidth attribute didn't store the original value");
107
108 iframe.setAttribute("marginwidth", "-2147483647");
109 is(iframe.getAttribute("marginwidth"), "-2147483647",
110 "Marginwidth attribute didn't store the original value");
111 iframe.setAttribute("marginwidth", "-2147483647%");
112 is(iframe.getAttribute("marginwidth"), "-2147483647%",
113 "Marginwidth attribute didn't store the original value");
114
115 iframe.setAttribute("marginwidth", "2147483648");
116 is(iframe.getAttribute("marginwidth"), "2147483648",
117 "Marginwidth attribute didn't store the original value");
118 iframe.setAttribute("marginwidth", "2147483648%");
119 is(iframe.getAttribute("marginwidth"), "2147483648%",
120 "Marginwidth attribute didn't store the original value");
121
122 iframe.setAttribute("marginwidth", "-2147483649");
123 is(iframe.getAttribute("marginwidth"), "-2147483649",
124 "Marginwidth attribute didn't store the original value");
125 iframe.setAttribute("marginwidth", "-2147483649%");
126 is(iframe.getAttribute("marginwidth"), "-2147483649%",
127 "Marginwidth attribute didn't store the original value");
128
129 // some values 0 > x > NS_ATTRVALUE_INTEGERTYPE_MAXVALUE
130 iframe.setAttribute("marginwidth", "134217726");
131 is(iframe.getAttribute("marginwidth"), "134217726",
132 "Marginwidth attribute didn't store the original value");
133 iframe.setAttribute("marginwidth", "134217727");
134 is(iframe.getAttribute("marginwidth"), "134217727",
135 "Marginwidth attribute didn't store the original value");
136 iframe.setAttribute("marginwidth", "134217728");
137 is(iframe.getAttribute("marginwidth"), "134217728",
138 "Marginwidth attribute didn't store the original value");
139 iframe.setAttribute("marginwidth", "134217729");
140 is(iframe.getAttribute("marginwidth"), "134217729",
141 "Marginwidth attribute didn't store the original value");
142
143 iframe.setAttribute("marginwidth", "134217726%");
144 is(iframe.getAttribute("marginwidth"), "134217726%",
145 "Marginwidth attribute didn't store the original value");
146 iframe.setAttribute("marginwidth", "134217727%");
147 is(iframe.getAttribute("marginwidth"), "134217727%",
148 "Marginwidth attribute didn't store the original value");
149 iframe.setAttribute("marginwidth", "134217728%");
150 is(iframe.getAttribute("marginwidth"), "134217728%",
151 "Marginwidth attribute didn't store the original value");
152 iframe.setAttribute("marginwidth", "134217729%");
153 is(iframe.getAttribute("marginwidth"), "134217729%",
154 "Marginwidth attribute didn't store the original value");
155
156 // some values 0 < x < NS_ATTRVALUE_INTEGERTYPE_MINVALUE
157 iframe.setAttribute("marginwidth", "-134217727");
158 is(iframe.getAttribute("marginwidth"), "-134217727",
159 "Marginwidth attribute didn't store the original value");
160 iframe.setAttribute("marginwidth", "-134217728");
161 is(iframe.getAttribute("marginwidth"), "-134217728",
162 "Marginwidth attribute didn't store the original value");
163 iframe.setAttribute("marginwidth", "-134217729");
164 is(iframe.getAttribute("marginwidth"), "-134217729",
165 "Marginwidth attribute didn't store the original value");
166 iframe.setAttribute("marginwidth", "-134217730");
167 is(iframe.getAttribute("marginwidth"), "-134217730",
168 "Marginwidth attribute didn't store the original value");
169 iframe.setAttribute("marginwidth", "-134217727%");
170 is(iframe.getAttribute("marginwidth"), "-134217727%",
171 "Marginwidth attribute didn't store the original value");
172 iframe.setAttribute("marginwidth", "-134217728%");
173 is(iframe.getAttribute("marginwidth"), "-134217728%",
174 "Marginwidth attribute didn't store the original value");
175 iframe.setAttribute("marginwidth", "-134217729%");
176 is(iframe.getAttribute("marginwidth"), "-134217729%",
177 "Marginwidth attribute didn't store the original value");
178 iframe.setAttribute("marginwidth", "-134217730%");
179 is(iframe.getAttribute("marginwidth"), "-134217730%",
180 "Marginwidth attribute didn't store the original value");
181
182 iframe.setAttribute("marginwidth", "-0");
183 is(iframe.getAttribute("marginwidth"), "-0",
184 "Marginwidth attribute didn't store the original value");
185 iframe.setAttribute("marginwidth", "-0%");
186 is(iframe.getAttribute("marginwidth"), "-0%",
187 "Marginwidth attribute didn't store the original value");
188 iframe.setAttribute("marginwidth", " 0 ");
189 is(iframe.getAttribute("marginwidth"), " 0 ",
190 "Marginwidth attribute didn't store the original value");
191 iframe.setAttribute("marginwidth", " 0% ");
192 is(iframe.getAttribute("marginwidth"), " 0% ",
193 "Marginwidth attribute didn't store the original value");
194 iframe.setAttribute("marginwidth", "-50%");
195 is(iframe.getAttribute("marginwidth"), "-50%",
196 "Marginwidth attribute didn't store the original value");
197 iframe.setAttribute("marginwidth", "-50");
198 is(iframe.getAttribute("marginwidth"), "-50",
199 "Marginwidth attribute didn't store the original value");
200 iframe.setAttribute("marginwidth", " -50% ");
201 is(iframe.getAttribute("marginwidth"), " -50% ",
202 "Marginwidth attribute didn't store the original value");
203 iframe.setAttribute("marginwidth", " -50 ");
204 is(iframe.getAttribute("marginwidth"), " -50 ",
205 "Marginwidth attribute didn't store the original value");
206 iframe.setAttribute("marginwidth", "foobar");
207 is(iframe.getAttribute("marginwidth"), "foobar",
208 "Marginwidth attribute didn't store the original value");
209
210 var bd = document.createElement("body");
211 bd.setAttribute("bgcolor", "red");
212 is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
213 is(bd.bgColor, "red", ".bgColor didn't return the right value!");
214
215 bd.setAttribute("bgcolor", " red ");
216 is(bd.getAttribute("bgcolor"), " red ", "Bgcolor attribute didn't store the original value");
217 is(bd.bgColor, " red ", ".bgColor didn't return the right value!");
218
219 bd.setAttribute("bgcolor", "#ff0000");
220 is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
221 is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
222
223 bd.setAttribute("bgcolor", "#f00");
224 is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
225 is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
226
227 bd.setAttribute("bgcolor", " #ff0000 ");
228 is(bd.getAttribute("bgcolor"), " #ff0000 ", "Bgcolor attribute didn't store the original value");
229 is(bd.bgColor, " #ff0000 ", ".bgColor didn't return the right value!");
230
231 bd.setAttribute("bgcolor", "nonsense(complete)");
232 is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
233 is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
234
235 // same test again setting the prop
236 bd.bgColor = "red";
237 is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
238 is(bd.bgColor, "red", ".bgColor didn't return the right value!");
239
240 bd.bgColor = " red ";
241 is(bd.getAttribute("bgcolor"), " red ", "Bgcolor attribute didn't store the original value");
242 is(bd.bgColor, " red ", ".bgColor didn't return the right value!");
243
244 bd.bgColor = "#ff0000";
245 is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
246 is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
247
248 bd.bgColor = "#f00";
249 is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
250 is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
251
252 bd.bgColor = " #ff0000 ";
253 is(bd.getAttribute("bgcolor"), " #ff0000 ", "Bgcolor attribute didn't store the original value");
254 is(bd.bgColor, " #ff0000 ", ".bgColor didn't return the right value!");
255
256 bd.bgColor = "nonsense(complete)";
257 is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
258 is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
259
260 // equal color, unequal string
261 var f1 = document.createElement("font");
262 var f2 = document.createElement("font");
263 var f3 = document.createElement("font");
264 f1.color = "#f00";
265 f2.color = "#ff0000";
266 f3.color = "red";
267 isnot(f1.color, f2.color, "#f00 and #ff0000 should not compare equal");
268 isnot(f1.color, f3.color, "#f00 and red should not compare equal");
269 isnot(f2.color, f3.color, "#ff0000 and red should not compare equal");
270
271 isnot(f1.getAttribute("color"), f2.getAttribute("color"),
272 "#f00 and #ff0000 should not compare equal [attr]");
273 isnot(f1.getAttribute("color"), f3.getAttribute("color"),
274 "#f00 and red should not compare equal [attr]");
275 isnot(f2.getAttribute("color"), f3.getAttribute("color"),
276 "#ff0000 and red should not compare equal [attr]");
277
278 var video = document.createElement("video");
279 video.setAttribute("playbackrate", "1");
280 is(video.getAttribute('playbackrate'), "1",
281 "Playbackrate attribute didn't store the original value");
282 video.setAttribute("playbackrate", "1.5");
283 is(video.getAttribute('playbackrate'), "1.5",
284 "Playbackrate attribute didn't store the original value");
285 video.setAttribute("playbackrate", "999999999999999999");
286 is(video.getAttribute('playbackrate'), "999999999999999999",
287 "Playbackrate attribute didn't store the original value");
288 video.setAttribute("playbackrate", "-999999999999999999");
289 is(video.getAttribute('playbackrate'), "-999999999999999999",
290 "Playbackrate attribute didn't store the original value");
291 video.setAttribute("playbackrate", "foo");
292 is(video.getAttribute('playbackrate'), "foo",
293 "Playbackrate attribute didn't store the original value");
294 </script>
295 </pre>
296 </body>
297 </html>
298

mercurial