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

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

Issue 2446903008: Custom Elements: Lookup custom element definition algorithm (Closed)
Patch Set: Patch 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/dom/custom/CustomElementRegistry.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/custom/CustomElementRegistry.h" 5 #include "core/dom/custom/CustomElementRegistry.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ElementDefinitionOptions.h" 10 #include "core/dom/ElementDefinitionOptions.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 EXPECT_EQ(&document(), definition->m_adopted[0]->m_oldOwner.get()) 408 EXPECT_EQ(&document(), definition->m_adopted[0]->m_oldOwner.get())
409 << "adoptedCallback should have been passed the old owner document"; 409 << "adoptedCallback should have been passed the old owner document";
410 EXPECT_EQ(otherDocument, definition->m_adopted[0]->m_newOwner.get()) 410 EXPECT_EQ(otherDocument, definition->m_adopted[0]->m_newOwner.get())
411 << "adoptedCallback should have been passed the new owner document"; 411 << "adoptedCallback should have been passed the new owner document";
412 412
413 EXPECT_EQ(2u, definition->m_logs.size()) 413 EXPECT_EQ(2u, definition->m_logs.size())
414 << "adoptNode() should not invoke other callbacks"; 414 << "adoptNode() should not invoke other callbacks";
415 } 415 }
416 416
417 TEST_F(CustomElementRegistryTest, lookupCustomElementDefinition) {
418 NonThrowableExceptionState shouldNotThrow;
419 TestCustomElementDefinitionBuilder builder;
420 CustomElementDefinition* definitionA = registry().define(
421 "a-a", builder, ElementDefinitionOptions(), shouldNotThrow);
422 ElementDefinitionOptions options;
423 options.setExtends("div");
424 CustomElementDefinition* definitionB =
425 registry().define("b-b", builder, options, shouldNotThrow);
426 // look up defined autonomous custom element
427 CustomElementDefinition* definition = registry().definitionFor(
428 CustomElementDescriptor(CustomElementDescriptor("a-a", "a-a")));
429 EXPECT_NE(nullptr, definition) << "a-a, a-a should be registered";
430 EXPECT_EQ(definitionA, definition);
431 // look up undefined autonomous custom element
432 definition = registry().definitionFor(CustomElementDescriptor("a-a", "div"));
433 EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered";
434 // look up defined customized built-in element
435 definition = registry().definitionFor(CustomElementDescriptor("b-b", "div"));
436 EXPECT_NE(nullptr, definition) << "b-b, div should be registered";
437 EXPECT_EQ(definitionB, definition);
438 // look up undefined customized built-in element
439 definition = registry().definitionFor(CustomElementDescriptor("a-a", "div"));
440 EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered";
441 }
442
417 // TODO(dominicc): Add tests which adjust the "is" attribute when type 443 // TODO(dominicc): Add tests which adjust the "is" attribute when type
418 // extensions are implemented. 444 // extensions are implemented.
419 445
420 } // namespace blink 446 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698