1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_bug302186.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,508 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=302186 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 302186</title> 1.11 + <script type="text/javascript" src="/MochiKit/Base.js"></script> 1.12 + <script type="text/javascript" src="/MochiKit/DOM.js"></script> 1.13 + <script type="text/javascript" src="/MochiKit/Style.js"></script> 1.14 + <script type="text/javascript" src="/MochiKit/Color.js"></script> 1.15 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.17 + 1.18 +<style> 1.19 + 1.20 + 1.21 +span { color: red } 1.22 +:default + span { color: green } 1.23 + 1.24 +span.reverse { color: green } 1.25 +:default + span.reverse { color: red } 1.26 + 1.27 +button { display: none } 1.28 +input { display: none } 1.29 +</style> 1.30 +</head> 1.31 +<body> 1.32 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=302186">Mozilla Bug 302186</a> 1.33 +<p id="display"></p> 1.34 +<div id="content" style="display: block"> 1.35 + 1.36 + <!-- static default 1 --> 1.37 + <form> 1.38 + <div> 1.39 + <input type="submit" checked="checked"><span id="s1a">There should be no red.</span> 1.40 + </div> 1.41 + <div> 1.42 + <input type="submit"><span id="s1b" class="reverse">There should be no red.</span> 1.43 + </div> 1.44 + </form> 1.45 + 1.46 + <!-- static default 2 --> 1.47 + <form> 1.48 + <div> 1.49 + <button type="submit" checked="checked" id="foo"></button> 1.50 + <span id="s2a">There should be no red.</span> 1.51 + </div> 1.52 + <div> 1.53 + <button type="submit"></button> 1.54 + <span class="reverse" id="s2b">There should be no red.</span> 1.55 + </div> 1.56 + </form> 1.57 + 1.58 + <!-- static default 3 --> 1.59 + <form> 1.60 + <div> 1.61 + <input type="checkbox" checked="checked" id="foo"> 1.62 + <span id="s3a">There should be no red.</span> 1.63 + </div> 1.64 + <div> 1.65 + <input checked="checked"> 1.66 + <span class="reverse" id="s3b">There should be no red.</span> 1.67 + </div> 1.68 + </form> 1.69 + 1.70 + <!-- static default 3 --> 1.71 + <form> 1.72 + <div> 1.73 + <input type="radio" checked="checked" id="foo"> 1.74 + <span id="s4a">There should be no red.</span> 1.75 + </div> 1.76 + <div> 1.77 + <input checked="checked"> 1.78 + <span class="reverse" id="s4b">There should be no red.</span> 1.79 + </div> 1.80 + </form> 1.81 + 1.82 + <!-- static default 5 --> 1.83 + <form> 1.84 + <div> 1.85 + <input type="image"><span id="s5a">There should be no red.</span> 1.86 + </div> 1.87 + <div> 1.88 + <input type="image"><span id="s5b" class="reverse">There should be no red.</span> 1.89 + 1.90 + </div> 1.91 + </form> 1.92 + 1.93 + <!-- dynamic default 1 --> 1.94 + <form> 1.95 + <div> 1.96 + <input type="submit" checked="checked" id="foo1"> 1.97 + <span class="reverse" id="1a">There should be no red.</span> 1.98 + </div> 1.99 + <div> 1.100 + <input type="submit"> 1.101 + <span id="1b">There should be no red.</span> 1.102 + 1.103 + </div> 1.104 + </form> 1.105 + 1.106 + <!-- dynamic default 2 --> 1.107 + <form> 1.108 + <div> 1.109 + <button type="submit" checked="checked" id="foo2"></button> 1.110 + <span class="reverse" id="2a">There should be no red.</span> 1.111 + </div> 1.112 + <div> 1.113 + <button type="submit"></button> 1.114 + <span id="2b">There should be no red.</span> 1.115 + </div> 1.116 + </form> 1.117 + 1.118 + <!-- dynamic default 3 --> 1.119 + <form> 1.120 + <div> 1.121 + <input type="checkbox" checked="checked" id="foo3"> 1.122 + <span class="reverse" id="3a">There should be no red.</span> 1.123 + </div> 1.124 + <div> 1.125 + <input checked="checked" id="bar3"> 1.126 + <span id="3b">There should be no red.</span> 1.127 + </div> 1.128 + </form> 1.129 + 1.130 + <!-- dynamic default 4 --> 1.131 + <form> 1.132 + <div> 1.133 + <input type="radio" checked="checked" id="foo4"> 1.134 + <span class="reverse" id="4a" >There should be no red.</span> 1.135 + </div> 1.136 + <div> 1.137 + <input checked="checked" id="bar4"> 1.138 + <span id="4b">There should be no red.</span> 1.139 + </div> 1.140 + </form> 1.141 + 1.142 + <!-- dynamic default 5 --> 1.143 + <form> 1.144 + <div> 1.145 + <input type="submit"> 1.146 + <input type="radio" checked="checked" id="foo5"> 1.147 + <span id="5" class="reverse">There should be no red.</span> 1.148 + </div> 1.149 + </form> 1.150 + 1.151 + <!-- dynamic default 6 --> 1.152 + <form> 1.153 + <div id="div6"> 1.154 + <span id="6a">There should be no red.</span> 1.155 +</div> 1.156 +<div> 1.157 + <input type="submit"><span id="6b" class="reverse">There should be no red.</span> 1.158 +</div> 1.159 + </form> 1.160 + 1.161 + <!-- dynamic default 7 --> 1.162 + <form> 1.163 +<div> 1.164 + <input type="submit"><span id="7a">There should be no red.</span> 1.165 +</div> 1.166 +<div id="div7"> 1.167 + <span class="reverse" id="7b">There should be no red.</span> 1.168 + 1.169 +</div> 1.170 +</form> 1.171 + 1.172 + <!-- dynamic default 8 --> 1.173 +<form> 1.174 +<div id="div8"><span id="8a">There should be no red.</span> 1.175 +</div> 1.176 +<div> 1.177 + <input type="image" id="foo"><span class="reverse" id="8b">There should be no red.</span> 1.178 + 1.179 +</div> 1.180 +</form> 1.181 + 1.182 + <!-- dynamic default 9 --> 1.183 +<form> 1.184 +<div> 1.185 + <input type="image"><span id="9a">There should be no red.</span> 1.186 +</div> 1.187 +<div id="div9"> 1.188 + <span class="reverse" id="9b">There should be no red.</span> 1.189 + 1.190 +</div> 1.191 +</form> 1.192 + 1.193 + <!-- dynamic default 10 --> 1.194 +<form> 1.195 +<div id="div10"> 1.196 + <input type="submit"><span id="10a" class="reverse">There should be no red.</span> 1.197 +</div> 1.198 +<div> 1.199 + <input type="submit"><span id="10b" >There should be no red.</span> 1.200 + 1.201 +</div> 1.202 +</form> 1.203 + 1.204 +<!-- dynamic default 11 --> 1.205 +<form> 1.206 +<div id="div11a"> 1.207 + <input type="submit"><span id="11a">There should be no red.</span> 1.208 +</div> 1.209 +<div id="div11"> 1.210 + <input type="submit"><span id="11b" class="reverse">There should be no red.</span> 1.211 + 1.212 +</div> 1.213 +</form> 1.214 + 1.215 +<!-- dynamic default 12 --> 1.216 +<form> 1.217 +<div id="div12"> 1.218 + <input type="image"><span id="12a" class="reverse">There should be no red.</span> 1.219 +</div> 1.220 +<div> 1.221 + <input type="image"><span id="12b">There should be no red.</span> 1.222 + 1.223 +</div> 1.224 +</form> 1.225 + 1.226 +<!-- dynamic default 13 --> 1.227 +<form> 1.228 +<div id="div13a"> 1.229 + <input type="image"><span id="13a">There should be no red.</span> 1.230 +</div> 1.231 +<div id="div13"> 1.232 + <input type="image"><span id="13b" class="reverse">There should be no red.</span> 1.233 + 1.234 +</div> 1.235 +</form> 1.236 + 1.237 +<!-- dynamic default 14 --> 1.238 +<form> 1.239 +<div id="div14a"> 1.240 + <input type="submit" id="foo14"><span id="14a">There should be no red.</span> 1.241 +</div> 1.242 +<div id="div14b"> 1.243 + <input type="submit" id="foo14b"><span id="14b" class="reverse">There should be no red.</span> 1.244 + 1.245 +</div> 1.246 +</form> 1.247 + 1.248 +<!-- dynamic default 15 --> 1.249 +<form> 1.250 +<div id="div15a"> 1.251 + <input type="image" id="foo15a"><span id="15a">There should be no red.</span> 1.252 +</div> 1.253 +<div id="div15b"> 1.254 + <input type="image" id="foo15b"><span id="15b" class="reverse">There should be no red.</span> 1.255 + 1.256 +</div> 1.257 +</form> 1.258 + 1.259 +<!-- dynamic default 16 --> 1.260 +<form> 1.261 +<div> 1.262 + <input type="image" checked="checked" id="foo16"></button> 1.263 + <span class="reverse" id="16a">There should be no red.</span> 1.264 +</div> 1.265 +<div> 1.266 + <input type="image"></button><span id="16b">There should be no red.</span> 1.267 + 1.268 +</div> 1.269 +</form> 1.270 + 1.271 +<!-- dynamic default 17 --> 1.272 +<form> 1.273 +<div> 1.274 + <button type="button" id="foo17"></button> 1.275 + <span id="17a">There should be no red.</span> 1.276 +</div> 1.277 +<div> 1.278 + <button type="submit"></button><span class="reverse" id="17b">There should be no red.</span> 1.279 +</div> 1.280 +</form> 1.281 + 1.282 +<!-- dynamic default 18 --> 1.283 +<form> 1.284 +<div> 1.285 + <input type="button" id="foo18"></button> 1.286 + <span id="18a">There should be no red.</span> 1.287 +</div> 1.288 +<div> 1.289 + <input type="submit"></button><span id="18b" class="reverse">There should be no red.</span> 1.290 + 1.291 +</div> 1.292 +</form> 1.293 + 1.294 +<!-- dynamic default 19 --> 1.295 +<form> 1.296 +<div id="div19"> 1.297 + <span id="19a">There should be no red.</span> 1.298 +</div> 1.299 +</form> 1.300 + 1.301 +<!-- dynamic default 20 --> 1.302 +<form> 1.303 +<div id="div20"> 1.304 + <span id="20a">There should be no red.</span> 1.305 +</div> 1.306 +</form> 1.307 + 1.308 +</div> 1.309 + 1.310 +<pre id="test"> 1.311 +<script class="testbody" type="text/javascript"> 1.312 + 1.313 +/** Test for Bug 302186 **/ 1.314 + 1.315 +SimpleTest.waitForExplicitFinish(); 1.316 + 1.317 +function idColor(anId) { 1.318 + var color = Color.fromComputedStyle(anId, "color"); 1.319 + return color.toRGBString(); 1.320 +} 1.321 + 1.322 +is(idColor("s1a"),"rgb(0,128,0)", "CSS static-default 1a"); 1.323 +is(idColor("s1b"),"rgb(0,128,0)", "CSS static-default 1b"); 1.324 +is(idColor("s2a"),"rgb(0,128,0)", "CSS static-default 2a"); 1.325 +is(idColor("s2b"),"rgb(0,128,0)", "CSS static-default 2b"); 1.326 +is(idColor("s3a"),"rgb(0,128,0)", "CSS static-default 3a"); 1.327 +is(idColor("s3b"),"rgb(0,128,0)", "CSS static-default 3b"); 1.328 +is(idColor("s4a"),"rgb(0,128,0)", "CSS static-default 4a"); 1.329 +is(idColor("s4b"),"rgb(0,128,0)", "CSS static-default 4b"); 1.330 +is(idColor("s5a"),"rgb(0,128,0)", "CSS static-default 5a"); 1.331 +is(idColor("s5b"),"rgb(0,128,0)", "CSS static-default 5b"); 1.332 + 1.333 +function dynamicDefault1() { 1.334 + $('foo1').removeAttribute("type"); 1.335 + is(idColor("1a"),"rgb(0,128,0)", "CSS dynamic-default 1a"); 1.336 + is(idColor("1b"),"rgb(0,128,0)", "CSS dynamic-default 1b"); 1.337 +} 1.338 + 1.339 +function dynamicDefault2() { 1.340 + $('foo2').setAttribute("type", "button"); 1.341 + is(idColor("2a"),"rgb(0,128,0)", "CSS dynamic-default 2a"); 1.342 + is(idColor("2b"),"rgb(0,128,0)", "CSS dynamic-default 2b"); 1.343 +} 1.344 + 1.345 +function dynamicDefault3() { 1.346 + $('foo3').removeAttribute("type"); 1.347 + $('bar3').setAttribute("type", "checkbox"); 1.348 + is(idColor("3a"),"rgb(0,128,0)", "CSS dynamic-default 3a"); 1.349 + is(idColor("3b"),"rgb(0,128,0)", "CSS dynamic-default 3b"); 1.350 +} 1.351 + 1.352 +function dynamicDefault4() { 1.353 + $('foo4').removeAttribute("type"); 1.354 + $('bar4').setAttribute("type", "radio"); 1.355 + is(idColor("4a"),"rgb(0,128,0)", "CSS dynamic-default 4a"); 1.356 + is(idColor("4b"),"rgb(0,128,0)", "CSS dynamic-default 4b"); 1.357 +} 1.358 + 1.359 +function dynamicDefault5() { 1.360 + $('foo5').setAttribute("type", "submit") 1.361 + is(idColor("5"),"rgb(0,128,0)", "CSS dynamic-default 5"); 1.362 +} 1.363 + 1.364 +function dynamicDefault6() { 1.365 + var but = document.createElement("input"); 1.366 + but.setAttribute("type", "submit"); 1.367 + $('div6').insertBefore(but, $('div6').firstChild); 1.368 + is(idColor("6a"),"rgb(0,128,0)", "CSS dynamic-default 6a"); 1.369 + is(idColor("6b"),"rgb(0,128,0)", "CSS dynamic-default 6b"); 1.370 +} 1.371 + 1.372 +function dynamicDefault7() { 1.373 + var but = document.createElement("input"); 1.374 + but.setAttribute("type", "submit"); 1.375 + $('div7').insertBefore(but, $('div7').firstChild); 1.376 + is(idColor("7a"),"rgb(0,128,0)", "CSS dynamic-default 7a"); 1.377 + is(idColor("7b"),"rgb(0,128,0)", "CSS dynamic-default 7b"); 1.378 +} 1.379 + 1.380 +function dynamicDefault8() { 1.381 + var but = document.createElement("input"); 1.382 + but.setAttribute("type", "image"); 1.383 + $('div8').insertBefore(but, $('div8').firstChild); 1.384 + is(idColor("8a"),"rgb(0,128,0)", "CSS dynamic-default 8a"); 1.385 + is(idColor("8b"),"rgb(0,128,0)", "CSS dynamic-default 8b"); 1.386 +} 1.387 + 1.388 +function dynamicDefault9() { 1.389 + var but = document.createElement("input"); 1.390 + but.setAttribute("type", "image"); 1.391 + $('div9').insertBefore(but, $('div9').firstChild); 1.392 + is(idColor("9a"),"rgb(0,128,0)", "CSS dynamic-default 9a"); 1.393 + is(idColor("9b"),"rgb(0,128,0)", "CSS dynamic-default 9b"); 1.394 +} 1.395 + 1.396 +function dynamicDefault10() { 1.397 + var inputs = $('div10').getElementsByTagName("input"); 1.398 + $('div10').removeChild(inputs[0]); 1.399 + is(idColor("10a"),"rgb(0,128,0)", "CSS dynamic-default 10a"); 1.400 + is(idColor("10b"),"rgb(0,128,0)", "CSS dynamic-default 10b"); 1.401 +} 1.402 + 1.403 +function dynamicDefault11() { 1.404 + var inputs = $('div11').getElementsByTagName("input"); 1.405 + $('div11').removeChild(inputs[0]); 1.406 + is(idColor("11a"),"rgb(0,128,0)", "CSS dynamic-default 11a"); 1.407 + is(idColor("11b"),"rgb(0,128,0)", "CSS dynamic-default 11b"); 1.408 +} 1.409 + 1.410 +function dynamicDefault12() { 1.411 + var inputs = $('div12').getElementsByTagName("input"); 1.412 + $('div12').removeChild(inputs[0]); 1.413 + is(idColor("12a"),"rgb(0,128,0)", "CSS dynamic-default 12a"); 1.414 + is(idColor("12b"),"rgb(0,128,0)", "CSS dynamic-default 12b"); 1.415 +} 1.416 + 1.417 +function dynamicDefault13() { 1.418 + var inputs = $('div13').getElementsByTagName("input"); 1.419 + $('div13').removeChild(inputs[0]); 1.420 + is(idColor("13a"),"rgb(0,128,0)", "CSS dynamic-default 13a"); 1.421 + is(idColor("13b"),"rgb(0,128,0)", "CSS dynamic-default 13b"); 1.422 +} 1.423 + 1.424 +function dynamicDefault14() { 1.425 + var div1 = document.getElementById("div14a"); 1.426 + var inputs = div1.getElementsByTagName("input"); 1.427 + var firstElement = div1.removeChild(inputs[0]); 1.428 + var div2 = document.getElementById("div14b"); 1.429 + inputs = div2.getElementsByTagName("input"); 1.430 + var secondElement = div2.removeChild(inputs[0]); 1.431 + div1.insertBefore(secondElement, div1.firstChild); 1.432 + div2.insertBefore(firstElement, div2.firstChild); 1.433 + is(idColor("14a"),"rgb(0,128,0)", "CSS dynamic-default 14a"); 1.434 + is(idColor("14b"),"rgb(0,128,0)", "CSS dynamic-default 14b"); 1.435 +} 1.436 + 1.437 +function dynamicDefault15() { 1.438 + var div1 = document.getElementById("div15a"); 1.439 + var inputs = div1.getElementsByTagName("input"); 1.440 + var firstElement = div1.removeChild(inputs[0]); 1.441 + var div2 = document.getElementById("div15b"); 1.442 + inputs = div2.getElementsByTagName("input"); 1.443 + var secondElement = div2.removeChild(inputs[0]); 1.444 + div1.insertBefore(secondElement, div1.firstChild); 1.445 + div2.insertBefore(firstElement, div2.firstChild); 1.446 + is(idColor("15a"),"rgb(0,128,0)", "CSS dynamic-default 15a"); 1.447 + is(idColor("15b"),"rgb(0,128,0)", "CSS dynamic-default 15b"); 1.448 +} 1.449 + 1.450 +function dynamicDefault16() { 1.451 + $("foo16").setAttribute("type", "button"); 1.452 + is(idColor("16a"),"rgb(0,128,0)", "CSS dynamic-default 16a"); 1.453 + is(idColor("16b"),"rgb(0,128,0)", "CSS dynamic-default 16b"); 1.454 +} 1.455 + 1.456 +function dynamicDefault17() { 1.457 + $("foo17").setAttribute("type", "submit"); 1.458 + is(idColor("17a"),"rgb(0,128,0)", "CSS dynamic-default 17a"); 1.459 + is(idColor("17b"),"rgb(0,128,0)", "CSS dynamic-default 17b"); 1.460 +} 1.461 + 1.462 +function dynamicDefault18() { 1.463 + $("foo18").setAttribute("type", "submit"); 1.464 + is(idColor("18a"),"rgb(0,128,0)", "CSS dynamic-default 18a"); 1.465 + is(idColor("18b"),"rgb(0,128,0)", "CSS dynamic-default 18b"); 1.466 +} 1.467 + 1.468 +function dynamicDefault19() { 1.469 + var newSubmit = document.createElement("input"); 1.470 + newSubmit.setAttribute("type", "submit"); 1.471 + var div1 = document.getElementById("div19"); 1.472 + div1.insertBefore(newSubmit, div1.firstChild); 1.473 + is(idColor("19a"),"rgb(0,128,0)", "CSS dynamic-default 19a"); 1.474 +} 1.475 + 1.476 +function dynamicDefault20() { 1.477 + var newSubmit = document.createElement("input"); 1.478 + newSubmit.setAttribute("type", "image"); 1.479 + var div1 = document.getElementById("div20"); 1.480 + div1.insertBefore(newSubmit, div1.firstChild); 1.481 + is(idColor("20a"),"rgb(0,128,0)", "CSS dynamic-default 20a"); 1.482 +} 1.483 + 1.484 +addLoadEvent(dynamicDefault1); 1.485 +addLoadEvent(dynamicDefault2); 1.486 +addLoadEvent(dynamicDefault3); 1.487 +addLoadEvent(dynamicDefault4); 1.488 +addLoadEvent(dynamicDefault5); 1.489 +addLoadEvent(dynamicDefault6); 1.490 +addLoadEvent(dynamicDefault7); 1.491 +addLoadEvent(dynamicDefault8); 1.492 +addLoadEvent(dynamicDefault9); 1.493 +addLoadEvent(dynamicDefault10); 1.494 +addLoadEvent(dynamicDefault11); 1.495 +addLoadEvent(dynamicDefault12); 1.496 +addLoadEvent(dynamicDefault13); 1.497 +addLoadEvent(dynamicDefault14); 1.498 +addLoadEvent(dynamicDefault15); 1.499 +addLoadEvent(dynamicDefault16); 1.500 +addLoadEvent(dynamicDefault17); 1.501 +addLoadEvent(dynamicDefault18); 1.502 +addLoadEvent(dynamicDefault19); 1.503 +addLoadEvent(dynamicDefault20); 1.504 + 1.505 +addLoadEvent(SimpleTest.finish); 1.506 + 1.507 +</script> 1.508 +</pre> 1.509 +</body> 1.510 +</html> 1.511 +