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

Side by Side Diff: third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp

Issue 2505543004: Let querySelector(All) match (nth-)last with unclosed parent. (Closed)
Patch Set: Added expectation file Created 4 years, 1 month 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/SelectorChecker.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 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/HTMLDocument.h"
9 #include "core/html/HTMLHtmlElement.h" 10 #include "core/html/HTMLHtmlElement.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include <memory> 12 #include <memory>
12 13
13 namespace blink { 14 namespace blink {
14 15
15 TEST(SelectorQueryTest, NotMatchingPseudoElement) { 16 TEST(SelectorQueryTest, NotMatchingPseudoElement) {
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( 20 document->documentElement()->setInnerHTML(
20 "<body><style>span::before { content: 'X' }</style><span></span></body>", 21 "<body><style>span::before { content: 'X' }</style><span></span></body>",
21 ASSERT_NO_EXCEPTION); 22 ASSERT_NO_EXCEPTION);
22 23
23 CSSSelectorList selectorList = CSSParser::parseSelector( 24 CSSSelectorList selectorList = CSSParser::parseSelector(
24 CSSParserContext(*document, nullptr), nullptr, "span::before"); 25 CSSParserContext(*document, nullptr), nullptr, "span::before");
25 std::unique_ptr<SelectorQuery> query = 26 std::unique_ptr<SelectorQuery> query =
26 SelectorQuery::adopt(std::move(selectorList)); 27 SelectorQuery::adopt(std::move(selectorList));
27 Element* elm = query->queryFirst(*document); 28 Element* elm = query->queryFirst(*document);
28 EXPECT_EQ(nullptr, elm); 29 EXPECT_EQ(nullptr, elm);
29 30
30 selectorList = CSSParser::parseSelector(CSSParserContext(*document, nullptr), 31 selectorList = CSSParser::parseSelector(CSSParserContext(*document, nullptr),
31 nullptr, "span"); 32 nullptr, "span");
32 query = SelectorQuery::adopt(std::move(selectorList)); 33 query = SelectorQuery::adopt(std::move(selectorList));
33 elm = query->queryFirst(*document); 34 elm = query->queryFirst(*document);
34 EXPECT_NE(nullptr, elm); 35 EXPECT_NE(nullptr, elm);
35 } 36 }
36 37
38 TEST(SelectorQueryTest, LastOfTypeNotFinishedParsing) {
39 Document* document = HTMLDocument::create();
40 HTMLHtmlElement* html = HTMLHtmlElement::create(*document);
41 document->appendChild(html);
42 document->documentElement()->setInnerHTML(
43 "<body><p></p><p id=last></p></body>", ASSERT_NO_EXCEPTION);
44
45 document->body()->beginParsingChildren();
46
47 CSSSelectorList selectorList = CSSParser::parseSelector(
48 CSSParserContext(*document, nullptr), nullptr, "p:last-of-type");
49 std::unique_ptr<SelectorQuery> query =
50 SelectorQuery::adopt(std::move(selectorList));
51 Element* elm = query->queryFirst(*document);
52 ASSERT_TRUE(elm);
53 EXPECT_EQ("last", elm->idForStyleResolution());
54 }
55
37 } // namespace blink 56 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698