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

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

Issue 2850443002: Stop flat tree selection canonicalization from using invalid positions (Closed)
Patch Set: Add expectation check 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..67b5b56b54dbad9f382ac7be1078763930e9ab19 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -328,4 +328,25 @@ 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");
+ Node* foo = body->firstChild();
+ Selection().SetSelection(SelectionInDOMTree::Builder()
+ .Collapse(Position(body, 0))
+ // SELECT@AfterAnchor is invalid in flat tree.
+ .Extend(Position::AfterNode(select))
+ .Build());
+ // Should not crash inside.
+ const VisibleSelectionInFlatTree& selection =
+ Selection().ComputeVisibleSelectionInFlatTree();
+
+ // This only records the current behavior. It might be changed in the future.
+ EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Base());
+ EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Extent());
+}
+
} // 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