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

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

Issue 2725603002: createFragmentFromMarkupWithContext() should use EphemeralRange. (Closed)
Patch Set: Y 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..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

Powered by Google App Engine
This is Rietveld 408576698