benjamin@webkit.org | 8a05e82 | 2014-10-22 03:28:29 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../../resources/js-test-pre.js"></script> |
| 5 | <style> |
| 6 | * { |
| 7 | color: black; |
| 8 | } |
| 9 | target:not(.Case1) { |
| 10 | color: rgb(0, 1, 2); |
| 11 | } |
| 12 | target:not(foo, .Case2, bar) { |
| 13 | color: rgb(3, 4, 5); |
| 14 | } |
| 15 | target:not(foo1, :matches(foo2, .Case3, bar1), bar2) { |
| 16 | color: rgb(6, 7, 8); |
| 17 | } |
| 18 | target:not(foo1, :not(foo2, .Case4, bar1), bar2) { |
| 19 | color: rgb(9, 10, 11); |
| 20 | } |
| 21 | target: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 | |
| 38 | description('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 | |
| 40 | function addClass(name) { |
| 41 | var allTargets = document.querySelectorAll("target"); |
| 42 | allTargets[0].classList.add(name); |
| 43 | allTargets[1].classList.add(name); |
| 44 | } |
| 45 | |
| 46 | function removeClass(name) { |
| 47 | var allTargets = document.querySelectorAll("target"); |
| 48 | allTargets[0].classList.remove(name); |
| 49 | allTargets[1].classList.remove(name); |
| 50 | } |
| 51 | |
| 52 | function 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. |
| 58 | var offsetTop = document.documentElement.offsetTop; |
| 59 | |
| 60 | checkStyle('rgb(0, 0, 0)'); |
| 61 | |
| 62 | // Change the classes one by one. |
| 63 | removeClass('Case1'); |
| 64 | checkStyle('rgb(0, 1, 2)'); |
| 65 | addClass('Case1'); |
| 66 | checkStyle('rgb(0, 0, 0)'); |
| 67 | |
| 68 | removeClass('Case2'); |
| 69 | checkStyle('rgb(3, 4, 5)'); |
| 70 | addClass('Case2'); |
| 71 | checkStyle('rgb(0, 0, 0)'); |
| 72 | |
| 73 | removeClass('Case3'); |
| 74 | checkStyle('rgb(6, 7, 8)'); |
| 75 | addClass('Case3'); |
| 76 | checkStyle('rgb(0, 0, 0)'); |
| 77 | |
| 78 | addClass('Case4'); |
| 79 | checkStyle('rgb(9, 10, 11)'); |
| 80 | removeClass('Case4'); |
| 81 | checkStyle('rgb(0, 0, 0)'); |
| 82 | |
| 83 | removeClass('Case5'); |
| 84 | checkStyle('rgb(12, 13, 14)'); |
| 85 | addClass('Case5'); |
| 86 | checkStyle('rgb(0, 0, 0)'); |
| 87 | |
| 88 | |
| 89 | // Remove the classes one after the other. |
| 90 | removeClass('Case1'); |
| 91 | checkStyle('rgb(0, 1, 2)'); |
| 92 | removeClass('Case2'); |
| 93 | checkStyle('rgb(3, 4, 5)'); |
| 94 | removeClass('Case3'); |
| 95 | checkStyle('rgb(6, 7, 8)'); |
| 96 | addClass('Case4'); |
| 97 | checkStyle('rgb(9, 10, 11)'); |
| 98 | removeClass('Case5'); |
| 99 | checkStyle('rgb(12, 13, 14)'); |
| 100 | </script> |
| 101 | <script src="../../resources/js-test-post.js"></script> |
| 102 | </html> |