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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDefinitionTest.cpp

Issue 2456773002: Clear the custom element's reaction queue if upgrade fails. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/dom/custom/CustomElementDefinition.h"
6
7 #include "core/dom/Node.h" // CustomElementState
8 #include "core/dom/custom/CEReactionsScope.h"
9 #include "core/dom/custom/CustomElementDescriptor.h"
10 #include "core/dom/custom/CustomElementReactionTestHelpers.h"
11 #include "core/dom/custom/CustomElementTestHelpers.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace blink {
15
16 namespace {
17
18 class ConstructorFails : public TestCustomElementDefinition {
19 WTF_MAKE_NONCOPYABLE(ConstructorFails);
20
21 public:
22 ConstructorFails(const CustomElementDescriptor& descriptor)
23 : TestCustomElementDefinition(descriptor) {}
24 ~ConstructorFails() override = default;
25 bool runConstructor(Element*) override { return false; }
26 };
27
28 } // namespace
29
30 TEST(CustomElementDefinitionTest, upgrade_clearsReactionQueueOnFailure) {
31 Element* element = CreateElement("a-a");
32 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState())
33 << "sanity check: this element should be ready to upgrade";
34 {
35 CEReactionsScope reactions;
36 reactions.enqueueToCurrentQueue(
37 element, new TestReaction({new Unreached(
38 "upgrade failure should clear the reaction queue")}));
39 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a"));
40 definition.upgrade(element);
41 }
42 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState())
43 << "failing to construct should have set the 'failed' element state";
44 }
45
46 TEST(CustomElementDefinitionTest,
47 upgrade_clearsReactionQueueOnFailure_backupStack) {
48 Element* element = CreateElement("a-a");
49 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState())
50 << "sanity check: this element should be ready to upgrade";
51 ResetCustomElementReactionStackForTest resetReactionStack;
52 resetReactionStack.stack().enqueueToBackupQueue(
53 element, new TestReaction({new Unreached(
54 "upgrade failure should clear the reaction queue")}));
55 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a"));
56 definition.upgrade(element);
57 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState())
58 << "failing to construct should have set the 'failed' element state";
59 }
60
61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698