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

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

Issue 2534783002: Apply RelocatablePosition in DeleteSelectionCommand::mergeParagraphs (Closed)
Patch Set: Tue Nov 29 21:12:11 JST 2016 Created 4 years, 1 month 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/DeleteSelectionCommand.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/DeleteSelectionCommandTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommandTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9851afd5e31be552240941e7fb6874d6d07c9a2
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommandTest.cpp
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/editing/commands/DeleteSelectionCommand.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/Document.h"
+#include "core/editing/EditingTestBase.h"
+#include "core/editing/FrameSelection.h"
+#include "core/editing/Position.h"
+#include "core/editing/VisibleSelection.h"
+#include "core/frame/FrameView.h"
+#include "core/frame/LocalFrame.h"
+#include "core/testing/DummyPageHolder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include <memory>
+
+namespace blink {
+
+class DeleteSelectionCommandTest : public EditingTestBase {};
+
+// This is a regression test for https://crbug.com/668765
+TEST_F(DeleteSelectionCommandTest, deleteListFromTable) {
+ setBodyContent(
+ "<div contenteditable=true>"
+ "<table><tr><td><ol>"
+ "<li><br></li>"
+ "<li>foo</li>"
+ "</ol></td></tr></table>"
+ "</div>");
+
+ Element* div = document().querySelector("div");
+ Element* table = document().querySelector("table");
+ Element* br = document().querySelector("br");
+
+ LocalFrame* frame = document().frame();
+ frame->selection().setSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(Position(br, PositionAnchorType::BeforeAnchor))
+ .extend(Position(table, PositionAnchorType::AfterAnchor))
+ .build());
+
+ const bool kNoSmartDelete = false;
+ const bool kMergeBlocksAfterDelete = true;
+ const bool kNoExpandForSpecialElements = false;
+ const bool kSanitizeMarkup = true;
+ DeleteSelectionCommand* command = DeleteSelectionCommand::create(
+ document(), kNoSmartDelete, kMergeBlocksAfterDelete,
+ kNoExpandForSpecialElements, kSanitizeMarkup,
+ InputEvent::InputType::DeleteByCut);
+
+ EXPECT_TRUE(command->apply()) << "the delete command should have succeeded";
+ EXPECT_EQ("<div contenteditable=\"true\"><br></div>",
+ document().body()->innerHTML());
+ EXPECT_TRUE(frame->selection().isCaret());
+ EXPECT_EQ(Position(div, 0), frame->selection().base().toOffsetInAnchor());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698