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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementReactionTestHelpers.h

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
« 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/CustomElementReactionTestHelpers.h
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionTestHelpers.h b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionTestHelpers.h
index 1a5d0246b1e3aa833c7118604617c2ab5a27ac0f..e2cab721abbde3f44cd5e9e21bd6a1e46990c09d 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionTestHelpers.h
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionTestHelpers.h
@@ -5,9 +5,13 @@
#include "core/dom/custom/CustomElementReaction.h"
#include "core/dom/custom/CustomElementReactionQueue.h"
+#include "core/dom/custom/CustomElementReactionStack.h"
#include "platform/heap/Handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/Functional.h"
#include "wtf/Noncopyable.h"
#include <initializer_list>
+#include <memory>
#include <vector>
namespace blink {
@@ -24,6 +28,31 @@ class Command : public GarbageCollectedFinalized<Command> {
virtual void run(Element*) = 0;
};
+class Call : public Command {
+ WTF_MAKE_NONCOPYABLE(Call);
+
+ public:
+ using Callback = WTF::Function<void(Element*)>;
+ Call(std::unique_ptr<Callback> callback) : m_callback(std::move(callback)) {}
+ ~Call() override = default;
+ void run(Element* element) override { m_callback->operator()(element); }
+
+ private:
+ std::unique_ptr<Callback> m_callback;
+};
+
+class Unreached : public Command {
+ WTF_MAKE_NONCOPYABLE(Unreached);
+
+ public:
+ Unreached(const char* message) : m_message(message) {}
+ ~Unreached() override = default;
+ void run(Element*) override { EXPECT_TRUE(false) << m_message; }
+
+ private:
+ const char* m_message;
+};
+
class Log : public Command {
WTF_MAKE_NONCOPYABLE(Log);
@@ -97,4 +126,26 @@ class TestReaction : public CustomElementReaction {
HeapVector<Member<Command>> m_commands;
};
+class ResetCustomElementReactionStackForTest final {
+ STACK_ALLOCATED();
+ WTF_MAKE_NONCOPYABLE(ResetCustomElementReactionStackForTest);
+
+ public:
+ ResetCustomElementReactionStackForTest()
+ : m_stack(new CustomElementReactionStack),
+ m_oldStack(
+ CustomElementReactionStackTestSupport::setCurrentForTest(m_stack)) {
+ }
+
+ ~ResetCustomElementReactionStackForTest() {
+ CustomElementReactionStackTestSupport::setCurrentForTest(m_oldStack);
+ }
+
+ CustomElementReactionStack& stack() { return *m_stack; }
+
+ private:
+ Member<CustomElementReactionStack> m_stack;
+ Member<CustomElementReactionStack> m_oldStack;
+};
+
} // 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