Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / css / invalidation / class-sibling-universal.html
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <style>
5 .t1 .sibling + *,
6 .t2 .sibling ~ *,
7 .t3 .sibling + :hover,
8 .t4 + .sibling,
9 .t5 + *,
10 .t6 ~ .sibling { background-color: rgb(0, 128, 0); }
11
12 #r3 { width: 10px; height: 10px }
13 </style>
14 <div>
15     <div id="t1">
16         <div class="sibling"></div>
17         <div id="r1"></div>
18     </div>
19 </div>
20 <div>
21     <div id="t2">
22         <div class="sibling"></div>
23         <div></div>
24         <div id="r2"></div>
25     </div>
26 </div>
27 <div>
28     <div id="t3">
29         <div class="sibling"></div>
30         <div id="r3"></div>
31     </div>
32 </div>
33 <div>
34     <div id="t4"></div>
35     <div id="r4" class="sibling">
36         <div></div>
37         <div></div>
38     </div>
39 </div>
40 <div>
41     <div id="t5"></div>
42     <div id="r5">
43         <div></div>
44         <div></div>
45     </div>
46 </div>
47 <div>
48     <div id="t6"></div>
49     <div></div>
50     <div id="r6" class="sibling">
51         <div></div>
52         <div></div>
53     </div>
54 </div>
55 <script>
56 document.body.offsetTop;
57
58 test(function() {
59     assert_true(!!window.internals, "This test only works with internals exposed present");
60     assert_equals(getComputedStyle(r1).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
61
62     t1.className = "t1";
63     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 3, "Subtree style recalc");
64     assert_equals(getComputedStyle(r1).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
65 }, "Adjacent with universal selector");
66
67 test(function() {
68     assert_true(!!window.internals, "This test only works with internals exposed present");
69     assert_equals(getComputedStyle(r2).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
70
71     t2.className = "t2";
72     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 4, "Subtree style recalc");
73     assert_equals(getComputedStyle(r2).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
74 }, "Indirect adjacent with universal selector");
75
76 test(function() {
77     assert_true(!!window.internals, "This test only works with internals exposed present");
78     assert_true(!!window.eventSender, "This test only works with eventSender present");
79
80     eventSender.mouseMoveTo(r3.offsetLeft + 1, r3.offsetTop + 1);
81     assert_equals(getComputedStyle(r3).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
82
83     t3.className = "t3";
84     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 3, "Subtree style recalc");
85     assert_equals(getComputedStyle(r3).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
86 }, "Adjacent with universal :hover selector");
87
88 test(function() {
89     assert_true(!!window.internals, "This test only works with internals exposed present");
90     assert_equals(getComputedStyle(r4).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
91
92     t4.className = "t4";
93     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 4, "Subtree style recalc");
94     assert_equals(getComputedStyle(r4).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
95 }, "Class change affecting selector for sibling class");
96
97 test(function() {
98     assert_true(!!window.internals, "This test only works with internals exposed present");
99     assert_equals(getComputedStyle(r5).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
100
101     t5.className = "t5";
102     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 4, "Subtree style recalc");
103     assert_equals(getComputedStyle(r5).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
104 }, "Class change affecting all sibling subtrees through a universal selector");
105
106 test(function() {
107     assert_true(!!window.internals, "This test only works with internals exposed present");
108     assert_equals(getComputedStyle(r6).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
109
110     t6.className = "t6";
111     assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 5, "Subtree style recalc");
112     assert_equals(getComputedStyle(r6).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
113 }, "Class change affecting all sibling subtrees through an indirect adjacent combinator");
114 </script>