Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: Source/core/css/RuleSetTest.cpp

Issue 789403005: Keep a separate list of :host(-context) rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added tests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/RuleSet.cpp ('k') | Source/core/css/resolver/ScopedStyleResolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/css/RuleSet.cpp ('k') | Source/core/css/resolver/ScopedStyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698