OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/js-test.js"></script> |
| 3 <style> |
| 4 .a1 span { background-color: green } |
| 5 .a2 span + div { background-color: green } |
| 6 .a3 * { background-color: green } |
| 7 </style> |
| 8 <div id="t1"> |
| 9 <span></span> |
| 10 <span></span> |
| 11 <div></div> |
| 12 <div></div> |
| 13 </div> |
| 14 <div id="t2"> |
| 15 <span></span> |
| 16 <span></span> |
| 17 <div></div> |
| 18 <div></div> |
| 19 </div> |
| 20 <div id="t3"> |
| 21 <span></span> |
| 22 <span></span> |
| 23 <span></span> |
| 24 <span></span> |
| 25 </div> |
| 26 <script> |
| 27 description("Check that targeted class invalidation works for type selectors."); |
| 28 |
| 29 var transparent = "rgba(0, 0, 0, 0)"; |
| 30 var green = "rgb(0, 128, 0)"; |
| 31 |
| 32 var children = [ |
| 33 document.querySelectorAll("#t1 *"), |
| 34 document.querySelectorAll("#t2 *"), |
| 35 document.querySelectorAll("#t3 *") |
| 36 ]; |
| 37 |
| 38 document.body.offsetTop; // Force style recalc. |
| 39 |
| 40 for (var i=0; i<children.length; i++) { |
| 41 for (var j=0; j<children[i].length; j++) { |
| 42 var evalString = "getComputedStyle(children["+i+"]["+j+"], null).backgro
undColor"; |
| 43 shouldBe(evalString, "transparent"); |
| 44 } |
| 45 } |
| 46 |
| 47 document.body.offsetTop; // Force style recalc. |
| 48 |
| 49 document.getElementById("t1").className = "a1"; |
| 50 if (window.internals) |
| 51 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "3"); |
| 52 shouldBe("getComputedStyle(children[0][0], null).backgroundColor", "green"); |
| 53 shouldBe("getComputedStyle(children[0][1], null).backgroundColor", "green"); |
| 54 shouldBe("getComputedStyle(children[0][2], null).backgroundColor", "transparent"
); |
| 55 shouldBe("getComputedStyle(children[0][3], null).backgroundColor", "transparent"
); |
| 56 |
| 57 document.body.offsetLeft; // force style recalc. |
| 58 |
| 59 document.getElementById("t2").className = "a2"; |
| 60 if (window.internals) |
| 61 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "5"); |
| 62 shouldBe("getComputedStyle(children[1][0], null).backgroundColor", "transparent"
); |
| 63 shouldBe("getComputedStyle(children[1][1], null).backgroundColor", "transparent"
); |
| 64 shouldBe("getComputedStyle(children[1][2], null).backgroundColor", "green"); |
| 65 shouldBe("getComputedStyle(children[1][3], null).backgroundColor", "transparent"
); |
| 66 |
| 67 document.body.offsetLeft; // force style recalc. |
| 68 |
| 69 document.getElementById("t3").className = "a3"; |
| 70 if (window.internals) |
| 71 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "5"); |
| 72 shouldBe("getComputedStyle(children[2][0], null).backgroundColor", "green"); |
| 73 shouldBe("getComputedStyle(children[2][1], null).backgroundColor", "green"); |
| 74 shouldBe("getComputedStyle(children[2][2], null).backgroundColor", "green"); |
| 75 shouldBe("getComputedStyle(children[2][3], null).backgroundColor", "green"); |
| 76 |
| 77 </script> |
OLD | NEW |