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

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

Issue 2446903008: Custom Elements: Lookup custom element definition algorithm (Closed)
Patch Set: lookup custom element definition 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" 10 #include "core/dom/custom/CustomElementDefinition.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXPECT_NE(nullptr, definition) << "a-a should be registered"; 222 EXPECT_NE(nullptr, definition) << "a-a should be registered";
223 223
224 // create an element with an uppercase tag name 224 // create an element with an uppercase tag name
225 Document& document = holder->document(); 225 Document& document = holder->document();
226 EXPECT_TRUE(document.isHTMLDocument()) 226 EXPECT_TRUE(document.isHTMLDocument())
227 << "this test requires a HTML document"; 227 << "this test requires a HTML document";
228 Element* element = document.createElement("A-A", shouldNotThrow); 228 Element* element = document.createElement("A-A", shouldNotThrow);
229 EXPECT_EQ(definition, element->customElementDefinition()); 229 EXPECT_EQ(definition, element->customElementDefinition());
230 } 230 }
231 231
232 TEST(CustomElementTest, CreateElement_LookupCustomElement) {
dominicc (has gone to gerrit) 2016/10/27 04:33:14 Could we put this in CustomElementRegistryTest? de
233 // register a definition
234 std::unique_ptr<DummyPageHolder> holder(DummyPageHolder::create());
235 CustomElementRegistry* registry =
236 holder->frame().localDOMWindow()->customElements();
237 NonThrowableExceptionState shouldNotThrow;
238 {
239 CEReactionsScope reactions;
240 TestCustomElementDefinitionBuilder builder;
241 registry->define("a-a", builder, ElementDefinitionOptions(),
242 shouldNotThrow);
243 ElementDefinitionOptions options;
244 options.setExtends("div");
245 registry->define("b-b", builder, options, shouldNotThrow);
246 }
247 CustomElementDefinition* definition =
248 registry->definitionFor(CustomElementDescriptor("a-a", "a-a"));
249 // lookup defined autonomous custom element
dominicc (has gone to gerrit) 2016/10/27 04:33:14 lookup -> look up
250 EXPECT_NE(nullptr, definition) << "a-a, a-a should be registered";
dominicc (has gone to gerrit) 2016/10/27 04:33:14 It would be more precise to hang onto the definiti
251 EXPECT_EQ(AtomicString("a-a"), definition->descriptor().name());
dominicc (has gone to gerrit) 2016/10/27 04:33:14 Just use EXPECT_EQ(..., definition->descriptor())
252 EXPECT_EQ(AtomicString("a-a"), definition->descriptor().localName());
253 // lookup undefined autonomous custom element
254 definition = registry->definitionFor(CustomElementDescriptor("a-b", "a-b"));
255 EXPECT_EQ(nullptr, definition) << "a-b, a-b should not be registered";
256 // lookup defined customized built-in element
257 // TODO(yurak): uncomment once the define algorithm is committed
dominicc (has gone to gerrit) 2016/10/27 04:33:14 Maybe just omit this instead of adding commented o
258 /*definition = registry->definitionFor(CustomElementDescriptor("b-b", "div"));
259 EXPECT_NE(nullptr, definition) << "b-b, div should be registered";
260 EXPECT_EQ(AtomicString("b-b"), definition->descriptor()->name());
261 EXPECT_EQ(AtomicString("div"), definition->descriptor()->localName());*/
262 // lookup undefined customized built-in element
263 definition = registry->definitionFor(CustomElementDescriptor("a-a", "div"));
264 EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered";
265 }
266
232 } // namespace blink 267 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698