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

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

Issue 2838013005: Update CSSSelectorParserTest so that it doesn't test /deep/ nor ::shadow (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSSelectorParser.h" 5 #include "core/css/parser/CSSSelectorParser.h"
6 6
7 #include "core/css/CSSSelectorList.h" 7 #include "core/css/CSSSelectorList.h"
8 #include "core/css/StyleSheetContents.h" 8 #include "core/css/StyleSheetContents.h"
9 #include "core/css/parser/CSSParserContext.h" 9 #include "core/css/parser/CSSParserContext.h"
10 #include "core/css/parser/CSSTokenizer.h" 10 #include "core/css/parser/CSSTokenizer.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 std::pair<int, int> ab; 99 std::pair<int, int> ab;
100 CSSTokenizer tokenizer(test_case); 100 CSSTokenizer tokenizer(test_case);
101 CSSParserTokenRange range = tokenizer.TokenRange(); 101 CSSParserTokenRange range = tokenizer.TokenRange();
102 bool passed = CSSSelectorParser::ConsumeANPlusB(range, ab); 102 bool passed = CSSSelectorParser::ConsumeANPlusB(range, ab);
103 EXPECT_FALSE(passed); 103 EXPECT_FALSE(passed);
104 } 104 }
105 } 105 }
106 106
107 TEST(CSSSelectorParserTest, ShadowDomPseudoInCompound) { 107 TEST(CSSSelectorParserTest, ShadowDomPseudoInCompound) {
108 const char* test_cases[][2] = {{"::shadow", "::shadow"}, 108 const char* test_cases[][2] = {{"::content", "::content"},
109 {".a::shadow", ".a::shadow"},
110 {"::content", "::content"},
111 {".a::content", ".a::content"}, 109 {".a::content", ".a::content"},
112 {"::content.a", "::content.a"}, 110 {"::content.a", "::content.a"},
113 {"::content.a.b", "::content.a.b"}, 111 {"::content.a.b", "::content.a.b"},
114 {".a::content.b", ".a::content.b"}, 112 {".a::content.b", ".a::content.b"},
115 {"::content:not(#id)", "::content:not(#id)"}}; 113 {"::content:not(#id)", "::content:not(#id)"}};
116 114
117 for (auto test_case : test_cases) { 115 for (auto test_case : test_cases) {
118 SCOPED_TRACE(test_case[0]); 116 SCOPED_TRACE(test_case[0]);
119 CSSTokenizer tokenizer(test_case[0]); 117 CSSTokenizer tokenizer(test_case[0]);
120 CSSParserTokenRange range = tokenizer.TokenRange(); 118 CSSParserTokenRange range = tokenizer.TokenRange();
121 CSSSelectorList list = CSSSelectorParser::ParseSelector( 119 CSSSelectorList list = CSSSelectorParser::ParseSelector(
122 range, CSSParserContext::Create(kHTMLStandardMode), nullptr); 120 range, CSSParserContext::Create(kHTMLStandardMode), nullptr);
123 EXPECT_STREQ(test_case[1], list.SelectorsText().Ascii().data()); 121 EXPECT_STREQ(test_case[1], list.SelectorsText().Ascii().data());
124 } 122 }
125 } 123 }
126 124
127 TEST(CSSSelectorParserTest, PseudoElementsInCompoundLists) { 125 TEST(CSSSelectorParserTest, PseudoElementsInCompoundLists) {
128 const char* test_cases[] = {":not(::before)", 126 const char* test_cases[] = {":not(::before)",
129 ":not(::content)", 127 ":not(::content)",
130 ":not(::shadow)",
131 ":host(::before)", 128 ":host(::before)",
132 ":host(::content)", 129 ":host(::content)",
133 ":host(::shadow)",
134 ":host-context(::before)", 130 ":host-context(::before)",
135 ":host-context(::content)", 131 ":host-context(::content)",
136 ":host-context(::shadow)",
137 ":-webkit-any(::after, ::before)", 132 ":-webkit-any(::after, ::before)",
138 ":-webkit-any(::content, span)", 133 ":-webkit-any(::content, span)"};
139 ":-webkit-any(div, ::shadow)"};
140 134
141 for (auto test_case : test_cases) { 135 for (auto test_case : test_cases) {
142 CSSTokenizer tokenizer(test_case); 136 CSSTokenizer tokenizer(test_case);
143 CSSParserTokenRange range = tokenizer.TokenRange(); 137 CSSParserTokenRange range = tokenizer.TokenRange();
144 CSSSelectorList list = CSSSelectorParser::ParseSelector( 138 CSSSelectorList list = CSSSelectorParser::ParseSelector(
145 range, CSSParserContext::Create(kHTMLStandardMode), nullptr); 139 range, CSSParserContext::Create(kHTMLStandardMode), nullptr);
146 EXPECT_FALSE(list.IsValid()); 140 EXPECT_FALSE(list.IsValid());
147 } 141 }
148 } 142 }
149 143
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 for (auto test_case : test_cases) { 188 for (auto test_case : test_cases) {
195 CSSTokenizer tokenizer(test_case); 189 CSSTokenizer tokenizer(test_case);
196 CSSParserTokenRange range = tokenizer.TokenRange(); 190 CSSParserTokenRange range = tokenizer.TokenRange();
197 CSSSelectorList list = CSSSelectorParser::ParseSelector( 191 CSSSelectorList list = CSSSelectorParser::ParseSelector(
198 range, CSSParserContext::Create(kUASheetMode), nullptr); 192 range, CSSParserContext::Create(kUASheetMode), nullptr);
199 EXPECT_TRUE(list.IsValid()); 193 EXPECT_TRUE(list.IsValid());
200 } 194 }
201 } 195 }
202 196
203 TEST(CSSSelectorParserTest, ValidPseudoElementInNonRightmostCompound) { 197 TEST(CSSSelectorParserTest, ValidPseudoElementInNonRightmostCompound) {
204 const char* test_cases[] = {"::content *", "::shadow *", 198 const char* test_cases[] = {"::content *", "::content div::before"};
205 "::content div::before",
206 "::shadow ::first-letter"};
207 199
208 for (auto test_case : test_cases) { 200 for (auto test_case : test_cases) {
209 CSSTokenizer tokenizer(test_case); 201 CSSTokenizer tokenizer(test_case);
210 CSSParserTokenRange range = tokenizer.TokenRange(); 202 CSSParserTokenRange range = tokenizer.TokenRange();
211 CSSSelectorList list = CSSSelectorParser::ParseSelector( 203 CSSSelectorList list = CSSSelectorParser::ParseSelector(
212 range, CSSParserContext::Create(kHTMLStandardMode), nullptr); 204 range, CSSParserContext::Create(kHTMLStandardMode), nullptr);
213 EXPECT_TRUE(list.IsValid()); 205 EXPECT_TRUE(list.IsValid());
214 } 206 }
215 } 207 }
216 208
(...skipping 23 matching lines...) Expand all
240 CSSSelectorList list = 232 CSSSelectorList list =
241 CSSSelectorParser::ParseSelector(range, context, sheet); 233 CSSSelectorParser::ParseSelector(range, context, sheet);
242 EXPECT_FALSE(list.IsValid()); 234 EXPECT_FALSE(list.IsValid());
243 } 235 }
244 } 236 }
245 237
246 TEST(CSSSelectorParserTest, SerializedUniversal) { 238 TEST(CSSSelectorParserTest, SerializedUniversal) {
247 const char* test_cases[][2] = { 239 const char* test_cases[][2] = {
248 {"*::-webkit-volume-slider", "::-webkit-volume-slider"}, 240 {"*::-webkit-volume-slider", "::-webkit-volume-slider"},
249 {"*::cue(i)", "::cue(i)"}, 241 {"*::cue(i)", "::cue(i)"},
250 {"*::shadow", "::shadow"},
251 {"*:host-context(.x)", "*:host-context(.x)"}, 242 {"*:host-context(.x)", "*:host-context(.x)"},
252 {"*:host", "*:host"}, 243 {"*:host", "*:host"},
253 {"|*::-webkit-volume-slider", "|*::-webkit-volume-slider"}, 244 {"|*::-webkit-volume-slider", "|*::-webkit-volume-slider"},
254 {"|*::cue(i)", "|*::cue(i)"}, 245 {"|*::cue(i)", "|*::cue(i)"},
255 {"|*::shadow", "|*::shadow"},
256 {"*|*::-webkit-volume-slider", "::-webkit-volume-slider"}, 246 {"*|*::-webkit-volume-slider", "::-webkit-volume-slider"},
257 {"*|*::cue(i)", "::cue(i)"}, 247 {"*|*::cue(i)", "::cue(i)"},
258 {"*|*::shadow", "::shadow"},
259 {"ns|*::-webkit-volume-slider", "ns|*::-webkit-volume-slider"}, 248 {"ns|*::-webkit-volume-slider", "ns|*::-webkit-volume-slider"},
260 {"ns|*::cue(i)", "ns|*::cue(i)"}, 249 {"ns|*::cue(i)", "ns|*::cue(i)"}};
261 {"ns|*::shadow", "ns|*::shadow"}};
262 250
263 CSSParserContext* context = CSSParserContext::Create(kHTMLStandardMode); 251 CSSParserContext* context = CSSParserContext::Create(kHTMLStandardMode);
264 StyleSheetContents* sheet = StyleSheetContents::Create(context); 252 StyleSheetContents* sheet = StyleSheetContents::Create(context);
265 sheet->ParserAddNamespace("ns", "http://ns.org"); 253 sheet->ParserAddNamespace("ns", "http://ns.org");
266 254
267 for (auto test_case : test_cases) { 255 for (auto test_case : test_cases) {
268 SCOPED_TRACE(test_case[0]); 256 SCOPED_TRACE(test_case[0]);
269 CSSTokenizer tokenizer(test_case[0]); 257 CSSTokenizer tokenizer(test_case[0]);
270 CSSParserTokenRange range = tokenizer.TokenRange(); 258 CSSParserTokenRange range = tokenizer.TokenRange();
271 CSSSelectorList list = 259 CSSSelectorList list =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 SCOPED_TRACE(test_case); 329 SCOPED_TRACE(test_case);
342 CSSTokenizer tokenizer(test_case); 330 CSSTokenizer tokenizer(test_case);
343 CSSParserTokenRange range = tokenizer.TokenRange(); 331 CSSParserTokenRange range = tokenizer.TokenRange();
344 CSSSelectorList list = 332 CSSSelectorList list =
345 CSSSelectorParser::ParseSelector(range, context, sheet); 333 CSSSelectorParser::ParseSelector(range, context, sheet);
346 EXPECT_FALSE(list.IsValid()); 334 EXPECT_FALSE(list.IsValid());
347 } 335 }
348 } 336 }
349 337
350 } // namespace blink 338 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698