| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "core/css/RuleSet.h" | 30 #include "core/css/RuleSet.h" |
| 31 | 31 |
| 32 #include "core/css/CSSTestHelper.h" | 32 #include "core/css/CSSTestHelper.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "wtf/text/StringBuilder.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 TEST(RuleSetTest, findBestRuleSetAndAdd_CustomPseudoElements) { | 38 TEST(RuleSetTest, findBestRuleSetAndAdd_CustomPseudoElements) { |
| 38 CSSTestHelper helper; | 39 CSSTestHelper helper; |
| 39 | 40 |
| 40 helper.addCSSRules("summary::-webkit-details-marker { }"); | 41 helper.addCSSRules("summary::-webkit-details-marker { }"); |
| 41 RuleSet& ruleSet = helper.ruleSet(); | 42 RuleSet& ruleSet = helper.ruleSet(); |
| 42 AtomicString str("-webkit-details-marker"); | 43 AtomicString str("-webkit-details-marker"); |
| 43 const TerminatedArray<RuleData>* rules = | 44 const TerminatedArray<RuleData>* rules = |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 189 |
| 189 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) { | 190 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) { |
| 190 CSSTestHelper helper; | 191 CSSTestHelper helper; |
| 191 | 192 |
| 192 helper.addCSSRules(".foo:host-context(*) { }"); | 193 helper.addCSSRules(".foo:host-context(*) { }"); |
| 193 RuleSet& ruleSet = helper.ruleSet(); | 194 RuleSet& ruleSet = helper.ruleSet(); |
| 194 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 195 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 195 ASSERT_EQ(0u, rules->size()); | 196 ASSERT_EQ(0u, rules->size()); |
| 196 } | 197 } |
| 197 | 198 |
| 199 TEST(RuleSetTest, SelectorIndexLimit) { |
| 200 StringBuilder builder; |
| 201 |
| 202 for (unsigned i = 0; i < 16383; i++) |
| 203 builder.append("div,"); |
| 204 |
| 205 builder.append("b,span {}"); |
| 206 |
| 207 CSSTestHelper helper; |
| 208 helper.addCSSRules(builder.toString().ascii().data()); |
| 209 const RuleSet& ruleSet = helper.ruleSet(); |
| 210 const HeapTerminatedArray<RuleData>* rules = ruleSet.tagRules("b"); |
| 211 ASSERT_EQ(1u, rules->size()); |
| 212 EXPECT_EQ("b", rules->at(0).selector().tagQName().localName()); |
| 213 EXPECT_FALSE(ruleSet.tagRules("span")); |
| 214 } |
| 215 |
| 198 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |