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