| 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
|
|
|