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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementTestHelpers.h

Issue 2442223003: Make createElement tag name case handling consistent for custom elements (Closed)
Patch Set: 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
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 #ifndef CustomElementTestHelpers_h 5 #ifndef CustomElementTestHelpers_h
6 #define CustomElementTestHelpers_h 6 #define CustomElementTestHelpers_h
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.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/ElementDefinitionOptions.h"
11 #include "core/dom/QualifiedName.h" 12 #include "core/dom/QualifiedName.h"
13 #include "core/dom/custom/CEReactionsScope.h"
14 #include "core/dom/custom/CustomElementDefinition.h"
15 #include "core/dom/custom/CustomElementDefinitionBuilder.h"
12 #include "core/html/HTMLDocument.h" 16 #include "core/html/HTMLDocument.h"
13 #include "platform/heap/Handle.h" 17 #include "platform/heap/Handle.h"
14 #include "wtf/text/AtomicString.h" 18 #include "wtf/text/AtomicString.h"
15 19
16 #include <utility> 20 #include <utility>
17 #include <vector> 21 #include <vector>
18 22
19 namespace blink { 23 namespace blink {
20 24
25 class CustomElementDescriptor;
26
27 class TestCustomElementDefinitionBuilder
28 : public CustomElementDefinitionBuilder {
29 STACK_ALLOCATED();
30 WTF_MAKE_NONCOPYABLE(TestCustomElementDefinitionBuilder);
31
32 public:
33 TestCustomElementDefinitionBuilder() {}
34 bool checkConstructorIntrinsics() override { return true; }
35 bool checkConstructorNotRegistered() override { return true; }
36 bool checkPrototype() override { return true; }
37 bool rememberOriginalProperties() override { return true; }
38 CustomElementDefinition* build(const CustomElementDescriptor&) override;
39 };
40
41 class TestCustomElementDefinition : public CustomElementDefinition {
42 WTF_MAKE_NONCOPYABLE(TestCustomElementDefinition);
43
44 public:
45 TestCustomElementDefinition(const CustomElementDescriptor& descriptor)
46 : CustomElementDefinition(descriptor) {}
47
48 TestCustomElementDefinition(const CustomElementDescriptor& descriptor,
49 const HashSet<AtomicString>& observedAttributes)
50 : CustomElementDefinition(descriptor, observedAttributes) {}
51
52 ~TestCustomElementDefinition() override = default;
53
54 ScriptValue getConstructorForScript() override { return ScriptValue(); }
55
56 bool runConstructor(Element* element) override {
57 if (constructionStack().isEmpty() || constructionStack().last() != element)
58 return false;
59 constructionStack().last().clear();
60 return true;
61 }
62
63 HTMLElement* createElementSync(Document& document,
64 const QualifiedName&) override {
65 return createElementForConstructor(document);
66 }
67
68 HTMLElement* createElementSync(Document& document,
69 const QualifiedName&,
70 ExceptionState&) override {
71 return createElementForConstructor(document);
72 }
73
74 bool hasConnectedCallback() const override { return false; }
75 bool hasDisconnectedCallback() const override { return false; }
76 bool hasAdoptedCallback() const override { return false; }
77
78 void runConnectedCallback(Element*) override {
79 NOTREACHED() << "definition does not have connected callback";
80 }
81
82 void runDisconnectedCallback(Element*) override {
83 NOTREACHED() << "definition does not have disconnected callback";
84 }
85
86 void runAdoptedCallback(Element*,
87 Document* oldOwner,
88 Document* newOwner) override {
89 NOTREACHED() << "definition does not have adopted callback";
90 }
91
92 void runAttributeChangedCallback(Element*,
93 const QualifiedName&,
94 const AtomicString& oldValue,
95 const AtomicString& newValue) override {
96 NOTREACHED() << "definition does not have attribute changed callback";
97 }
98 };
99
21 class CreateElement { 100 class CreateElement {
22 STACK_ALLOCATED() 101 STACK_ALLOCATED()
23 public: 102 public:
24 CreateElement(const AtomicString& localName) 103 CreateElement(const AtomicString& localName)
25 : m_namespaceURI(HTMLNames::xhtmlNamespaceURI), m_localName(localName) {} 104 : m_namespaceURI(HTMLNames::xhtmlNamespaceURI), m_localName(localName) {}
26 105
27 CreateElement& inDocument(Document* document) { 106 CreateElement& inDocument(Document* document) {
28 m_document = document; 107 m_document = document;
29 return *this; 108 return *this;
30 } 109 }
(...skipping 28 matching lines...) Expand all
59 private: 138 private:
60 Member<Document> m_document; 139 Member<Document> m_document;
61 AtomicString m_namespaceURI; 140 AtomicString m_namespaceURI;
62 AtomicString m_localName; 141 AtomicString m_localName;
63 std::vector<std::pair<QualifiedName, AtomicString>> m_attributes; 142 std::vector<std::pair<QualifiedName, AtomicString>> m_attributes;
64 }; 143 };
65 144
66 } // namespace blink 145 } // namespace blink
67 146
68 #endif // CustomElementTestHelpers_h 147 #endif // CustomElementTestHelpers_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698