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

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

Issue 2249563002: CsutomElements: adoptedCallback unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: misspell correction Created 4 years, 4 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
« no previous file with comments | « no previous file | 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/CustomElementsRegistry.h" 5 #include "core/dom/custom/CustomElementsRegistry.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.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"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 CEReactionsScope reactions; 435 CEReactionsScope reactions;
436 element->remove(shouldNotThrow); 436 element->remove(shouldNotThrow);
437 } 437 }
438 EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0]) 438 EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0])
439 << "remove() should invoke disconnectedCallback"; 439 << "remove() should invoke disconnectedCallback";
440 440
441 EXPECT_EQ(1u, definition->m_logs.size()) 441 EXPECT_EQ(1u, definition->m_logs.size())
442 << "remove() should not invoke other callbacks"; 442 << "remove() should not invoke other callbacks";
443 } 443 }
444 444
445 TEST_F(CustomElementsRegistryTest, adoptedCallback)
446 {
447 ScriptForbiddenScope doNotRelyOnScript;
448
449 Element* element = CreateElement("a-a").inDocument(&document());
450 document().documentElement()->appendChild(element);
451
452 LogUpgradeBuilder builder;
453 NonThrowableExceptionState shouldNotThrow;
454 {
455 CEReactionsScope reactions;
456 registry().define(
457 "a-a",
458 builder,
459 ElementRegistrationOptions(),
460 shouldNotThrow);
461 }
462 LogUpgradeDefinition* definition =
463 static_cast<LogUpgradeDefinition*>(registry().definitionForName("a-a"));
464
465 definition->clear();
466 Document* otherDocument = HTMLDocument::create();
467 {
468 CEReactionsScope reactions;
469 otherDocument->adoptNode(element, ASSERT_NO_EXCEPTION);
470 }
471 EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0])
472 << "adoptNode() should invoke disconnectedCallback";
473
474 EXPECT_EQ(LogUpgradeDefinition::AdoptedCallback, definition->m_logs[1])
475 << "adoptNode() should invoke adoptedCallback";
476
477 EXPECT_EQ(2u, definition->m_logs.size())
478 << "adoptNode() should not invoke other callbacks";
479 }
480
445 // TODO(dominicc): Add tests which adjust the "is" attribute when type 481 // TODO(dominicc): Add tests which adjust the "is" attribute when type
446 // extensions are implemented. 482 // extensions are implemented.
447 483
448 } // namespace blink 484 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698