OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
4 <style></style> | 4 <style></style> |
5 <div> | 5 <div> |
6 <div></div> | 6 <div></div> |
7 <div></div> | 7 <div></div> |
8 <div></div> | 8 <div></div> |
9 <div></div> | 9 <div></div> |
10 <div></div> | 10 <div></div> |
11 <div id="found"> | 11 <div id="found"> |
12 <div></div> | 12 <div></div> |
13 </div> | 13 </div> |
14 <span></span> | 14 <span></span> |
15 </div> | 15 </div> |
| 16 <div id="placeholderWrapper"> |
| 17 <textarea placeholder="Placeholder text"></textarea> |
| 18 </div> |
| 19 <textarea placeholder="Placeholder text"></textarea> |
16 <script> | 20 <script> |
17 test(() => { | 21 test(() => { |
18 assert_true(!!window.internals, "Tests require window.internals."); | 22 assert_true(!!window.internals, "Tests require window.internals."); |
19 }, "Test for prerequisites."); | 23 }, "Test for prerequisites."); |
20 | 24 |
21 function applyRuleAndReturnAffectedElementCount(ruleString) { | 25 function applyRuleAndReturnAffectedElementCount(ruleString) { |
22 document.body.offsetTop; | 26 document.body.offsetTop; |
23 document.styleSheets[0].insertRule(ruleString, 0); | 27 document.styleSheets[0].insertRule(ruleString, 0); |
24 var recalcCount = internals.updateStyleAndReturnAffectedElementCount(); | 28 var recalcCount = internals.updateStyleAndReturnAffectedElementCount(); |
25 document.styleSheets[0].removeRule(); | 29 document.styleSheets[0].removeRule(); |
(...skipping 10 matching lines...) Expand all Loading... |
36 assert_equals(applyRuleAndReturnAffectedElementCount( | 40 assert_equals(applyRuleAndReturnAffectedElementCount( |
37 "#notfound div { background: red }"), 0, | 41 "#notfound div { background: red }"), 0, |
38 "Check that none of divs are recalculated."); | 42 "Check that none of divs are recalculated."); |
39 }, "A type selector scoped in an unknown id should not invalidate any elemen
ts."); | 43 }, "A type selector scoped in an unknown id should not invalidate any elemen
ts."); |
40 | 44 |
41 test(() => { | 45 test(() => { |
42 assert_equals(applyRuleAndReturnAffectedElementCount( | 46 assert_equals(applyRuleAndReturnAffectedElementCount( |
43 "#found div { background: red }"), 1, | 47 "#found div { background: red }"), 1, |
44 "Check that only one of the divs is recalculated."); | 48 "Check that only one of the divs is recalculated."); |
45 }, "A type selector scoped by a known id should only invalidate descendants
of the element with that id."); | 49 }, "A type selector scoped by a known id should only invalidate descendants
of the element with that id."); |
| 50 |
| 51 test(() => { |
| 52 assert_equals(applyRuleAndReturnAffectedElementCount( |
| 53 "::-webkit-input-placeholder { background: green }"), 2, |
| 54 "Check that only custom pseudo elements are recalculated."); |
| 55 }, "A style rule with a custom pseudo element should only invalidate custom
pseudo elements."); |
| 56 |
| 57 test(() => { |
| 58 assert_equals(applyRuleAndReturnAffectedElementCount( |
| 59 "#notfound ::-webkit-input-placeholder { background: green }"), 0, |
| 60 "Check that no elements are recalculated."); |
| 61 }, "A custom pseudo element scoped in an unknown id should not invalidate an
y elements."); |
| 62 |
| 63 test(() => { |
| 64 assert_equals(applyRuleAndReturnAffectedElementCount( |
| 65 "#placeholderWrapper ::-webkit-input-placeholder { background: green
}"), 1, |
| 66 "Check that only the scoped custom pseudo element is recalculated.")
; |
| 67 }, "A custom pseudo element scoped in a known id should only invalidate desc
endants of the element with that id."); |
46 </script> | 68 </script> |
OLD | NEW |