summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_bug302186.html
blob: 28ff676ff026d61711180e23f4cf2721d1ccdc90 (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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=302186
-->
<head>
  <title>Test for Bug 302186</title>
  <script type="text/javascript" src="/MochiKit/Base.js"></script>
  <script type="text/javascript" src="/MochiKit/DOM.js"></script>
  <script type="text/javascript" src="/MochiKit/Style.js"></script>
  <script type="text/javascript" src="/MochiKit/Color.js"></script>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

<style>


span { color: red }
:default + span { color: green }

span.reverse { color: green }
:default + span.reverse { color: red }

button { display: none }
input { display: none }
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=302186">Mozilla Bug 302186</a>
<p id="display"></p>
<div id="content" style="display: block">
   
  <!-- static default 1 -->
  <form>
   <div>
    <input type="submit" checked="checked"><span id="s1a">There should be no red.</span>
   </div>
   <div>
    <input type="submit"><span id="s1b" class="reverse">There should be no red.</span>
   </div>
  </form>
  
  <!-- static default 2 -->
  <form>
   <div>
    <button type="submit" checked="checked" id="foo"></button>
    <span id="s2a">There should be no red.</span>
   </div>
   <div>
    <button type="submit"></button>
    <span class="reverse" id="s2b">There should be no red.</span>
   </div>
  </form>

  <!-- static default 3 -->
  <form>
   <div>
    <input type="checkbox" checked="checked" id="foo">
    <span id="s3a">There should be no red.</span>
   </div>
   <div>
    <input checked="checked">
    <span class="reverse" id="s3b">There should be no red.</span>
   </div>
  </form>

  <!-- static default 3 -->
  <form>
   <div>
    <input type="radio" checked="checked" id="foo">
    <span id="s4a">There should be no red.</span>
   </div>
   <div>
    <input checked="checked">
    <span class="reverse" id="s4b">There should be no red.</span>
   </div>
  </form>

  <!-- static default 5 -->
  <form>
   <div>
    <input type="image"><span id="s5a">There should be no red.</span>
   </div>
   <div>
  <input type="image"><span id="s5b" class="reverse">There should be no red.</span>

   </div>
  </form>

  <!-- dynamic default 1 -->
  <form>
   <div>
    <input type="submit" checked="checked" id="foo1">
    <span class="reverse" id="1a">There should be no red.</span>
   </div>
   <div>
    <input type="submit">
    <span id="1b">There should be no red.</span>

   </div>
  </form>

  <!-- dynamic default 2 -->
  <form>
   <div>
    <button type="submit" checked="checked" id="foo2"></button>
    <span class="reverse" id="2a">There should be no red.</span>
   </div>
   <div>
    <button type="submit"></button>
    <span id="2b">There should be no red.</span>
   </div>
  </form>

  <!-- dynamic default 3 -->
  <form>
   <div>
    <input type="checkbox" checked="checked" id="foo3">
    <span class="reverse" id="3a">There should be no red.</span>
   </div>
   <div>
    <input checked="checked" id="bar3">
    <span id="3b">There should be no red.</span>
   </div>
  </form>

  <!-- dynamic default 4 -->
  <form>
   <div>
    <input type="radio" checked="checked" id="foo4">
    <span class="reverse" id="4a" >There should be no red.</span>
   </div>
   <div>
    <input checked="checked" id="bar4">
    <span id="4b">There should be no red.</span>
   </div>
  </form>

  <!-- dynamic default 5 -->
  <form>
   <div>
    <input type="submit">
    <input type="radio" checked="checked" id="foo5">
    <span id="5" class="reverse">There should be no red.</span>
   </div>
  </form>

  <!-- dynamic default 6 -->
  <form>
  <div id="div6">
  <span id="6a">There should be no red.</span>
</div>
<div>
  <input type="submit"><span id="6b" class="reverse">There should be no red.</span>
</div>
  </form>

  <!-- dynamic default 7 -->
  <form>
<div>
  <input type="submit"><span id="7a">There should be no red.</span>
</div>
<div id="div7">
  <span class="reverse" id="7b">There should be no red.</span>

</div>
</form>

  <!-- dynamic default 8 -->
<form>
<div id="div8"><span id="8a">There should be no red.</span>
</div>
<div>
  <input type="image" id="foo"><span class="reverse" id="8b">There should be no red.</span>

</div>
</form>

  <!-- dynamic default 9 -->
<form>
<div>
  <input type="image"><span id="9a">There should be no red.</span>
</div>
<div id="div9">
  <span class="reverse" id="9b">There should be no red.</span>

</div>
</form>

  <!-- dynamic default 10 -->
<form>
<div id="div10">
  <input type="submit"><span id="10a" class="reverse">There should be no red.</span>
</div>
<div>
  <input type="submit"><span id="10b" >There should be no red.</span>

</div>
</form>

<!-- dynamic default 11 -->
<form>
<div id="div11a">
  <input type="submit"><span id="11a">There should be no red.</span>
</div>
<div id="div11">
  <input type="submit"><span id="11b" class="reverse">There should be no red.</span>

</div>
</form>

<!-- dynamic default 12 -->
<form>
<div id="div12">
  <input type="image"><span id="12a" class="reverse">There should be no red.</span>
</div>
<div>
  <input type="image"><span id="12b">There should be no red.</span>

</div>
</form>

<!-- dynamic default 13 -->
<form>
<div id="div13a">
  <input type="image"><span id="13a">There should be no red.</span>
</div>
<div id="div13">
  <input type="image"><span id="13b" class="reverse">There should be no red.</span>

</div>
</form>

<!-- dynamic default 14 -->
<form>
<div id="div14a">
  <input type="submit" id="foo14"><span id="14a">There should be no red.</span>
</div>
<div id="div14b">
  <input type="submit" id="foo14b"><span id="14b" class="reverse">There should be no red.</span>

</div>
</form>

<!-- dynamic default 15 -->
<form>
<div id="div15a">
  <input type="image" id="foo15a"><span id="15a">There should be no red.</span>
</div>
<div id="div15b">
  <input type="image" id="foo15b"><span id="15b" class="reverse">There should be no red.</span>

</div>
</form>

<!-- dynamic default 16 -->
<form>
<div>
  <input type="image" checked="checked" id="foo16"></button>
  <span class="reverse" id="16a">There should be no red.</span>
</div>
<div>
  <input type="image"></button><span id="16b">There should be no red.</span>

</div>
</form>

<!-- dynamic default 17 -->
<form>
<div>
  <button type="button" id="foo17"></button>
  <span id="17a">There should be no red.</span>
</div>
<div>
  <button type="submit"></button><span class="reverse" id="17b">There should be no red.</span>
</div>
</form>

<!-- dynamic default 18 -->
<form>
<div>
  <input type="button" id="foo18"></button>
  <span id="18a">There should be no red.</span>
</div>
<div>
  <input type="submit"></button><span id="18b" class="reverse">There should be no red.</span>

</div>
</form>

<!-- dynamic default 19 -->
<form>
<div id="div19">
  <span id="19a">There should be no red.</span>
</div>
</form>

<!-- dynamic default 20 -->
<form>
<div id="div20">
  <span id="20a">There should be no red.</span>
</div>
</form>

</div>

<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 302186 **/

SimpleTest.waitForExplicitFinish();

function idColor(anId) {
 var color = Color.fromComputedStyle(anId, "color");
 return color.toRGBString();
}

is(idColor("s1a"),"rgb(0,128,0)", "CSS static-default 1a");
is(idColor("s1b"),"rgb(0,128,0)", "CSS static-default 1b");
is(idColor("s2a"),"rgb(0,128,0)", "CSS static-default 2a");
is(idColor("s2b"),"rgb(0,128,0)", "CSS static-default 2b");
is(idColor("s3a"),"rgb(0,128,0)", "CSS static-default 3a");
is(idColor("s3b"),"rgb(0,128,0)", "CSS static-default 3b");
is(idColor("s4a"),"rgb(0,128,0)", "CSS static-default 4a");
is(idColor("s4b"),"rgb(0,128,0)", "CSS static-default 4b");
is(idColor("s5a"),"rgb(0,128,0)", "CSS static-default 5a");
is(idColor("s5b"),"rgb(0,128,0)", "CSS static-default 5b");

function dynamicDefault1() {
  $('foo1').removeAttribute("type");
  is(idColor("1a"),"rgb(0,128,0)", "CSS dynamic-default 1a");
  is(idColor("1b"),"rgb(0,128,0)", "CSS dynamic-default 1b");
}

function dynamicDefault2() {
  $('foo2').setAttribute("type", "button");
  is(idColor("2a"),"rgb(0,128,0)", "CSS dynamic-default 2a");
  is(idColor("2b"),"rgb(0,128,0)", "CSS dynamic-default 2b");
}

function dynamicDefault3() {
  $('foo3').removeAttribute("type");
  $('bar3').setAttribute("type", "checkbox");
  is(idColor("3a"),"rgb(0,128,0)", "CSS dynamic-default 3a");
  is(idColor("3b"),"rgb(0,128,0)", "CSS dynamic-default 3b");
}

function dynamicDefault4() {
  $('foo4').removeAttribute("type");
  $('bar4').setAttribute("type", "radio");
  is(idColor("4a"),"rgb(0,128,0)", "CSS dynamic-default 4a");
  is(idColor("4b"),"rgb(0,128,0)", "CSS dynamic-default 4b");
}

function dynamicDefault5() {
  $('foo5').setAttribute("type", "submit")
  is(idColor("5"),"rgb(0,128,0)", "CSS dynamic-default 5");
}

function dynamicDefault6() {
  var but = document.createElement("input");
  but.setAttribute("type", "submit");
  $('div6').insertBefore(but, $('div6').firstChild);
  is(idColor("6a"),"rgb(0,128,0)", "CSS dynamic-default 6a");
  is(idColor("6b"),"rgb(0,128,0)", "CSS dynamic-default 6b");
}

function dynamicDefault7() {
  var but = document.createElement("input");
  but.setAttribute("type", "submit");
  $('div7').insertBefore(but, $('div7').firstChild);
  is(idColor("7a"),"rgb(0,128,0)", "CSS dynamic-default 7a");
  is(idColor("7b"),"rgb(0,128,0)", "CSS dynamic-default 7b");
}

function dynamicDefault8() {
  var but = document.createElement("input");
  but.setAttribute("type", "image");
  $('div8').insertBefore(but, $('div8').firstChild);
  is(idColor("8a"),"rgb(0,128,0)", "CSS dynamic-default 8a");
  is(idColor("8b"),"rgb(0,128,0)", "CSS dynamic-default 8b");
}

function dynamicDefault9() {
  var but = document.createElement("input");
  but.setAttribute("type", "image");
  $('div9').insertBefore(but, $('div9').firstChild);
  is(idColor("9a"),"rgb(0,128,0)", "CSS dynamic-default 9a");
  is(idColor("9b"),"rgb(0,128,0)", "CSS dynamic-default 9b");
}

function dynamicDefault10() {
  var inputs = $('div10').getElementsByTagName("input");
  $('div10').removeChild(inputs[0]);
  is(idColor("10a"),"rgb(0,128,0)", "CSS dynamic-default 10a");
  is(idColor("10b"),"rgb(0,128,0)", "CSS dynamic-default 10b");
}

function dynamicDefault11() {
  var inputs = $('div11').getElementsByTagName("input");
  $('div11').removeChild(inputs[0]);
  is(idColor("11a"),"rgb(0,128,0)", "CSS dynamic-default 11a");
  is(idColor("11b"),"rgb(0,128,0)", "CSS dynamic-default 11b");
}

function dynamicDefault12() {
  var inputs = $('div12').getElementsByTagName("input");
  $('div12').removeChild(inputs[0]);
  is(idColor("12a"),"rgb(0,128,0)", "CSS dynamic-default 12a");
  is(idColor("12b"),"rgb(0,128,0)", "CSS dynamic-default 12b");
}

function dynamicDefault13() {
  var inputs = $('div13').getElementsByTagName("input");
  $('div13').removeChild(inputs[0]);
  is(idColor("13a"),"rgb(0,128,0)", "CSS dynamic-default 13a");
  is(idColor("13b"),"rgb(0,128,0)", "CSS dynamic-default 13b");
}

function dynamicDefault14() {
  var div1 = document.getElementById("div14a");
  var inputs = div1.getElementsByTagName("input");
  var firstElement = div1.removeChild(inputs[0]);
  var div2 = document.getElementById("div14b");
  inputs = div2.getElementsByTagName("input");
  var secondElement = div2.removeChild(inputs[0]);
  div1.insertBefore(secondElement, div1.firstChild);
  div2.insertBefore(firstElement, div2.firstChild);
  is(idColor("14a"),"rgb(0,128,0)", "CSS dynamic-default 14a");
  is(idColor("14b"),"rgb(0,128,0)", "CSS dynamic-default 14b");
}

function dynamicDefault15() {
  var div1 = document.getElementById("div15a");
  var inputs = div1.getElementsByTagName("input");
  var firstElement = div1.removeChild(inputs[0]);
  var div2 = document.getElementById("div15b");
  inputs = div2.getElementsByTagName("input");
  var secondElement = div2.removeChild(inputs[0]);
  div1.insertBefore(secondElement, div1.firstChild);
  div2.insertBefore(firstElement, div2.firstChild);
  is(idColor("15a"),"rgb(0,128,0)", "CSS dynamic-default 15a");
  is(idColor("15b"),"rgb(0,128,0)", "CSS dynamic-default 15b");
}

function dynamicDefault16() {
  $("foo16").setAttribute("type", "button");
  is(idColor("16a"),"rgb(0,128,0)", "CSS dynamic-default 16a");
  is(idColor("16b"),"rgb(0,128,0)", "CSS dynamic-default 16b");
}

function dynamicDefault17() {
  $("foo17").setAttribute("type", "submit");
  is(idColor("17a"),"rgb(0,128,0)", "CSS dynamic-default 17a");
  is(idColor("17b"),"rgb(0,128,0)", "CSS dynamic-default 17b");
}

function dynamicDefault18() {
  $("foo18").setAttribute("type", "submit");
  is(idColor("18a"),"rgb(0,128,0)", "CSS dynamic-default 18a");
  is(idColor("18b"),"rgb(0,128,0)", "CSS dynamic-default 18b");
}

function dynamicDefault19() {
  var newSubmit = document.createElement("input");
  newSubmit.setAttribute("type", "submit");
  var div1 = document.getElementById("div19");
  div1.insertBefore(newSubmit, div1.firstChild);
  is(idColor("19a"),"rgb(0,128,0)", "CSS dynamic-default 19a");
}

function dynamicDefault20() {
  var newSubmit = document.createElement("input");
  newSubmit.setAttribute("type", "image");
  var div1 = document.getElementById("div20");
  div1.insertBefore(newSubmit, div1.firstChild);
  is(idColor("20a"),"rgb(0,128,0)", "CSS dynamic-default 20a");
}

addLoadEvent(dynamicDefault1);
addLoadEvent(dynamicDefault2);
addLoadEvent(dynamicDefault3);
addLoadEvent(dynamicDefault4);
addLoadEvent(dynamicDefault5);
addLoadEvent(dynamicDefault6);
addLoadEvent(dynamicDefault7);
addLoadEvent(dynamicDefault8);
addLoadEvent(dynamicDefault9);
addLoadEvent(dynamicDefault10);
addLoadEvent(dynamicDefault11);
addLoadEvent(dynamicDefault12);
addLoadEvent(dynamicDefault13);
addLoadEvent(dynamicDefault14);
addLoadEvent(dynamicDefault15);
addLoadEvent(dynamicDefault16);
addLoadEvent(dynamicDefault17);
addLoadEvent(dynamicDefault18);
addLoadEvent(dynamicDefault19);
addLoadEvent(dynamicDefault20);

addLoadEvent(SimpleTest.finish);

</script>
</pre>
</body>
</html>