OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/js-test.js"></script> |
| 3 <style> |
| 4 .select::selection { |
| 5 background-color: red; |
| 6 } |
| 7 |
| 8 .t1 .select::selection, |
| 9 .t2 .select::selection:window-inactive { |
| 10 background-color: green; |
| 11 } |
| 12 </style> |
| 13 <div id="t1"> |
| 14 <div> |
| 15 <div class="select"> |
| 16 1 |
| 17 <span></span> |
| 18 <span></span> |
| 19 </div> |
| 20 <div></div> |
| 21 </div> |
| 22 </div> |
| 23 <div id="t2"> |
| 24 <div> |
| 25 <div class="select"> |
| 26 2 |
| 27 <span></span> |
| 28 <span></span> |
| 29 </div> |
| 30 <div></div> |
| 31 </div> |
| 32 </div> |
| 33 <script> |
| 34 description("Style invalidation for ::selection"); |
| 35 |
| 36 var red = "rgb(255, 0, 0)"; |
| 37 var green = "rgb(0, 128, 0)"; |
| 38 |
| 39 function setSelection(textNode) { |
| 40 var range = document.createRange(); |
| 41 range.setStart(textNode, 0); |
| 42 range.setEnd(textNode, 1); |
| 43 window.getSelection().addRange(range); |
| 44 } |
| 45 |
| 46 var select = document.querySelectorAll(".select"); |
| 47 |
| 48 setSelection(select[0].firstChild); |
| 49 shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "red"); |
| 50 |
| 51 document.body.offsetTop; // Force recalc. |
| 52 t1.className = "t1"; |
| 53 if (window.internals) |
| 54 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
| 55 shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "green"); |
| 56 |
| 57 shouldBeDefined(window.testRunner); |
| 58 testRunner.setWindowIsKey(false); |
| 59 |
| 60 setSelection(select[1].firstChild); |
| 61 shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "red"); |
| 62 |
| 63 document.body.offsetTop; // Force recalc. |
| 64 t2.className = "t2"; |
| 65 if (window.internals) |
| 66 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
| 67 shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "green"); |
| 68 </script> |
OLD | NEW |