Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp

Issue 2122003003: Make ReplaceSelectionCommand to handle empty SPAN replacement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-07T10:52:58 Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp
index 2613cb521914a74004fca3c36533344f251fd646..201f98478b6955da827eaf0da87c2ded63d0c337 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp
@@ -25,6 +25,34 @@ namespace blink {
class ReplaceSelectionCommandTest : public EditingTestBase {
};
+// This is a regression test for https://crbug.com/619131
+TEST_F(ReplaceSelectionCommandTest, pastingEmptySpan)
+{
+ document().setDesignMode("on");
+ setBodyContent("foo");
+
+ LocalFrame* frame = document().frame();
+ frame->selection().setSelection(
+ VisibleSelection(Position(document().body(), 0)));
+
+ DocumentFragment* fragment = document().createDocumentFragment();
+ fragment->appendChild(document().createElement("span", ASSERT_NO_EXCEPTION));
+
+ // |options| are taken from |Editor::replaceSelectionWithFragment()| with
+ // |selectReplacement| and |smartReplace|.
+ ReplaceSelectionCommand::CommandOptions options =
+ ReplaceSelectionCommand::PreventNesting |
+ ReplaceSelectionCommand::SanitizeFragment |
+ ReplaceSelectionCommand::SelectReplacement |
+ ReplaceSelectionCommand::SmartReplace;
+ ReplaceSelectionCommand* command =
+ ReplaceSelectionCommand::create(document(), fragment, options);
+
+ EXPECT_TRUE(command->apply())
+ << "the replace command should have succeeded";
+ EXPECT_EQ("foo", document().body()->innerHTML()) << "no DOM tree mutation";
+}
+
// This is a regression test for https://crbug.com/121163
TEST_F(ReplaceSelectionCommandTest, styleTagsInPastedHeadIncludedInContent)
{
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698