Index: third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
index c4d76ac5dca6b6645be5214ea354509a89591a3f..c04b267d100c1e865c0b42eff045169b8b4a29ad 100644 |
--- a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp |
@@ -1977,4 +1977,47 @@ TEST_F(VisibleUnitsTest, |
EXPECT_EQ(Position(text, 2), start); |
} |
+TEST_F(VisibleUnitsTest, boundingBoxWithEphemeralRange) { |
+ const char* bodyContent = |
+ "<p id='host'>1" |
+ "<b id='one'>22</b>" |
+ "<b id='two'>333</b>" |
+ "<b id='three'>4444</b>" |
+ "</p>"; |
+ setBodyContent(bodyContent); |
+ |
+ const Position startPosition(document().getElementById("one"), 0); |
+ const Position endPosition(document().getElementById("three"), 0); |
+ Range* range = Range::create(document()); |
+ range->selectNode(document().body()); |
+ range->setStart(document().getElementById("one"), 0, |
+ IGNORE_EXCEPTION_FOR_TESTING); |
+ range->setEnd(document().getElementById("three"), 0, |
+ IGNORE_EXCEPTION_FOR_TESTING); |
+ const EphemeralRange ephemeralRange(startPosition, endPosition); |
+ EXPECT_EQ(range->boundingBox(), boundingBox(ephemeralRange)); |
+} |
+ |
+TEST_F(VisibleUnitsTest, boundingBoxWithEphemeralRangeInFlatTree) { |
+ const char* bodyContent = |
+ "<p id='host'>1" |
+ "<b id='one'>22</b>" |
+ "<b id='two'>333</b>" |
+ "<b id='three'>4444</b>" |
+ "</p>"; |
+ setBodyContent(bodyContent); |
+ |
+ const PositionInFlatTree startPosition(document().getElementById("one"), 0); |
+ const PositionInFlatTree endPosition(document().getElementById("three"), 0); |
+ Range* range = Range::create(document()); |
+ range->selectNode(document().body()); |
+ range->setStart(document().getElementById("one"), 0, |
+ IGNORE_EXCEPTION_FOR_TESTING); |
+ range->setEnd(document().getElementById("three"), 0, |
+ IGNORE_EXCEPTION_FOR_TESTING); |
+ const EphemeralRangeInFlatTree ephemeralRangeInFlatTree(startPosition, |
+ endPosition); |
+ EXPECT_EQ(range->boundingBox(), boundingBox(ephemeralRangeInFlatTree)); |
+} |
+ |
} // namespace blink |