OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "core/editing/Position.h" | 6 #include "core/editing/Position.h" |
7 | 7 |
8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint) | 91 TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint) |
92 { | 92 { |
93 const char* bodyContent = "<p id='p'><content></content></p>"; | 93 const char* bodyContent = "<p id='p'><content></content></p>"; |
94 setBodyContent(bodyContent); | 94 setBodyContent(bodyContent); |
95 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); | 95 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); |
96 | 96 |
97 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree(
Position(anchor.get(), 0))); | 97 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree(
Position(anchor.get(), 0))); |
98 EXPECT_EQ(PositionInComposedTree(anchor, PositionAnchorType::AfterChildren),
toPositionInComposedTree(Position(anchor.get(), 1))); | 98 EXPECT_EQ(PositionInComposedTree(anchor, PositionAnchorType::AfterChildren),
toPositionInComposedTree(Position(anchor.get(), 1))); |
99 } | 99 } |
100 | 100 |
| 101 // This test comes from "editing/style/block-style-progress-crash.html". |
| 102 TEST_F(PositionTest, ToPositionInComposedTreeWithNotDistributed) |
| 103 { |
| 104 setBodyContent("<progress id=sample>foo</progress>"); |
| 105 Element* sample = document().getElementById("sample"); |
| 106 |
| 107 EXPECT_EQ(PositionInComposedTree(sample, PositionAnchorType::AfterChildren),
toPositionInComposedTree(Position(sample, 0))); |
| 108 } |
| 109 |
101 TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRoot) | 110 TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRoot) |
102 { | 111 { |
103 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 112 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
104 const char* shadowContent = "<a><content select=#one></content></a>"; | 113 const char* shadowContent = "<a><content select=#one></content></a>"; |
105 setBodyContent(bodyContent); | 114 setBodyContent(bodyContent); |
106 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 115 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
107 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 116 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
108 | 117 |
109 EXPECT_EQ(PositionInComposedTree(host.get(), 0), toPositionInComposedTree(Po
sition(shadowRoot.get(), 0))); | 118 EXPECT_EQ(PositionInComposedTree(host.get(), 0), toPositionInComposedTree(Po
sition(shadowRoot.get(), 0))); |
110 EXPECT_EQ(PositionInComposedTree(host.get(), PositionAnchorType::AfterChildr
en), toPositionInComposedTree(Position(shadowRoot.get(), 1))); | 119 EXPECT_EQ(PositionInComposedTree(host.get(), PositionAnchorType::AfterChildr
en), toPositionInComposedTree(Position(shadowRoot.get(), 1))); |
(...skipping 16 matching lines...) Expand all Loading... |
127 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 136 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
128 const char* shadowContent = ""; | 137 const char* shadowContent = ""; |
129 setBodyContent(bodyContent); | 138 setBodyContent(bodyContent); |
130 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 139 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); |
131 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 140 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
132 | 141 |
133 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); | 142 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); |
134 } | 143 } |
135 | 144 |
136 } // namespace blink | 145 } // namespace blink |
OLD | NEW |