Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp b/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp |
| index fe6bc1115e6861bef28187d856c7e06a0aeb23eb..bc394b463124796f597ef47fc89e1d252e8c133c 100644 |
| --- a/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp |
| @@ -148,4 +148,33 @@ TEST_F(EphemeralRangeTest, traversalEmptyRanges) { |
| singlePositionRange.endPosition().nodeAsRangePastLastNode()); |
| } |
| +TEST_F(EphemeralRangeTest, commonAncesstorDOM) { |
| + const char* bodyContent = |
| + "<p id='host'>00<b id='one'>11</b><b id='two'>22</b><b " |
|
yosin_UTC9
2017/03/06 07:35:30
Could you use multiple lines string literal to bet
tanvir
2017/03/06 14:42:01
When i tried to do using staring literal, i was un
yosin_UTC9
2017/03/07 01:55:02
Thanks for trying. It seems "raw string literal" h
|
| + "id='three'>33</b></p>"; |
| + setBodyContent(bodyContent); |
| + |
| + const Position startPosition(document().getElementById("one"), 0); |
| + const Position endPosition(document().getElementById("two"), 0); |
| + const EphemeralRange range(startPosition, endPosition); |
| + EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer()); |
| +} |
| + |
| +TEST_F(EphemeralRangeTest, commonAncesstorFlatTree) { |
| + const char* bodyContent = |
| + "<b id=zero>0</b><p id=host><b id=one>1</b><b id=two>22</b></p><b " |
| + "id=three>333</b>"; |
| + const char* shadowContent = |
| + "<p id=four>4444</p><content select=#two></content><content " |
| + "select=#one></content><p id=five>55555</p>"; |
| + setBodyContent(bodyContent); |
| + |
|
Xiaocheng
2017/03/06 07:33:20
nit: remove this extra blank line.
tanvir
2017/03/06 14:42:01
Done.
|
| + ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| + |
| + const PositionInFlatTree startPosition(document().getElementById("one"), 0); |
| + const PositionInFlatTree endPosition(shadowRoot->getElementById("five"), 0); |
| + const EphemeralRangeInFlatTree range(startPosition, endPosition); |
| + EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer()); |
| +} |
| + |
| } // namespace blink |