Index: LayoutTests/fast/css/invalidation/selection-pseudo.html |
diff --git a/LayoutTests/fast/css/invalidation/selection-pseudo.html b/LayoutTests/fast/css/invalidation/selection-pseudo.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1fcb40ce5839d6087af8930788573260901b53cb |
--- /dev/null |
+++ b/LayoutTests/fast/css/invalidation/selection-pseudo.html |
@@ -0,0 +1,68 @@ |
+<!DOCTYPE html> |
+<script src="../../../resources/js-test.js"></script> |
+<style> |
+.select::selection { |
+ background-color: red; |
+} |
+ |
+.t1 .select::selection, |
+.t2 .select::selection:window-inactive { |
+ background-color: green; |
+} |
+</style> |
+<div id="t1"> |
+ <div> |
+ <div class="select"> |
+ 1 |
+ <span></span> |
+ <span></span> |
+ </div> |
+ <div></div> |
+ </div> |
+</div> |
+<div id="t2"> |
+ <div> |
+ <div class="select"> |
+ 2 |
+ <span></span> |
+ <span></span> |
+ </div> |
+ <div></div> |
+ </div> |
+</div> |
+<script> |
+description("Style invalidation for ::selection"); |
+ |
+var red = "rgb(255, 0, 0)"; |
+var green = "rgb(0, 128, 0)"; |
+ |
+function setSelection(textNode) { |
+ var range = document.createRange(); |
+ range.setStart(textNode, 0); |
+ range.setEnd(textNode, 1); |
+ window.getSelection().addRange(range); |
+} |
+ |
+var select = document.querySelectorAll(".select"); |
+ |
+setSelection(select[0].firstChild); |
+shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "red"); |
+ |
+document.body.offsetTop; // Force recalc. |
+t1.className = "t1"; |
+if (window.internals) |
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
+shouldBe("getComputedStyle(select[0], '::selection').backgroundColor", "green"); |
+ |
+shouldBeDefined(window.testRunner); |
+testRunner.setWindowIsKey(false); |
+ |
+setSelection(select[1].firstChild); |
+shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "red"); |
+ |
+document.body.offsetTop; // Force recalc. |
+t2.className = "t2"; |
+if (window.internals) |
+ shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
+shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "green"); |
+</script> |