OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dom/SelectorQuery.h" | 5 #include "core/dom/SelectorQuery.h" |
6 | 6 |
7 #include "core/css/parser/CSSParser.h" | 7 #include "core/css/parser/CSSParser.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/html/HTMLHtmlElement.h" | 9 #include "core/html/HTMLHtmlElement.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include <memory> |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 TEST(SelectorQueryTest, NotMatchingPseudoElement) | 15 TEST(SelectorQueryTest, NotMatchingPseudoElement) |
15 { | 16 { |
16 Document* document = Document::create(); | 17 Document* document = Document::create(); |
17 HTMLHtmlElement* html = HTMLHtmlElement::create(*document); | 18 HTMLHtmlElement* html = HTMLHtmlElement::create(*document); |
18 document->appendChild(html); | 19 document->appendChild(html); |
19 document->documentElement()->setInnerHTML("<body><style>span::before { conte
nt: 'X' }</style><span></span></body>", ASSERT_NO_EXCEPTION); | 20 document->documentElement()->setInnerHTML("<body><style>span::before { conte
nt: 'X' }</style><span></span></body>", ASSERT_NO_EXCEPTION); |
20 | 21 |
21 CSSSelectorList selectorList = CSSParser::parseSelector(CSSParserContext(*do
cument, nullptr), nullptr, "span::before"); | 22 CSSSelectorList selectorList = CSSParser::parseSelector(CSSParserContext(*do
cument, nullptr), nullptr, "span::before"); |
22 OwnPtr<SelectorQuery> query = SelectorQuery::adopt(std::move(selectorList)); | 23 std::unique_ptr<SelectorQuery> query = SelectorQuery::adopt(std::move(select
orList)); |
23 Element* elm = query->queryFirst(*document); | 24 Element* elm = query->queryFirst(*document); |
24 EXPECT_EQ(nullptr, elm); | 25 EXPECT_EQ(nullptr, elm); |
25 | 26 |
26 selectorList = CSSParser::parseSelector(CSSParserContext(*document, nullptr)
, nullptr, "span"); | 27 selectorList = CSSParser::parseSelector(CSSParserContext(*document, nullptr)
, nullptr, "span"); |
27 query = SelectorQuery::adopt(std::move(selectorList)); | 28 query = SelectorQuery::adopt(std::move(selectorList)); |
28 elm = query->queryFirst(*document); | 29 elm = query->queryFirst(*document); |
29 EXPECT_NE(nullptr, elm); | 30 EXPECT_NE(nullptr, elm); |
30 } | 31 } |
31 | 32 |
32 } // namespace blink | 33 } // namespace blink |
OLD | NEW |