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

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

Issue 2023093003: Upgrade in-document custom elements when an element is defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ASAN failure in test helper. Created 4 years, 6 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
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/custom/CustomElementUpgradeSorter.h" 5 #include "core/dom/custom/CustomElementUpgradeSorter.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
11 #include "core/dom/shadow/ShadowRoot.h" 11 #include "core/dom/shadow/ShadowRoot.h"
12 #include "core/dom/shadow/ShadowRootInit.h" 12 #include "core/dom/shadow/ShadowRootInit.h"
13 #include "core/html/HTMLDocument.h" 13 #include "core/html/HTMLDocument.h"
14 #include "core/testing/DummyPageHolder.h" 14 #include "core/testing/DummyPageHolder.h"
15 #include "platform/heap/Handle.h" 15 #include "platform/heap/Handle.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "wtf/OwnPtr.h" 17 #include "wtf/OwnPtr.h"
18 #include "wtf/text/AtomicString.h" 18 #include "wtf/text/AtomicString.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 class CustomElementUpgradeSorterTest : public ::testing::Test { 22 class CustomElementUpgradeSorterTest : public ::testing::Test {
23 public: 23 protected:
24 void SetUp() override
25 {
26 m_page = DummyPageHolder::create(IntSize(1, 1));
27 }
28
29 void TearDown() override
30 {
31 m_page = nullptr;
32 }
33
24 Element* createElementWithId(const char* localName, const char* id) 34 Element* createElementWithId(const char* localName, const char* id)
25 { 35 {
26 NonThrowableExceptionState noExceptions; 36 NonThrowableExceptionState noExceptions;
27 Element* element = 37 Element* element =
28 document()->createElement(localName, AtomicString(), noExceptions); 38 document()->createElement(localName, AtomicString(), noExceptions);
29 element->setAttribute(HTMLNames::idAttr, id); 39 element->setAttribute(HTMLNames::idAttr, id);
30 return element; 40 return element;
31 } 41 }
32 42
33 Document* document() { return &m_page->document(); } 43 Document* document() { return &m_page->document(); }
34 44
35 ScriptState* scriptState() 45 ScriptState* scriptState()
36 { 46 {
37 return ScriptState::forMainWorld(&m_page->frame()); 47 return ScriptState::forMainWorld(&m_page->frame());
38 } 48 }
39 49
40 ShadowRoot* attachShadowTo(Element* element) 50 ShadowRoot* attachShadowTo(Element* element)
41 { 51 {
42 NonThrowableExceptionState noExceptions; 52 NonThrowableExceptionState noExceptions;
43 ShadowRootInit shadowRootInit; 53 ShadowRootInit shadowRootInit;
44 return 54 return
45 element->attachShadow(scriptState(), shadowRootInit, noExceptions); 55 element->attachShadow(scriptState(), shadowRootInit, noExceptions);
46 } 56 }
47 57
48 protected:
49 void SetUp() override
50 {
51 m_page = DummyPageHolder::create(IntSize(1, 1));
52 }
53
54 void TearDown() override
55 {
56 m_page = nullptr;
57 }
58
59 private: 58 private:
60 OwnPtr<DummyPageHolder> m_page; 59 OwnPtr<DummyPageHolder> m_page;
61 }; 60 };
62 61
63 TEST_F(CustomElementUpgradeSorterTest, inOtherDocument_notInSet) 62 TEST_F(CustomElementUpgradeSorterTest, inOtherDocument_notInSet)
64 { 63 {
65 NonThrowableExceptionState noExceptions; 64 NonThrowableExceptionState noExceptions;
66 Element* element = 65 Element* element =
67 document()->createElement("a-a", AtomicString(), noExceptions); 66 document()->createElement("a-a", AtomicString(), noExceptions);
68 67
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 218
220 HeapVector<Member<Element>> elements; 219 HeapVector<Member<Element>> elements;
221 sort.sorted(&elements, document()); 220 sort.sorted(&elements, document());
222 EXPECT_EQ(3u, elements.size()); 221 EXPECT_EQ(3u, elements.size());
223 EXPECT_EQ(a, elements[0].get()); 222 EXPECT_EQ(a, elements[0].get());
224 EXPECT_EQ(c, elements[1].get()); 223 EXPECT_EQ(c, elements[1].get());
225 EXPECT_EQ(d, elements[2].get()); 224 EXPECT_EQ(d, elements[2].get());
226 } 225 }
227 226
228 } // namespace blink 227 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698