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

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

Issue 2456773002: Clear the custom element's reaction queue if upgrade fails. (Closed)
Patch Set: Created 4 years, 2 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
Index: third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueueTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueueTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueueTest.cpp
index 9c3a0b72bfe131f0bb52b0d1c2d15b67321269f0..98f5a49ac9440838e1837d11ad1aac0f7a3b2f5d 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueueTest.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueueTest.cpp
@@ -7,6 +7,7 @@
#include "core/dom/custom/CustomElementReaction.h"
#include "core/dom/custom/CustomElementReactionTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/Functional.h"
#include <initializer_list>
#include <vector>
@@ -53,4 +54,19 @@ TEST(CustomElementReactionQueueTest, invokeReactions_recursive) {
<< "the reactions should have been invoked";
}
+TEST(CustomElementReactionQueueTest, clear_duringInvoke) {
+ std::vector<char> log;
+ CustomElementReactionQueue* queue = new CustomElementReactionQueue();
+
+ queue->add(new TestReaction({new Log('a', log)}));
+ queue->add(new TestReaction({new Call(WTF::bind(
+ [](CustomElementReactionQueue* queue, Element*) { queue->clear(); },
+ wrapPersistent(queue)))}));
+ queue->add(new TestReaction({new Log('b', log)}));
+
+ queue->invokeReactions(nullptr);
+ EXPECT_EQ(log, std::vector<char>({'a'}))
+ << "only 'a' should be logged; the second log should have been cleared";
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698