Index: Source/core/css/RuleSetTest.cpp |
diff --git a/Source/core/css/RuleSetTest.cpp b/Source/core/css/RuleSetTest.cpp |
index e9b70df4b3a214603d70ea31681689d8f0bb0ab8..a5264782217457f9c024063e05a921e19c4d04eb 100644 |
--- a/Source/core/css/RuleSetTest.cpp |
+++ b/Source/core/css/RuleSetTest.cpp |
@@ -136,4 +136,78 @@ TEST(RuleSetTest, findBestRuleSetAndAdd_DivWithContent) |
ASSERT_EQ(valueStr, rules->at(0).selector().value()); |
} |
+TEST(RuleSetTest, findBestRuleSetAndAdd_Host) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(":host { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(1u, rules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(":host(#x) { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(1u, rules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(":host-context(*) { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(1u, rules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(":host-context(#x) { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(1u, rules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* shadowRules = ruleSet.shadowHostRules(); |
+ const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); |
+ const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); |
+ ASSERT_EQ(0u, shadowRules->size()); |
+ ASSERT_EQ(1u, idRules->size()); |
+ ASSERT_EQ(1u, classRules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndClass) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(".foo:host { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(0u, rules->size()); |
+} |
+ |
+TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) |
+{ |
+ CSSTestHelper helper; |
+ |
+ helper.addCSSRules(".foo:host-context(*) { }"); |
+ RuleSet& ruleSet = helper.ruleSet(); |
+ const Vector<RuleData>* rules = ruleSet.shadowHostRules(); |
+ ASSERT_EQ(0u, rules->size()); |
+} |
+ |
} // namespace blink |