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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret) { | 259 TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret) { |
260 setBodyContent("<style id=sample></style>"); | 260 setBodyContent("<style id=sample></style>"); |
261 document().setDesignMode("on"); | 261 document().setDesignMode("on"); |
262 updateAllLifecyclePhases(); | 262 updateAllLifecyclePhases(); |
263 Element* sample = document().getElementById("sample"); | 263 Element* sample = document().getElementById("sample"); |
264 selection().setSelection( | 264 selection().setSelection( |
265 SelectionInDOMTree::Builder().collapse(Position(sample, 0)).build()); | 265 SelectionInDOMTree::Builder().collapse(Position(sample, 0)).build()); |
266 EXPECT_EQ(Position(document().body(), 0), selection().start()); | 266 EXPECT_EQ(Position(document().body(), 0), selection().start()); |
267 EXPECT_EQ(selection().start(), caretPosition().position()); | 267 EXPECT_EQ(selection().start(), caretPosition().position()); |
268 document().body()->remove(); | 268 document().body()->remove(); |
269 EXPECT_EQ(Position(), selection().start()) | 269 // TODO(yosin): Once lazy canonicalization implemented, selection.start |
270 << "Selection has been removed by BODY.remove()."; | 270 // should be Position(HTML, 0). |
| 271 EXPECT_EQ(Position(document().documentElement(), 1), selection().start()); |
271 EXPECT_EQ(selection().start(), caretPosition().position()); | 272 EXPECT_EQ(selection().start(), caretPosition().position()); |
272 document().updateStyleAndLayout(); | 273 document().updateStyleAndLayout(); |
273 selection().updateIfNeeded(); | 274 selection().updateIfNeeded(); |
274 | 275 |
| 276 // TODO(yosin): Once lazy canonicalization implemented, selection.start |
| 277 // should be Position(HTML, 0). |
275 EXPECT_EQ(Position(), selection().start()) | 278 EXPECT_EQ(Position(), selection().start()) |
276 << "selection().updateIfNeeded() does nothing."; | 279 << "updateIfNeeded() makes selection to null."; |
277 EXPECT_EQ(selection().start(), caretPosition().position()); | 280 EXPECT_EQ(selection().start(), caretPosition().position()); |
278 } | 281 } |
279 | 282 |
280 } // namespace blink | 283 } // namespace blink |
OLD | NEW |