OLD | NEW |
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 Loading... |
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 |
OLD | NEW |