Chromium Code Reviews| 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..45a1b8d5de43f7b5623916239191ffa443d94145 | 
| --- /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\">" | 
| 
 
yosin_UTC9
2016/11/29 01:36:22
nit: Let's use single-quote to avoid escaping doub
 
Xiaocheng
2016/11/29 02:00:35
Quotes removed.
 
 | 
| + "<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 kSmartDelete = false; | 
| + const bool kMergeBlocksAfterDelete = true; | 
| + const bool kExpandForSpecialElements = false; | 
| + const bool kSanitizeMarkup = true; | 
| + DeleteSelectionCommand* command = DeleteSelectionCommand::create( | 
| + document(), kSmartDelete, kMergeBlocksAfterDelete, | 
| 
 
tkent
2016/11/29 01:43:19
|kSmartDelete| is confusing.  The code looks to en
 
Xiaocheng
2016/11/29 02:00:35
Renamed to |kNoSmartDelete|.
 
 | 
| + kExpandForSpecialElements, kSanitizeMarkup, | 
| 
 
tkent
2016/11/29 01:43:19
Ditto for kExpandForSpecialElements.
 
Xiaocheng
2016/11/29 02:00:35
Renamed to |kNoExpandForSpecialElements|.
 
 | 
| + InputEvent::InputType::DeleteByCut); | 
| + | 
| + EXPECT_TRUE(command->apply()) << "the delete command should have succeeded"; | 
| + EXPECT_EQ("<div contenteditable=\"true\"><br></div>", | 
| 
 
yosin_UTC9
2016/11/29 01:36:22
nit: Let's use single-quote to avoid escaping doub
 
Xiaocheng
2016/11/29 02:00:35
Can't use single-quote for test expectation...
 
 | 
| + document().body()->innerHTML()); | 
| + EXPECT_TRUE(frame->selection().isCaret()); | 
| + EXPECT_EQ(Position(div, 0), frame->selection().base().toOffsetInAnchor()); | 
| +} | 
| + | 
| +} // namespace blink |