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

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

Issue 2850443002: Stop flat tree selection canonicalization from using invalid positions (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Position.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b5a282ec1d995f8cf6a6ad0f0e39ff318e406bc2..7e08841bacf47f1dfb86226e0cdb1011cd06e081 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -328,4 +328,19 @@ TEST_F(FrameSelectionTest, SetSelectedRangePreservesHandle) {
"selectSetSelectedRange they should be present after it.";
}
+// Regression test for crbug.com/702756
+// Test case excerpted from editing/undo/redo_correct_selection.html
+TEST_F(FrameSelectionTest, SelectInvalidPositionInFlatTreeDoesntCrash) {
+ SetBodyContent("foo<option><select></select></option>");
+ Element* body = GetDocument().body();
+ Element* select = GetDocument().QuerySelector("select");
+ Selection().SetSelection(SelectionInDOMTree::Builder()
+ .Collapse(Position(body, 0))
+ // SELECT@AfterAnchor is invalid in flat tree.
+ .Extend(Position::AfterNode(select))
+ .Build());
+ // The test passes if it doesn't crash inside.
+ Selection().ComputeVisibleSelectionInFlatTree();
yosin_UTC9 2017/04/27 07:02:28 nit: Let's have EXPECT_EQ() to compare expected Vi
Xiaocheng 2017/04/27 07:20:46 The expected selection in flat tree should be '|fo
+}
+
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Position.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698