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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistryTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistryTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistryTest.cpp
index 9f8d84ae6cd358110b59ea894de6877c78b896d1..7b844f544e3ba6832579be4ca2446df06bfc0d1f 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistryTest.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistryTest.cpp
@@ -442,6 +442,42 @@ TEST_F(CustomElementsRegistryTest, disconnectedCallback)
<< "remove() should not invoke other callbacks";
}
+TEST_F(CustomElementsRegistryTest, adoptedCallback)
+{
+ ScriptForbiddenScope doNotRelyOnScript;
+
+ Element* element = CreateElement("a-a").inDocument(&document());
+ document().documentElement()->appendChild(element);
+
+ LogUpgradeBuilder builder;
+ NonThrowableExceptionState shouldNotThrow;
+ {
+ CEReactionsScope reactions;
+ registry().define(
+ "a-a",
+ builder,
+ ElementRegistrationOptions(),
+ shouldNotThrow);
+ }
+ LogUpgradeDefinition* definition =
+ static_cast<LogUpgradeDefinition*>(registry().definitionForName("a-a"));
+
+ definition->clear();
+ Document* otherDocument = HTMLDocument::create();
+ {
+ CEReactionsScope reactions;
+ otherDocument->adoptNode(element, ASSERT_NO_EXCEPTION);
+ }
+ EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0])
+ << "adoptNode() should invoke disconnectedCallback";
+
+ EXPECT_EQ(LogUpgradeDefinition::AdoptedCallback, definition->m_logs[1])
+ << "adoptNode() should invoke adoptedCallback";
+
+ EXPECT_EQ(2u, definition->m_logs.size())
+ << "adoptNode() should not invoke other callbacks";
+}
+
// TODO(dominicc): Add tests which adjust the "is" attribute when type
// extensions are implemented.
« 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