blob: 451e666837b280a30f0e1802e73dafdafbe50e03 [file] [log] [blame]
benjamin@webkit.org8a05e822014-10-22 03:28:29 +00001<!DOCTYPE html>
2<html>
3<head>
4<script src="../../resources/js-test-pre.js"></script>
5<style>
6* {
7 color: black;
8}
9target:not(.Case1) {
10 color: rgb(0, 1, 2);
11}
12target:not(foo, .Case2, bar) {
13 color: rgb(3, 4, 5);
14}
15target:not(foo1, :matches(foo2, .Case3, bar1), bar2) {
16 color: rgb(6, 7, 8);
17}
18target:not(foo1, :not(foo2, .Case4, bar1), bar2) {
19 color: rgb(9, 10, 11);
20}
21target:not(foo1, :matches(foo2, :matches(foo3, .Case5, bar1), bar2), bar3) {
22 color: rgb(12, 13, 14);
23}
24</style>
25</head>
26<body>
27 <div>
28 <!-- With renderer -->
29 <target class="Case1 Case2 Case3 Case5"></target>
30 </div>
31 <div style="display:none;">
32 <!-- Without renderer -->
33 <target class="Case1 Case2 Case3 Case5"></target>
34 </div>
35</body>
36<script>
37
38description('Test that the style of elements is invalidated correctly when a class changes inside :not() can affect its style. Elements are only invalidate if the class changed affects the style. It is important to account nested selector lists.');
39
40function addClass(name) {
41 var allTargets = document.querySelectorAll("target");
42 allTargets[0].classList.add(name);
43 allTargets[1].classList.add(name);
44}
45
46function removeClass(name) {
47 var allTargets = document.querySelectorAll("target");
48 allTargets[0].classList.remove(name);
49 allTargets[1].classList.remove(name);
50}
51
52function checkStyle(expectedColor) {
53 shouldBeEqualToString('getComputedStyle(document.querySelectorAll("target")[0]).color', expectedColor);
54 shouldBeEqualToString('getComputedStyle(document.querySelectorAll("target")[1]).color', expectedColor);
55}
56
57// Force a layout to ensure we don't have dirty styles.
58var offsetTop = document.documentElement.offsetTop;
59
60checkStyle('rgb(0, 0, 0)');
61
62// Change the classes one by one.
63removeClass('Case1');
64checkStyle('rgb(0, 1, 2)');
65addClass('Case1');
66checkStyle('rgb(0, 0, 0)');
67
68removeClass('Case2');
69checkStyle('rgb(3, 4, 5)');
70addClass('Case2');
71checkStyle('rgb(0, 0, 0)');
72
73removeClass('Case3');
74checkStyle('rgb(6, 7, 8)');
75addClass('Case3');
76checkStyle('rgb(0, 0, 0)');
77
78addClass('Case4');
79checkStyle('rgb(9, 10, 11)');
80removeClass('Case4');
81checkStyle('rgb(0, 0, 0)');
82
83removeClass('Case5');
84checkStyle('rgb(12, 13, 14)');
85addClass('Case5');
86checkStyle('rgb(0, 0, 0)');
87
88
89// Remove the classes one after the other.
90removeClass('Case1');
91checkStyle('rgb(0, 1, 2)');
92removeClass('Case2');
93checkStyle('rgb(3, 4, 5)');
94removeClass('Case3');
95checkStyle('rgb(6, 7, 8)');
96addClass('Case4');
97checkStyle('rgb(9, 10, 11)');
98removeClass('Case5');
99checkStyle('rgb(12, 13, 14)');
100</script>
101<script src="../../resources/js-test-post.js"></script>
102</html>