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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 .setIsHandleVisible(true) | 235 .setIsHandleVisible(true) |
236 .build()); | 236 .build()); |
237 EXPECT_TRUE(selection().isHandleVisible()); | 237 EXPECT_TRUE(selection().isHandleVisible()); |
238 selection().selectAll(); | 238 selection().selectAll(); |
239 EXPECT_TRUE(selection().isHandleVisible()) | 239 EXPECT_TRUE(selection().isHandleVisible()) |
240 << "If handles were present before" | 240 << "If handles were present before" |
241 "selectAll. Then they should be present" | 241 "selectAll. Then they should be present" |
242 "after it."; | 242 "after it."; |
243 } | 243 } |
244 | 244 |
245 TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret) { | |
246 setBodyContent("<style id=sample></style>"); | |
247 document().setDesignMode("on"); | |
248 updateAllLifecyclePhases(); | |
249 Element* sample = document().getElementById("sample"); | |
250 selection().setSelection( | |
251 SelectionInDOMTree::Builder().collapse(Position(sample, 0)).build()); | |
252 EXPECT_EQ(Position(document().body(), 0), | |
253 selection().computeVisibleSelectionInDOMTreeDeprecated().start()); | |
254 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(), | |
255 caretPosition().position()); | |
256 document().body()->remove(); | |
257 EXPECT_EQ(Position(), | |
258 selection().computeVisibleSelectionInDOMTreeDeprecated().start()) | |
259 << "Selection has been removed by BODY.remove()."; | |
260 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(), | |
261 caretPosition().position()); | |
262 document().updateStyleAndLayout(); | |
263 selection().updateIfNeeded(); | |
264 | |
265 EXPECT_EQ(Position(), | |
266 selection().computeVisibleSelectionInDOMTreeDeprecated().start()) | |
267 << "selection().updateIfNeeded() does nothing."; | |
268 EXPECT_EQ(selection().computeVisibleSelectionInDOMTreeDeprecated().start(), | |
269 caretPosition().position()); | |
270 } | |
271 | |
272 } // namespace blink | 245 } // namespace blink |
OLD | NEW |