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

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

Issue 2725603002: createFragmentFromMarkupWithContext() should use EphemeralRange. (Closed)
Patch Set: Y Created 3 years, 10 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..0b72b8e79e602eb35a17a45261b01fd9d460da95 100644
--- a/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp
+++ b/third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp
@@ -148,4 +148,45 @@ 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);
+
+ Range* range = getBodyRange();
Xiaocheng 2017/03/05 06:31:19 There's no need to create an EphemeralRange from R
tanvir 2017/03/06 07:05:11 Done.
+ range->setStart(document().getElementById("one"), 0,
+ IGNORE_EXCEPTION_FOR_TESTING);
+ range->setEnd(document().getElementById("two"), 0,
+ IGNORE_EXCEPTION_FOR_TESTING);
+
+ const EphemeralRange ephemeralRange(range->startPosition(),
+ range->endPosition());
+ const Node* commonAncestor = document().getElementById("host");
+ EXPECT_EQ(commonAncestor, ephemeralRange.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);
+ setShadowContent(shadowContent, "host");
Xiaocheng 2017/03/05 06:31:19 Do instead: ... ShadowRoot* shadowRoot = setShado
tanvir 2017/03/06 07:05:11 Done the changes!! Thanks for the explanation.
+
+ Range* range = getBodyRange();
+ range->setStart(document().getElementById("one"), 0,
+ IGNORE_EXCEPTION_FOR_TESTING);
+ range->setEnd(document().getElementById("five"), 0,
+ IGNORE_EXCEPTION_FOR_TESTING);
+
+ const EphemeralRangeInFlatTree ephemeralRange(
+ toPositionInFlatTree(range->startPosition()),
+ toPositionInFlatTree(range->endPosition()));
+ EXPECT_EQ(document().documentElement(),
+ ephemeralRange.commonAncestorContainer());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698