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

Side by Side 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 unified diff | 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 »
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/CustomElementReactionStack.h" 5 #include "core/dom/custom/CustomElementReactionStack.h"
6 6
7 #include "core/dom/custom/CustomElementReaction.h" 7 #include "core/dom/custom/CustomElementReaction.h"
8 #include "core/dom/custom/CustomElementReactionTestHelpers.h" 8 #include "core/dom/custom/CustomElementReactionTestHelpers.h"
9 #include "core/dom/custom/CustomElementTestHelpers.h" 9 #include "core/dom/custom/CustomElementTestHelpers.h"
10 #include "core/html/HTMLDocument.h" 10 #include "core/html/HTMLDocument.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 stack->popInvokingReactions(); 104 stack->popInvokingReactions();
105 105
106 EXPECT_EQ(log, std::vector<char>({'y', 'a', 'b'})) 106 EXPECT_EQ(log, std::vector<char>({'y', 'a', 'b'}))
107 << "reactions should run together in the order elements were queued"; 107 << "reactions should run together in the order elements were queued";
108 108
109 log.clear(); 109 log.clear();
110 stack->popInvokingReactions(); 110 stack->popInvokingReactions();
111 EXPECT_EQ(log, std::vector<char>({'z'})) << "reactions should be run once"; 111 EXPECT_EQ(log, std::vector<char>({'z'})) << "reactions should be run once";
112 } 112 }
113 113
114 class EnqueueToStack : public Command {
115 WTF_MAKE_NONCOPYABLE(EnqueueToStack);
116 public:
117 EnqueueToStack(CustomElementReactionStack* stack, Element* element, CustomEl ementReaction* reaction)
118 : m_stack(stack)
119 , m_element(element)
120 , m_reaction(reaction)
121 {
122 }
123 ~EnqueueToStack() override = default;
124 DEFINE_INLINE_VIRTUAL_TRACE()
125 {
126 Command::trace(visitor);
127 visitor->trace(m_stack);
128 visitor->trace(m_element);
129 visitor->trace(m_reaction);
130 }
131 void run(Element*) override
132 {
133 m_stack->enqueue(m_element, m_reaction);
134 }
135 private:
136 Member<CustomElementReactionStack> m_stack;
137 Member<Element> m_element;
138 Member<CustomElementReaction> m_reaction;
139 };
140
141 TEST(CustomElementReactionStackTest, enqueueFromReaction)
142 {
143 std::vector<char> log;
144
145 Element* element = CreateElement("a");
146
147 CustomElementReactionStack* stack = new CustomElementReactionStack();
148 stack->push();
149 stack->enqueue(element, new TestReaction({
150 new EnqueueToStack(stack, element,
151 new TestReaction({ new Log('a', log) }) )
152 }));
153 stack->popInvokingReactions();
154
155 EXPECT_EQ(log, std::vector<char>({ 'a' })) << "enqueued reaction from anothe r reaction should run in the same invoke";
156 }
157
114 } // namespace blink 158 } // namespace blink
OLDNEW
« 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