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

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

Issue 1600793002: Pseudo elements may only appear in rightmost compound. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Start counting from 0. Created 4 years, 11 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 | « third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp ('k') | 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/parser/CSSTokenizer.h" 8 #include "core/css/parser/CSSTokenizer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 CSSTokenizer::Scope scope(testCase); 196 CSSTokenizer::Scope scope(testCase);
197 CSSParserTokenRange range = scope.tokenRange(); 197 CSSParserTokenRange range = scope.tokenRange();
198 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParser Context(HTMLStandardMode, nullptr), nullptr); 198 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParser Context(HTMLStandardMode, nullptr), nullptr);
199 EXPECT_FALSE(list.isValid()); 199 EXPECT_FALSE(list.isValid());
200 } 200 }
201 } 201 }
202 202
203 TEST(CSSSelectorParserTest, WorkaroundForInvalidCustomPseudoInUAStyle) 203 TEST(CSSSelectorParserTest, WorkaroundForInvalidCustomPseudoInUAStyle)
204 { 204 {
205 // See crbug.com/578131 205 // See crbug.com/578131
206 CSSTokenizer::Scope scope("video::-webkit-media-text-track-region-container. scrolling"); 206 const char* testCases[] = {
207 CSSParserTokenRange range = scope.tokenRange(); 207 "video::-webkit-media-text-track-region-container.scrolling",
208 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParserCont ext(UASheetMode, nullptr), nullptr); 208 "input[type=\"range\" i]::-webkit-media-slider-container > div"
209 EXPECT_TRUE(list.isValid()); 209 };
210
211 for (auto testCase : testCases) {
212 CSSTokenizer::Scope scope(testCase);
213 CSSParserTokenRange range = scope.tokenRange();
214 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParser Context(UASheetMode, nullptr), nullptr);
215 EXPECT_TRUE(list.isValid());
216 }
217 }
218
219 TEST(CSSSelectorParserTest, ValidPseudoElementInNonRightmostCompound)
220 {
221 const char* testCases[] = {
222 "::content *",
223 "::shadow *",
224 "::content div::before",
225 "::shadow ::first-letter"
226 };
227
228 for (auto testCase : testCases) {
229 CSSTokenizer::Scope scope(testCase);
230 CSSParserTokenRange range = scope.tokenRange();
231 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParser Context(HTMLStandardMode, nullptr), nullptr);
232 EXPECT_TRUE(list.isValid());
233 }
234 }
235
236 TEST(CSSSelectorParserTest, InvalidPseudoElementInNonRightmostCompound)
237 {
238 const char* testCases[] = {
239 "::-webkit-volume-slider *",
240 "::before *",
241 "::-webkit-scrollbar *",
242 "::cue *",
243 "::selection *"
244 };
245
246 for (auto testCase : testCases) {
247 CSSTokenizer::Scope scope(testCase);
248 CSSParserTokenRange range = scope.tokenRange();
249 CSSSelectorList list = CSSSelectorParser::parseSelector(range, CSSParser Context(HTMLStandardMode, nullptr), nullptr);
250 EXPECT_FALSE(list.isValid());
251 }
210 } 252 }
211 253
212 } // namespace 254 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698