2 <script src=
"../../../resources/js-test.js"></script>
8 .t1 .select::selection,
9 .t2 .select::selection:window-inactive {
10 background-color: green;
34 description("Style invalidation for ::selection");
36 var red
= "rgb(255, 0, 0)";
37 var green
= "rgb(0, 128, 0)";
39 function setSelection(textNode
) {
40 var range
= document
.createRange();
41 range
.setStart(textNode
, 0);
42 range
.setEnd(textNode
, 1);
43 window
.getSelection().addRange(range
);
46 var select
= document
.querySelectorAll(".select");
48 setSelection(select
[0].firstChild
);
49 shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "red");
51 document
.body
.offsetTop
; // Force recalc.
54 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
55 shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "green");
57 shouldBeDefined(window
.testRunner
);
58 testRunner
.setWindowIsKey(false);
60 setSelection(select
[1].firstChild
);
61 shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "red");
63 document
.body
.offsetTop
; // Force recalc.
66 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
67 shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "green");