OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/js-test.js"></script> |
| 3 <div id="host1"></div> |
| 4 <div id="host2"></div> |
| 5 <div id="host3" class="c3"></div> |
| 6 <div id="host4"></div> |
| 7 <script> |
| 8 description("Check that targeted class invalidation works with the :host pseudo
class."); |
| 9 |
| 10 // Create shadow trees |
| 11 |
| 12 var host1 = document.getElementById("host1"); |
| 13 host1.createShadowRoot().innerHTML = "<style>:host(.c1) { background-color: gree
n }</style><div></div><div></div><div></div><div></div><div></div>"; |
| 14 |
| 15 var host2 = document.getElementById("host2"); |
| 16 host2.createShadowRoot().innerHTML = '<style>:host(.c2) .inner { background-colo
r: green }</style><div></div><div></div><div></div><div><span id="inner" class="
inner"></span></div>'; |
| 17 |
| 18 var host3 = document.getElementById("host3"); |
| 19 host3.createShadowRoot().innerHTML = "<style>:host(#host3:not(.c3)) { background
-color: green }</style><div></div><div></div><div></div><div></div>"; |
| 20 |
| 21 var host4 = document.getElementById("host4"); |
| 22 host4.createShadowRoot().innerHTML = "<style>:host(.nomatch, .c4) { background-c
olor: green }</style><div></div><div></div><div></div><div></div>"; |
| 23 |
| 24 var transparent = "rgba(0, 0, 0, 0)"; |
| 25 var green = "rgb(0, 128, 0)"; |
| 26 |
| 27 var inner = host2.shadowRoot.getElementById("inner"); |
| 28 |
| 29 shouldBe("getComputedStyle(host1, null).backgroundColor", "transparent"); |
| 30 shouldBe("getComputedStyle(inner, null).backgroundColor", "transparent"); |
| 31 shouldBe("getComputedStyle(host3, null).backgroundColor", "transparent"); |
| 32 shouldBe("getComputedStyle(host4, null).backgroundColor", "transparent"); |
| 33 |
| 34 document.body.offsetLeft; // force style recalc. |
| 35 |
| 36 host1.className = "c1"; |
| 37 if (window.internals) |
| 38 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); |
| 39 shouldBe("getComputedStyle(host1, null).backgroundColor", "green"); |
| 40 |
| 41 document.body.offsetLeft; // force style recalc. |
| 42 |
| 43 host2.className = "c2"; |
| 44 if (window.internals) |
| 45 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
| 46 shouldBe("getComputedStyle(inner, null).backgroundColor", "green"); |
| 47 |
| 48 document.body.offsetLeft; // force style recalc. |
| 49 |
| 50 host3.className = ""; |
| 51 if (window.internals) |
| 52 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "6"); |
| 53 shouldBe("getComputedStyle(host3, null).backgroundColor", "green"); |
| 54 |
| 55 document.body.offsetLeft; // force style recalc. |
| 56 |
| 57 host4.className = "c4"; |
| 58 if (window.internals) |
| 59 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); |
| 60 shouldBe("getComputedStyle(host4, null).backgroundColor", "green"); |
| 61 |
| 62 </script> |
OLD | NEW |