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

Unified Diff: third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp

Issue 1683923003: Don't add siblingRules with combinator left of ::content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing clear Created 4 years, 10 months 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 | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
diff --git a/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp b/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
index 95e7c0acb49ad0cb05914363ad7f4b85630b2b29..64168dc90e4d99ab7d0a79066ed2cf0da41dd460 100644
--- a/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
+++ b/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
@@ -44,6 +44,15 @@ public:
m_ruleFeatureSet.updateInvalidationSets(ruleData);
}
+ void collectFeatures(const String& selectorText)
+ {
+ CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserContext(), nullptr, selectorText);
+
+ RefPtrWillBeRawPtr<StyleRule> styleRule = StyleRule::create(std::move(selectorList), MutableStylePropertySet::create(HTMLStandardMode));
+ RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState);
+ m_ruleFeatureSet.collectFeaturesFromRuleData(ruleData);
+ }
+
void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, const AtomicString& className) const
{
Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLElement>::firstChild(*m_document->body()));
@@ -170,6 +179,11 @@ public:
EXPECT_TRUE(attributes.contains(attribute));
}
+ void expectSiblingRuleCount(unsigned count)
+ {
+ EXPECT_EQ(count, m_ruleFeatureSet.siblingRules.size());
+ }
+
DEFINE_INLINE_TRACE()
{
#if ENABLE(OILPAN)
@@ -337,4 +351,58 @@ TEST_F(RuleFeatureSetTest, contentPseudo)
expectClassesInvalidation("b", "c", invalidationLists.descendants);
}
+TEST_F(RuleFeatureSetTest, siblingRulesBeforeContentPseudo)
+{
+ collectFeatures("a + b ::content .c");
+ expectSiblingRuleCount(0);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesAfterContentPseudo)
+{
+ collectFeatures(".a ::content .b + .c");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesNthBeforeContentPseudo)
+{
+ collectFeatures(":nth-child(2) ::content .a");
+ expectSiblingRuleCount(0);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesNthAfterContentPseudo)
+{
+ collectFeatures(".a ::content :nth-child(2)");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesBeforeDeep)
+{
+ collectFeatures("a + b /deep/ .c");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesAfterDeep)
+{
+ collectFeatures(".a /deep/ .b + .c");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesBeforeShadow)
+{
+ collectFeatures(".a + .b::shadow .c");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesAfterShadow)
+{
+ collectFeatures(".a ::shadow .b + .c");
+ expectSiblingRuleCount(1);
+}
+
+TEST_F(RuleFeatureSetTest, siblingRulesBeforeSlotted)
+{
+ collectFeatures(".a + ::slotted(.b)");
+ expectSiblingRuleCount(1);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698