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

Unified Diff: third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp

Issue 2725603002: createFragmentFromMarkupWithContext() should use EphemeralRange. (Closed)
Patch Set: Addressed Review Comments Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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..4e84da53194d8a4c4acf953f1a7cd751e09e18cd 100644
--- a/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp
+++ b/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp
@@ -148,4 +148,41 @@ 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 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);
+ 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

Powered by Google App Engine
This is Rietveld 408576698