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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp

Issue 2500813003: Parser support for >>> (shadow-piercing descendant) combinator. (Closed)
Patch Set: Address timloh's comments. Created 4 years, 1 month 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
Index: third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
index b32a77011a18d051d9de2ece5d2580b6bf8b7875..95ab5014a7955939b95f44c1297573e6a4bab60a 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
@@ -274,4 +274,60 @@ TEST(CSSSelectorParserTest, SerializedUniversal) {
}
}
+TEST(CSSSelectorParserTest, InvalidDescendantCombinatorInDynamicProfile) {
+ const char* testCases[] = {"div >>>> span", "div >>> span", "div >> span"};
+
+ CSSParserContext context(HTMLStandardMode, nullptr,
+ CSSParserContext::DynamicProfile);
+ StyleSheetContents* sheet = StyleSheetContents::create(context);
+
+ for (auto testCase : testCases) {
+ SCOPED_TRACE(testCase);
+ CSSTokenizer tokenizer(testCase);
+ CSSParserTokenRange range = tokenizer.tokenRange();
+ CSSSelectorList list =
+ CSSSelectorParser::parseSelector(range, context, sheet);
+ EXPECT_FALSE(list.isValid());
+ }
+}
+
+TEST(CSSSelectorParserTest, InvalidDescendantCombinatorInStaticProfile) {
+ const char* testCases[] = {"div >>>> span", "div >> span", "div >> > span",
+ "div > >> span", "div > > > span"};
+
+ CSSParserContext context(HTMLStandardMode, nullptr,
+ CSSParserContext::StaticProfile);
+ StyleSheetContents* sheet = StyleSheetContents::create(context);
+
+ for (auto testCase : testCases) {
+ SCOPED_TRACE(testCase);
+ CSSTokenizer tokenizer(testCase);
+ CSSParserTokenRange range = tokenizer.tokenRange();
+ CSSSelectorList list =
+ CSSSelectorParser::parseSelector(range, context, sheet);
+ EXPECT_FALSE(list.isValid());
+ }
+}
+
+TEST(CSSSelectorParserTest, ShadowPiercingCombinatorInStaticProfile) {
+ const char* testCases[][2] = {{"div >>> span", "div >>> span"},
+ {"div >>/**/> span", "div >>> span"},
+ {"div >/**/>> span", "div >>> span"},
+ {"div >/**/>/**/> span", "div >>> span"}};
+
+ CSSParserContext context(HTMLStandardMode, nullptr,
+ CSSParserContext::StaticProfile);
+ StyleSheetContents* sheet = StyleSheetContents::create(context);
+
+ for (auto testCase : testCases) {
+ SCOPED_TRACE(testCase[0]);
+ CSSTokenizer tokenizer(testCase[0]);
+ CSSParserTokenRange range = tokenizer.tokenRange();
+ CSSSelectorList list =
+ CSSSelectorParser::parseSelector(range, context, sheet);
+ EXPECT_TRUE(list.isValid());
+ EXPECT_STREQ(testCase[1], list.selectorsText().ascii().data());
+ }
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698