Chromium Code Reviews| 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 1924c0958e7ca057d898843d52897651fa9358a0..7ea3955da0cd4db55b1048229c2a98dea07cc42f 100644 |
| --- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp |
| @@ -9,6 +9,7 @@ |
| #include "core/dom/Element.h" |
| #include "core/dom/Text.h" |
| #include "core/editing/EditingTestBase.h" |
| +#include "core/editing/FrameCaret.h" |
| #include "core/frame/FrameView.h" |
| #include "core/html/HTMLBodyElement.h" |
| #include "core/html/HTMLDocument.h" |
| @@ -39,6 +40,11 @@ protected: |
| bool shouldPaintCaretForTesting() const { return selection().shouldPaintCaretForTesting(); } |
| bool isPreviousCaretDirtyForTesting() const { return selection().isPreviousCaretDirtyForTesting(); } |
| + PositionWithAffinity caretPosition() const |
| + { |
| + return selection().m_frameCaret->caretPosition(); |
| + } |
| + |
| private: |
| Persistent<Text> m_textNode; |
| }; |
| @@ -273,4 +279,21 @@ TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) |
| EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the content of the documentElement is not selctable."; |
| } |
| +TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret) |
| +{ |
| + setBodyContent("<style id=sample></style>"); |
| + document().setDesignMode("on"); |
| + Element* sample = document().getElementById("sample"); |
| + setSelection(VisibleSelection(Position(sample, 0))); |
|
yoichio
2016/07/20 09:10:06
Confirm selection().start() and caretPosition().po
yosin_UTC9
2016/07/20 09:27:33
Done.
|
| + document().body()->remove(); |
| + selection().updateIfNeeded(); |
| + |
| + // TODO(yosin): Once lazy canonicalization implemented, selection.start |
| + // should be Position(HTML, 0). |
| + EXPECT_EQ(Position(), selection().start()) |
| + << "updateIfNeeded() makes selection to null."; |
| + EXPECT_EQ(Position(), caretPosition().position()) |
| + << "caret position and selection.start should be same."; |
| +} |
| + |
| } // namespace blink |