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

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

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 #include "core/dom/custom/CustomElement.h" 5 #include "core/dom/custom/CustomElement.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/SVGNames.h" 8 #include "core/SVGNames.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/custom/CustomElementDefinition.h"
11 #include "core/dom/custom/CustomElementRegistry.h"
12 #include "core/dom/custom/CustomElementTestHelpers.h"
10 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
11 #include "core/testing/DummyPageHolder.h" 14 #include "core/testing/DummyPageHolder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 #include <ios> 16 #include <ios>
14 #include <memory> 17 #include <memory>
15 18
16 namespace blink { 19 namespace blink {
17 20
18 static void testIsPotentialCustomElementName(const AtomicString& str, 21 static void testIsPotentialCustomElementName(const AtomicString& str,
19 bool expected) { 22 bool expected) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 element = document.createElementNS(SVGNames::svgNamespaceURI, data.name, 198 element = document.createElementNS(SVGNames::svgNamespaceURI, data.name,
196 ASSERT_NO_EXCEPTION); 199 ASSERT_NO_EXCEPTION);
197 EXPECT_EQ(CustomElementState::Uncustomized, 200 EXPECT_EQ(CustomElementState::Uncustomized,
198 element->getCustomElementState()) 201 element->getCustomElementState())
199 << data.name; 202 << data.name;
200 EXPECT_EQ(data.v0state, element->getV0CustomElementState()) << data.name; 203 EXPECT_EQ(data.v0state, element->getV0CustomElementState()) << data.name;
201 } 204 }
202 } 205 }
203 206
207 TEST(CustomElementTest,
208 CreateElement_TagNameCaseHandlingCreatingCustomElement) {
209 // register a definition
210 std::unique_ptr<DummyPageHolder> holder(DummyPageHolder::create());
211 CustomElementRegistry* registry =
212 holder->frame().localDOMWindow()->customElements();
213 NonThrowableExceptionState shouldNotThrow;
214 {
215 CEReactionsScope reactions;
216 TestCustomElementDefinitionBuilder builder;
217 registry->define("a-a", builder, ElementDefinitionOptions(),
218 shouldNotThrow);
219 }
220 CustomElementDefinition* definition =
221 registry->definitionFor(CustomElementDescriptor("a-a", "a-a"));
222 EXPECT_NE(nullptr, definition) << "a-a should be registered";
223
224 // create an element with an uppercase tag name
225 Document& document = holder->document();
226 EXPECT_TRUE(document.isHTMLDocument())
227 << "this test requires a HTML document";
228 Element* element = document.createElement("A-A", shouldNotThrow);
229 EXPECT_EQ(definition, element->customElementDefinition());
230 }
231
204 } // namespace blink 232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698