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 76d0f6d8cd54a03ebf0e37edde875111ac69cf04..d18c02e4fe01a463415f8d938d87fd97282f3af6 100644 |
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp |
@@ -69,7 +69,7 @@ TEST_F(FrameSelectionTest, FirstEphemeralRangeOf) { |
const EphemeralRange& range = |
FirstEphemeralRangeOf(Selection().ComputeVisibleSelectionInDOMTree()); |
EXPECT_EQ(Position(sample->nextSibling(), 0), range.StartPosition()) |
- << "firstRagne() should return current selection value"; |
+ << "firstRange() should return current selection value"; |
EXPECT_EQ(Position(sample->nextSibling(), 0), range.EndPosition()); |
} |
@@ -280,8 +280,8 @@ TEST_F(FrameSelectionTest, SelectAllPreservesHandle) { |
EXPECT_FALSE(Selection().IsHandleVisible()); |
Selection().SelectAll(); |
EXPECT_FALSE(Selection().IsHandleVisible()) |
- << "If handles weren't present before" |
- "selectAll. Then they shouldn't be present" |
+ << "If handles weren't present before " |
+ "selectAll. Then they shouldn't be present " |
"after it."; |
Selection().SetSelection(SelectionInDOMTree::Builder() |
@@ -291,11 +291,40 @@ TEST_F(FrameSelectionTest, SelectAllPreservesHandle) { |
EXPECT_TRUE(Selection().IsHandleVisible()); |
Selection().SelectAll(); |
EXPECT_TRUE(Selection().IsHandleVisible()) |
- << "If handles were present before" |
- "selectAll. Then they should be present" |
+ << "If handles were present before " |
+ "selectAll. Then they should be present " |
"after it."; |
} |
+TEST_F(FrameSelectionTest, BoldCommandPreservesHandle) { |
+ SetBodyContent("<div id=sample>abc</div>"); |
+ Element* sample = GetDocument().getElementById("sample"); |
+ const Position end_of_text(sample->firstChild(), 3); |
+ Selection().SetSelection(SelectionInDOMTree::Builder() |
+ .Collapse(end_of_text) |
+ .SetIsHandleVisible(false) |
+ .Build()); |
+ EXPECT_FALSE(Selection().IsHandleVisible()); |
+ Selection().SelectAll(); |
+ GetDocument().execCommand("bold", false, "", ASSERT_NO_EXCEPTION); |
+ EXPECT_FALSE(Selection().IsHandleVisible()) |
+ << "If handles weren't present before " |
+ "bold command. Then they shouldn't " |
+ "be present after it."; |
+ |
+ Selection().SetSelection(SelectionInDOMTree::Builder() |
+ .Collapse(end_of_text) |
+ .SetIsHandleVisible(true) |
+ .Build()); |
+ EXPECT_TRUE(Selection().IsHandleVisible()); |
+ Selection().SelectAll(); |
+ GetDocument().execCommand("bold", false, "", ASSERT_NO_EXCEPTION); |
+ EXPECT_TRUE(Selection().IsHandleVisible()) |
+ << "If handles were present before " |
+ "bold command. Then they should " |
+ "be present after it."; |
+} |
+ |
TEST_F(FrameSelectionTest, SetSelectedRangeHidesHandle) { |
Text* text = AppendTextNode("Hello, World!"); |
GetDocument().View()->UpdateAllLifecyclePhases(); |