4 https://bugzilla.mozilla.org/show_bug.cgi?id=302186
7 <title>Test for Bug
302186</title>
8 <script type=
"text/javascript" src=
"/MochiKit/Base.js"></script>
9 <script type=
"text/javascript" src=
"/MochiKit/DOM.js"></script>
10 <script type=
"text/javascript" src=
"/MochiKit/Style.js"></script>
11 <script type=
"text/javascript" src=
"/MochiKit/Color.js"></script>
12 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
13 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
19 :default + span { color: green }
21 span.reverse { color: green }
22 :default + span.reverse { color: red }
24 button { display: none }
25 input { display: none }
29 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=302186">Mozilla Bug
302186</a>
31 <div id=
"content" style=
"display: block">
33 <!-- static default 1 -->
36 <input type=
"submit" checked=
"checked"><span id=
"s1a">There should be no red.
</span>
39 <input type=
"submit"><span id=
"s1b" class=
"reverse">There should be no red.
</span>
43 <!-- static default 2 -->
46 <button type=
"submit" checked=
"checked" id=
"foo"></button>
47 <span id=
"s2a">There should be no red.
</span>
50 <button type=
"submit"></button>
51 <span class=
"reverse" id=
"s2b">There should be no red.
</span>
55 <!-- static default 3 -->
58 <input type=
"checkbox" checked=
"checked" id=
"foo">
59 <span id=
"s3a">There should be no red.
</span>
62 <input checked=
"checked">
63 <span class=
"reverse" id=
"s3b">There should be no red.
</span>
67 <!-- static default 3 -->
70 <input type=
"radio" checked=
"checked" id=
"foo">
71 <span id=
"s4a">There should be no red.
</span>
74 <input checked=
"checked">
75 <span class=
"reverse" id=
"s4b">There should be no red.
</span>
79 <!-- static default 5 -->
82 <input type=
"image"><span id=
"s5a">There should be no red.
</span>
85 <input type=
"image"><span id=
"s5b" class=
"reverse">There should be no red.
</span>
90 <!-- dynamic default 1 -->
93 <input type=
"submit" checked=
"checked" id=
"foo1">
94 <span class=
"reverse" id=
"1a">There should be no red.
</span>
98 <span id=
"1b">There should be no red.
</span>
103 <!-- dynamic default 2 -->
106 <button type=
"submit" checked=
"checked" id=
"foo2"></button>
107 <span class=
"reverse" id=
"2a">There should be no red.
</span>
110 <button type=
"submit"></button>
111 <span id=
"2b">There should be no red.
</span>
115 <!-- dynamic default 3 -->
118 <input type=
"checkbox" checked=
"checked" id=
"foo3">
119 <span class=
"reverse" id=
"3a">There should be no red.
</span>
122 <input checked=
"checked" id=
"bar3">
123 <span id=
"3b">There should be no red.
</span>
127 <!-- dynamic default 4 -->
130 <input type=
"radio" checked=
"checked" id=
"foo4">
131 <span class=
"reverse" id=
"4a" >There should be no red.
</span>
134 <input checked=
"checked" id=
"bar4">
135 <span id=
"4b">There should be no red.
</span>
139 <!-- dynamic default 5 -->
142 <input type=
"submit">
143 <input type=
"radio" checked=
"checked" id=
"foo5">
144 <span id=
"5" class=
"reverse">There should be no red.
</span>
148 <!-- dynamic default 6 -->
151 <span id=
"6a">There should be no red.
</span>
154 <input type=
"submit"><span id=
"6b" class=
"reverse">There should be no red.
</span>
158 <!-- dynamic default 7 -->
161 <input type=
"submit"><span id=
"7a">There should be no red.
</span>
164 <span class=
"reverse" id=
"7b">There should be no red.
</span>
169 <!-- dynamic default 8 -->
171 <div id=
"div8"><span id=
"8a">There should be no red.
</span>
174 <input type=
"image" id=
"foo"><span class=
"reverse" id=
"8b">There should be no red.
</span>
179 <!-- dynamic default 9 -->
182 <input type=
"image"><span id=
"9a">There should be no red.
</span>
185 <span class=
"reverse" id=
"9b">There should be no red.
</span>
190 <!-- dynamic default 10 -->
193 <input type=
"submit"><span id=
"10a" class=
"reverse">There should be no red.
</span>
196 <input type=
"submit"><span id=
"10b" >There should be no red.
</span>
201 <!-- dynamic default 11 -->
204 <input type=
"submit"><span id=
"11a">There should be no red.
</span>
207 <input type=
"submit"><span id=
"11b" class=
"reverse">There should be no red.
</span>
212 <!-- dynamic default 12 -->
215 <input type=
"image"><span id=
"12a" class=
"reverse">There should be no red.
</span>
218 <input type=
"image"><span id=
"12b">There should be no red.
</span>
223 <!-- dynamic default 13 -->
226 <input type=
"image"><span id=
"13a">There should be no red.
</span>
229 <input type=
"image"><span id=
"13b" class=
"reverse">There should be no red.
</span>
234 <!-- dynamic default 14 -->
237 <input type=
"submit" id=
"foo14"><span id=
"14a">There should be no red.
</span>
240 <input type=
"submit" id=
"foo14b"><span id=
"14b" class=
"reverse">There should be no red.
</span>
245 <!-- dynamic default 15 -->
248 <input type=
"image" id=
"foo15a"><span id=
"15a">There should be no red.
</span>
251 <input type=
"image" id=
"foo15b"><span id=
"15b" class=
"reverse">There should be no red.
</span>
256 <!-- dynamic default 16 -->
259 <input type=
"image" checked=
"checked" id=
"foo16"></button>
260 <span class=
"reverse" id=
"16a">There should be no red.
</span>
263 <input type=
"image"></button><span id=
"16b">There should be no red.
</span>
268 <!-- dynamic default 17 -->
271 <button type=
"button" id=
"foo17"></button>
272 <span id=
"17a">There should be no red.
</span>
275 <button type=
"submit"></button><span class=
"reverse" id=
"17b">There should be no red.
</span>
279 <!-- dynamic default 18 -->
282 <input type=
"button" id=
"foo18"></button>
283 <span id=
"18a">There should be no red.
</span>
286 <input type=
"submit"></button><span id=
"18b" class=
"reverse">There should be no red.
</span>
291 <!-- dynamic default 19 -->
294 <span id=
"19a">There should be no red.
</span>
298 <!-- dynamic default 20 -->
301 <span id=
"20a">There should be no red.
</span>
308 <script class=
"testbody" type=
"text/javascript">
310 /** Test for Bug
302186 **/
312 SimpleTest.waitForExplicitFinish();
314 function idColor(anId) {
315 var color = Color.fromComputedStyle(anId,
"color");
316 return color.toRGBString();
319 is(idColor(
"s1a"),
"rgb(0,128,0)",
"CSS static-default 1a");
320 is(idColor(
"s1b"),
"rgb(0,128,0)",
"CSS static-default 1b");
321 is(idColor(
"s2a"),
"rgb(0,128,0)",
"CSS static-default 2a");
322 is(idColor(
"s2b"),
"rgb(0,128,0)",
"CSS static-default 2b");
323 is(idColor(
"s3a"),
"rgb(0,128,0)",
"CSS static-default 3a");
324 is(idColor(
"s3b"),
"rgb(0,128,0)",
"CSS static-default 3b");
325 is(idColor(
"s4a"),
"rgb(0,128,0)",
"CSS static-default 4a");
326 is(idColor(
"s4b"),
"rgb(0,128,0)",
"CSS static-default 4b");
327 is(idColor(
"s5a"),
"rgb(0,128,0)",
"CSS static-default 5a");
328 is(idColor(
"s5b"),
"rgb(0,128,0)",
"CSS static-default 5b");
330 function dynamicDefault1() {
331 $('foo1').removeAttribute(
"type");
332 is(idColor(
"1a"),
"rgb(0,128,0)",
"CSS dynamic-default 1a");
333 is(idColor(
"1b"),
"rgb(0,128,0)",
"CSS dynamic-default 1b");
336 function dynamicDefault2() {
337 $('foo2').setAttribute(
"type",
"button");
338 is(idColor(
"2a"),
"rgb(0,128,0)",
"CSS dynamic-default 2a");
339 is(idColor(
"2b"),
"rgb(0,128,0)",
"CSS dynamic-default 2b");
342 function dynamicDefault3() {
343 $('foo3').removeAttribute(
"type");
344 $('bar3').setAttribute(
"type",
"checkbox");
345 is(idColor(
"3a"),
"rgb(0,128,0)",
"CSS dynamic-default 3a");
346 is(idColor(
"3b"),
"rgb(0,128,0)",
"CSS dynamic-default 3b");
349 function dynamicDefault4() {
350 $('foo4').removeAttribute(
"type");
351 $('bar4').setAttribute(
"type",
"radio");
352 is(idColor(
"4a"),
"rgb(0,128,0)",
"CSS dynamic-default 4a");
353 is(idColor(
"4b"),
"rgb(0,128,0)",
"CSS dynamic-default 4b");
356 function dynamicDefault5() {
357 $('foo5').setAttribute(
"type",
"submit")
358 is(idColor(
"5"),
"rgb(0,128,0)",
"CSS dynamic-default 5");
361 function dynamicDefault6() {
362 var but = document.createElement(
"input");
363 but.setAttribute(
"type",
"submit");
364 $('div6').insertBefore(but, $('div6').firstChild);
365 is(idColor(
"6a"),
"rgb(0,128,0)",
"CSS dynamic-default 6a");
366 is(idColor(
"6b"),
"rgb(0,128,0)",
"CSS dynamic-default 6b");
369 function dynamicDefault7() {
370 var but = document.createElement(
"input");
371 but.setAttribute(
"type",
"submit");
372 $('div7').insertBefore(but, $('div7').firstChild);
373 is(idColor(
"7a"),
"rgb(0,128,0)",
"CSS dynamic-default 7a");
374 is(idColor(
"7b"),
"rgb(0,128,0)",
"CSS dynamic-default 7b");
377 function dynamicDefault8() {
378 var but = document.createElement(
"input");
379 but.setAttribute(
"type",
"image");
380 $('div8').insertBefore(but, $('div8').firstChild);
381 is(idColor(
"8a"),
"rgb(0,128,0)",
"CSS dynamic-default 8a");
382 is(idColor(
"8b"),
"rgb(0,128,0)",
"CSS dynamic-default 8b");
385 function dynamicDefault9() {
386 var but = document.createElement(
"input");
387 but.setAttribute(
"type",
"image");
388 $('div9').insertBefore(but, $('div9').firstChild);
389 is(idColor(
"9a"),
"rgb(0,128,0)",
"CSS dynamic-default 9a");
390 is(idColor(
"9b"),
"rgb(0,128,0)",
"CSS dynamic-default 9b");
393 function dynamicDefault10() {
394 var inputs = $('div10').getElementsByTagName(
"input");
395 $('div10').removeChild(inputs[
0]);
396 is(idColor(
"10a"),
"rgb(0,128,0)",
"CSS dynamic-default 10a");
397 is(idColor(
"10b"),
"rgb(0,128,0)",
"CSS dynamic-default 10b");
400 function dynamicDefault11() {
401 var inputs = $('div11').getElementsByTagName(
"input");
402 $('div11').removeChild(inputs[
0]);
403 is(idColor(
"11a"),
"rgb(0,128,0)",
"CSS dynamic-default 11a");
404 is(idColor(
"11b"),
"rgb(0,128,0)",
"CSS dynamic-default 11b");
407 function dynamicDefault12() {
408 var inputs = $('div12').getElementsByTagName(
"input");
409 $('div12').removeChild(inputs[
0]);
410 is(idColor(
"12a"),
"rgb(0,128,0)",
"CSS dynamic-default 12a");
411 is(idColor(
"12b"),
"rgb(0,128,0)",
"CSS dynamic-default 12b");
414 function dynamicDefault13() {
415 var inputs = $('div13').getElementsByTagName(
"input");
416 $('div13').removeChild(inputs[
0]);
417 is(idColor(
"13a"),
"rgb(0,128,0)",
"CSS dynamic-default 13a");
418 is(idColor(
"13b"),
"rgb(0,128,0)",
"CSS dynamic-default 13b");
421 function dynamicDefault14() {
422 var div1 = document.getElementById(
"div14a");
423 var inputs = div1.getElementsByTagName(
"input");
424 var firstElement = div1.removeChild(inputs[
0]);
425 var div2 = document.getElementById(
"div14b");
426 inputs = div2.getElementsByTagName(
"input");
427 var secondElement = div2.removeChild(inputs[
0]);
428 div1.insertBefore(secondElement, div1.firstChild);
429 div2.insertBefore(firstElement, div2.firstChild);
430 is(idColor(
"14a"),
"rgb(0,128,0)",
"CSS dynamic-default 14a");
431 is(idColor(
"14b"),
"rgb(0,128,0)",
"CSS dynamic-default 14b");
434 function dynamicDefault15() {
435 var div1 = document.getElementById(
"div15a");
436 var inputs = div1.getElementsByTagName(
"input");
437 var firstElement = div1.removeChild(inputs[
0]);
438 var div2 = document.getElementById(
"div15b");
439 inputs = div2.getElementsByTagName(
"input");
440 var secondElement = div2.removeChild(inputs[
0]);
441 div1.insertBefore(secondElement, div1.firstChild);
442 div2.insertBefore(firstElement, div2.firstChild);
443 is(idColor(
"15a"),
"rgb(0,128,0)",
"CSS dynamic-default 15a");
444 is(idColor(
"15b"),
"rgb(0,128,0)",
"CSS dynamic-default 15b");
447 function dynamicDefault16() {
448 $(
"foo16").setAttribute(
"type",
"button");
449 is(idColor(
"16a"),
"rgb(0,128,0)",
"CSS dynamic-default 16a");
450 is(idColor(
"16b"),
"rgb(0,128,0)",
"CSS dynamic-default 16b");
453 function dynamicDefault17() {
454 $(
"foo17").setAttribute(
"type",
"submit");
455 is(idColor(
"17a"),
"rgb(0,128,0)",
"CSS dynamic-default 17a");
456 is(idColor(
"17b"),
"rgb(0,128,0)",
"CSS dynamic-default 17b");
459 function dynamicDefault18() {
460 $(
"foo18").setAttribute(
"type",
"submit");
461 is(idColor(
"18a"),
"rgb(0,128,0)",
"CSS dynamic-default 18a");
462 is(idColor(
"18b"),
"rgb(0,128,0)",
"CSS dynamic-default 18b");
465 function dynamicDefault19() {
466 var newSubmit = document.createElement(
"input");
467 newSubmit.setAttribute(
"type",
"submit");
468 var div1 = document.getElementById(
"div19");
469 div1.insertBefore(newSubmit, div1.firstChild);
470 is(idColor(
"19a"),
"rgb(0,128,0)",
"CSS dynamic-default 19a");
473 function dynamicDefault20() {
474 var newSubmit = document.createElement(
"input");
475 newSubmit.setAttribute(
"type",
"image");
476 var div1 = document.getElementById(
"div20");
477 div1.insertBefore(newSubmit, div1.firstChild);
478 is(idColor(
"20a"),
"rgb(0,128,0)",
"CSS dynamic-default 20a");
481 addLoadEvent(dynamicDefault1);
482 addLoadEvent(dynamicDefault2);
483 addLoadEvent(dynamicDefault3);
484 addLoadEvent(dynamicDefault4);
485 addLoadEvent(dynamicDefault5);
486 addLoadEvent(dynamicDefault6);
487 addLoadEvent(dynamicDefault7);
488 addLoadEvent(dynamicDefault8);
489 addLoadEvent(dynamicDefault9);
490 addLoadEvent(dynamicDefault10);
491 addLoadEvent(dynamicDefault11);
492 addLoadEvent(dynamicDefault12);
493 addLoadEvent(dynamicDefault13);
494 addLoadEvent(dynamicDefault14);
495 addLoadEvent(dynamicDefault15);
496 addLoadEvent(dynamicDefault16);
497 addLoadEvent(dynamicDefault17);
498 addLoadEvent(dynamicDefault18);
499 addLoadEvent(dynamicDefault19);
500 addLoadEvent(dynamicDefault20);
502 addLoadEvent(SimpleTest.finish);