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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 EXPECT_TRUE(Selection().SelectionHasFocus()); 956 EXPECT_TRUE(Selection().SelectionHasFocus());
957 EXPECT_FALSE(Selection().IsHidden()); 957 EXPECT_FALSE(Selection().IsHidden());
958 958
959 Element* const alink = GetDocument().getElementById("alink"); 959 Element* const alink = GetDocument().getElementById("alink");
960 alink->focus(); 960 alink->focus();
961 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); 961 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange());
962 EXPECT_FALSE(Selection().SelectionHasFocus()); 962 EXPECT_FALSE(Selection().SelectionHasFocus());
963 EXPECT_FALSE(Selection().IsHidden()); // Range still visible. 963 EXPECT_FALSE(Selection().IsHidden()); // Range still visible.
964 } 964 }
965 965
966 // crbug.com/725457
967 TEST_F(FrameSelectionTest, InconsistentVisibleSelectionNoCrash) {
968 SetBodyContent("foo<div id=host><span id=anchor>bar</span></div>baz");
969 SetShadowContent("shadow", "host");
970
971 Element* anchor = GetDocument().getElementById("anchor");
972
973 // |start| and |end| are valid Positions in DOM tree, but do not participate
974 // in flat tree. They should be canonicalized to null VisiblePositions, but
975 // are currently not. See crbug.com/729636 for details.
976 const Position& start = Position::BeforeNode(anchor);
977 const Position& end = Position::AfterNode(anchor);
978 Selection().SetSelection(
979 SelectionInDOMTree::Builder().Collapse(start).Extend(end).Build());
980
981 // Shouldn't crash inside.
982 EXPECT_FALSE(Selection().SelectionHasFocus());
983 }
984
966 } // namespace blink 985 } // namespace blink
OLDNEW
« 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