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

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

Issue 2920583003: Stop crashing when VisibleSelections in DOM and Flat trees are inconsistent (Closed)
Patch Set: Mon Jun 5 11:40:52 PDT 2017 Created 3 years, 6 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 | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | 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 83c0b38c4d19d31dddb2feb61cd50f4fa7887347..6d5a5dac219497a5f3955e60337335a0314e012c 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -963,4 +963,23 @@ TEST_F(FrameSelectionTest, RangeOutsideFocus) {
EXPECT_FALSE(Selection().IsHidden()); // Range still visible.
}
+// crbug.com/725457
+TEST_F(FrameSelectionTest, InconsistentVisibleSelectionNoCrash) {
+ SetBodyContent("foo<div id=host><span id=anchor>bar</span></div>baz");
+ SetShadowContent("shadow", "host");
+
+ Element* anchor = GetDocument().getElementById("anchor");
+
+ // |start| and |end| are valid Positions in DOM tree, but do not participate
+ // in flat tree. They should be canonicalized to null VisiblePositions, but
+ // are currently not. See crbug.com/729636 for details.
+ const Position& start = Position::BeforeNode(anchor);
+ const Position& end = Position::AfterNode(anchor);
+ Selection().SetSelection(
+ SelectionInDOMTree::Builder().Collapse(start).Extend(end).Build());
+
+ // Shouldn't crash inside.
+ EXPECT_FALSE(Selection().SelectionHasFocus());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698