OLD | NEW |
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/CustomElementDefinition.h" | 5 #include "core/dom/custom/CustomElementDefinition.h" |
6 | 6 |
7 #include "core/dom/Node.h" // CustomElementState | 7 #include "core/dom/Node.h" // CustomElementState |
8 #include "core/dom/custom/CEReactionsScope.h" | 8 #include "core/dom/custom/CEReactionsScope.h" |
9 #include "core/dom/custom/CustomElementDescriptor.h" | 9 #include "core/dom/custom/CustomElementDescriptor.h" |
10 #include "core/dom/custom/CustomElementReactionTestHelpers.h" | 10 #include "core/dom/custom/CustomElementReactionTestHelpers.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 TEST(CustomElementDefinitionTest, upgrade_clearsReactionQueueOnFailure) { | 30 TEST(CustomElementDefinitionTest, upgrade_clearsReactionQueueOnFailure) { |
31 Element* element = CreateElement("a-a"); | 31 Element* element = CreateElement("a-a"); |
32 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState()) | 32 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState()) |
33 << "sanity check: this element should be ready to upgrade"; | 33 << "sanity check: this element should be ready to upgrade"; |
34 { | 34 { |
35 CEReactionsScope reactions; | 35 CEReactionsScope reactions; |
36 reactions.enqueueToCurrentQueue( | 36 reactions.enqueueToCurrentQueue( |
37 element, new TestReaction({new Unreached( | 37 element, |
38 "upgrade failure should clear the reaction queue")})); | 38 new TestReaction({new Unreached( |
| 39 "upgrade failure should clear the reaction queue")})); |
39 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); | 40 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); |
40 definition.upgrade(element); | 41 definition.upgrade(element); |
41 } | 42 } |
42 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState()) | 43 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState()) |
43 << "failing to construct should have set the 'failed' element state"; | 44 << "failing to construct should have set the 'failed' element state"; |
44 } | 45 } |
45 | 46 |
46 TEST(CustomElementDefinitionTest, | 47 TEST(CustomElementDefinitionTest, |
47 upgrade_clearsReactionQueueOnFailure_backupStack) { | 48 upgrade_clearsReactionQueueOnFailure_backupStack) { |
48 Element* element = CreateElement("a-a"); | 49 Element* element = CreateElement("a-a"); |
49 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState()) | 50 EXPECT_EQ(CustomElementState::Undefined, element->getCustomElementState()) |
50 << "sanity check: this element should be ready to upgrade"; | 51 << "sanity check: this element should be ready to upgrade"; |
51 ResetCustomElementReactionStackForTest resetReactionStack; | 52 ResetCustomElementReactionStackForTest resetReactionStack; |
52 resetReactionStack.stack().enqueueToBackupQueue( | 53 resetReactionStack.stack().enqueueToBackupQueue( |
53 element, new TestReaction({new Unreached( | 54 element, |
54 "upgrade failure should clear the reaction queue")})); | 55 new TestReaction( |
| 56 {new Unreached("upgrade failure should clear the reaction queue")})); |
55 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); | 57 ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); |
56 definition.upgrade(element); | 58 definition.upgrade(element); |
57 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState()) | 59 EXPECT_EQ(CustomElementState::Failed, element->getCustomElementState()) |
58 << "failing to construct should have set the 'failed' element state"; | 60 << "failing to construct should have set the 'failed' element state"; |
59 } | 61 } |
60 | 62 |
61 } // namespace blink | 63 } // namespace blink |
OLD | NEW |