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

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

Issue 2299033005: Pass the old and new owner documents to the adoptedCallback. (Closed)
Patch Set: WTF_ARRAY_LENGTH Created 4 years, 3 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 | « third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp ('k') | 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/CustomElementRegistryTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp
index af35a822dfa6b94b7323942bd6c19e7b1de37b69..f32a1a61ebb12f071af843436c64ed877ddfdc11 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp
@@ -246,6 +246,7 @@ public:
{
TestCustomElementDefinition::trace(visitor);
visitor->trace(m_element);
+ visitor->trace(m_adopted);
}
// TODO(dominicc): Make this class collect a vector of what's
@@ -267,6 +268,22 @@ public:
};
Vector<AttributeChanged> m_attributeChanged;
+ struct Adopted : public GarbageCollected<Adopted> {
+ Adopted(Document* oldOwner, Document* newOwner)
+ : m_oldOwner(oldOwner)
+ , m_newOwner(newOwner) { }
+
+ Member<Document> m_oldOwner;
+ Member<Document> m_newOwner;
+
+ DEFINE_INLINE_TRACE()
+ {
+ visitor->trace(m_oldOwner);
+ visitor->trace(m_newOwner);
+ }
+ };
+ HeapVector<Member<Adopted>> m_adopted;
+
void clear()
{
m_logs.clear();
@@ -296,10 +313,12 @@ public:
EXPECT_EQ(element, m_element);
}
- void runAdoptedCallback(Element* element) override
+ void runAdoptedCallback(
+ Element* element, Document* oldOwner, Document* newOwner) override
{
m_logs.append(AdoptedCallback);
EXPECT_EQ(element, m_element);
+ m_adopted.append(new Adopted(oldOwner, newOwner));
}
void runAttributeChangedCallback(Element* element, const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) override
@@ -474,6 +493,11 @@ TEST_F(CustomElementRegistryTest, adoptedCallback)
EXPECT_EQ(LogUpgradeDefinition::AdoptedCallback, definition->m_logs[1])
<< "adoptNode() should invoke adoptedCallback";
+ EXPECT_EQ(&document(), definition->m_adopted[0]->m_oldOwner.get())
+ << "adoptedCallback should have been passed the old owner document";
+ EXPECT_EQ(otherDocument, definition->m_adopted[0]->m_newOwner.get())
+ << "adoptedCallback should have been passed the new owner document";
+
EXPECT_EQ(2u, definition->m_logs.size())
<< "adoptNode() should not invoke other callbacks";
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698