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

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

Issue 2972753002: Make FrameSelection::MoveRangeSelection() not to set live granularity selection (Closed)
Patch Set: 2017-07-05T18:14:38 Created 3 years, 5 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/FrameSelectionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
index 9fc95a618e6d1a2b8541e53edad80acd5c90ba7b..247820ff444abf7f1921f1252e77ec758acd1f9c 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -238,6 +238,27 @@ TEST_F(FrameSelectionTest, MoveRangeSelectionTest) {
EXPECT_EQ_SELECTED_TEXT("Foo Bar");
}
+TEST_F(FrameSelectionTest, MoveRangeSelectionNoLiveness) {
+ SetBodyContent("<span id=sample>xyz</span>");
+ Element* const sample = GetDocument().getElementById("sample");
+ // Select as: <span id=sample>^xyz|</span>
+ Selection().MoveRangeSelection(
+ CreateVisiblePosition(Position(sample->firstChild(), 1)),
+ CreateVisiblePosition(Position(sample->firstChild(), 1)),
+ kWordGranularity);
+ EXPECT_EQ("xyz", Selection().SelectedText());
+ sample->insertBefore(Text::Create(GetDocument(), "abc"),
+ sample->firstChild());
+ GetDocument().UpdateStyleAndLayout();
+ const VisibleSelection& selection =
+ Selection().ComputeVisibleSelectionInDOMTree();
+ // Inserting "abc" before "xyz" should not affect to selection.
+ EXPECT_EQ(Position(sample->lastChild(), 0), selection.Start());
+ EXPECT_EQ(Position(sample->lastChild(), 3), selection.End());
+ EXPECT_EQ("xyz", Selection().SelectedText());
+ EXPECT_EQ("abcxyz", sample->innerText());
+}
+
// For http://crbug.com/695317
TEST_F(FrameSelectionTest, SelectAllWithInputElement) {
SetBodyContent("<input>123");

Powered by Google App Engine
This is Rietveld 408576698