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 <script> |
| 7 description("Check that targeted class invalidation works with the :host pseudo
class."); |
| 8 |
| 9 // Create shadow trees |
| 10 |
| 11 var host1 = document.getElementById("host1"); |
| 12 host1.createShadowRoot().innerHTML = "<style>:host(.c1) { background-color: gree
n }</style><div></div><div></div><div></div><div></div><div></div>"; |
| 13 |
| 14 var host2 = document.getElementById("host2"); |
| 15 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>'; |
| 16 |
| 17 var host3 = document.getElementById("host3"); |
| 18 host3.createShadowRoot().innerHTML = "<style>:host(:not(.c3)) { background-color
: green }</style><div></div><div></div><div></div><div></div>"; |
| 19 |
| 20 var transparent = "rgba(0, 0, 0, 0)"; |
| 21 var green = "rgb(0, 128, 0)"; |
| 22 |
| 23 var inner = host2.shadowRoot.getElementById("inner"); |
| 24 |
| 25 shouldBe("getComputedStyle(host1, null).backgroundColor", "transparent"); |
| 26 shouldBe("getComputedStyle(inner, null).backgroundColor", "transparent"); |
| 27 shouldBe("getComputedStyle(host3, null).backgroundColor", "transparent"); |
| 28 |
| 29 document.body.offsetLeft; // force style recalc. |
| 30 |
| 31 host1.className = "c1"; |
| 32 if (window.internals) |
| 33 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); |
| 34 shouldBe("getComputedStyle(host1, null).backgroundColor", "green"); |
| 35 |
| 36 document.body.offsetLeft; // force style recalc. |
| 37 |
| 38 host2.className = "c2"; |
| 39 if (window.internals) |
| 40 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
| 41 shouldBe("getComputedStyle(inner, null).backgroundColor", "green"); |
| 42 |
| 43 document.body.offsetLeft; // force style recalc. |
| 44 |
| 45 host3.className = ""; |
| 46 if (window.internals) |
| 47 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "6"); |
| 48 shouldBe("getComputedStyle(host3, null).backgroundColor", "green"); |
| 49 </script> |
OLD | NEW |