Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / invalidation / selection-pseudo.html
blob50c122b9584a1cd53cf7b97d8efd1263350ed047
1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script>
3 <style>
4 .select::selection {
5 background-color: red;
8 .t1 .select::selection,
9 .t2 .select::selection:window-inactive {
10 background-color: green;
12 </style>
13 <div id="t1">
14 <div>
15 <div class="select">
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">
27 <span></span>
28 <span></span>
29 </div>
30 <div></div>
31 </div>
32 </div>
33 <script>
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.
52 t1.className = "t1";
53 if (window.internals)
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.
64 t2.className = "t2";
65 if (window.internals)
66 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
67 shouldBe("getComputedStyle(select[1], '::selection').backgroundColor", "green");
68 </script>