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

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

Issue 2052283002: Allow reactions to enqueue other reactions for the same element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor typo Created 4 years, 6 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/CustomElementReactionStack.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/CustomElementReactionStackTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionStackTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionStackTest.cpp
index 8290dbc9f07624b8917514cddc3787a229eb24ca..7edc0c93199395633a97ce696776aa603961b70c 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionStackTest.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionStackTest.cpp
@@ -111,4 +111,48 @@ TEST(CustomElementReactionStackTest, oneReactionQueuePerElement)
EXPECT_EQ(log, std::vector<char>({'z'})) << "reactions should be run once";
}
+class EnqueueToStack : public Command {
+ WTF_MAKE_NONCOPYABLE(EnqueueToStack);
+public:
+ EnqueueToStack(CustomElementReactionStack* stack, Element* element, CustomElementReaction* reaction)
+ : m_stack(stack)
+ , m_element(element)
+ , m_reaction(reaction)
+ {
+ }
+ ~EnqueueToStack() override = default;
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ Command::trace(visitor);
+ visitor->trace(m_stack);
+ visitor->trace(m_element);
+ visitor->trace(m_reaction);
+ }
+ void run(Element*) override
+ {
+ m_stack->enqueue(m_element, m_reaction);
+ }
+private:
+ Member<CustomElementReactionStack> m_stack;
+ Member<Element> m_element;
+ Member<CustomElementReaction> m_reaction;
+};
+
+TEST(CustomElementReactionStackTest, enqueueFromReaction)
+{
+ std::vector<char> log;
+
+ Element* element = CreateElement("a");
+
+ CustomElementReactionStack* stack = new CustomElementReactionStack();
+ stack->push();
+ stack->enqueue(element, new TestReaction({
+ new EnqueueToStack(stack, element,
+ new TestReaction({ new Log('a', log) }) )
+ }));
+ stack->popInvokingReactions();
+
+ EXPECT_EQ(log, std::vector<char>({ 'a' })) << "enqueued reaction from another reaction should run in the same invoke";
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementReactionStack.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698