OLD | NEW |
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/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(co
ntext); | 264 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(co
ntext); |
265 | 265 |
266 for (auto testCase : testCases) { | 266 for (auto testCase : testCases) { |
267 CSSTokenizer::Scope scope(testCase); | 267 CSSTokenizer::Scope scope(testCase); |
268 CSSParserTokenRange range = scope.tokenRange(); | 268 CSSParserTokenRange range = scope.tokenRange(); |
269 CSSSelectorList list = CSSSelectorParser::parseSelector(range, context,
sheet.get()); | 269 CSSSelectorList list = CSSSelectorParser::parseSelector(range, context,
sheet.get()); |
270 EXPECT_FALSE(list.isValid()); | 270 EXPECT_FALSE(list.isValid()); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
| 274 TEST(CSSSelectorParserTest, SerializedUniversal) |
| 275 { |
| 276 const char* testCases[][2] = { |
| 277 { "*::-webkit-volume-slider", "::-webkit-volume-slider" }, |
| 278 { "*::cue(i)", "::cue(i)" }, |
| 279 { "*::shadow", "::shadow" }, |
| 280 { "*:host-context(.x)", "*:host-context(.x)" }, |
| 281 { "*:host", "*:host" }, |
| 282 { "|*::-webkit-volume-slider", "|*::-webkit-volume-slider" }, |
| 283 { "|*::cue(i)", "|*::cue(i)" }, |
| 284 { "|*::shadow", "|*::shadow" }, |
| 285 { "*|*::-webkit-volume-slider", "::-webkit-volume-slider" }, |
| 286 { "*|*::cue(i)", "::cue(i)" }, |
| 287 { "*|*::shadow", "::shadow" }, |
| 288 { "ns|*::-webkit-volume-slider", "ns|*::-webkit-volume-slider" }, |
| 289 { "ns|*::cue(i)", "ns|*::cue(i)" }, |
| 290 { "ns|*::shadow", "ns|*::shadow" } |
| 291 }; |
| 292 |
| 293 CSSParserContext context(HTMLStandardMode, nullptr); |
| 294 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(co
ntext); |
| 295 sheet->parserAddNamespace("ns", "http://ns.org"); |
| 296 |
| 297 for (auto testCase : testCases) { |
| 298 SCOPED_TRACE(testCase[0]); |
| 299 CSSTokenizer::Scope scope(testCase[0]); |
| 300 CSSParserTokenRange range = scope.tokenRange(); |
| 301 CSSSelectorList list = CSSSelectorParser::parseSelector(range, context,
sheet.get()); |
| 302 EXPECT_TRUE(list.isValid()); |
| 303 EXPECT_STREQ(testCase[1], list.selectorsText().ascii().data()); |
| 304 } |
| 305 } |
| 306 |
274 } // namespace blink | 307 } // namespace blink |
OLD | NEW |