| Index: third_party/WebKit/Source/core/editing/commands/InsertListCommandTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/commands/InsertListCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/InsertListCommandTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..eb70b3574f76684adf611519373a42baf4f528fc
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/commands/InsertListCommandTest.cpp
|
| @@ -0,0 +1,44 @@
|
| +// 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/InsertListCommand.h"
|
| +
|
| +#include "core/dom/ParentNode.h"
|
| +#include "core/dom/Text.h"
|
| +#include "core/editing/EditingTestBase.h"
|
| +#include "core/editing/FrameSelection.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class InsertListCommandTest : public EditingTestBase {
|
| +};
|
| +
|
| +TEST_F(InsertListCommandTest, ShouldCleanlyRemoveSpuriousTextNode)
|
| +{
|
| + // Needs to be editable to use InsertListCommand.
|
| + document().setDesignMode("on");
|
| + // Set up the condition:
|
| + // * Selection is a range, to go down into InsertListCommand::listifyParagraph.
|
| + // * The selection needs to have a sibling list to go down into
|
| + // InsertListCommand::mergeWithNeighboringLists.
|
| + // * Should be the same type (ordered list) to go into
|
| + // CompositeEditCommand::mergeIdenticalElements.
|
| + // * Should have no actual children to fail the listChildNode check
|
| + // in InsertListCommand::doApplyForSingleParagraph.
|
| + // * There needs to be an extra text node to trigger its removal in
|
| + // CompositeEditCommand::mergeIdenticalElements.
|
| + // The removeNode is what updates document lifecycle to VisualUpdatePending and
|
| + // makes FrameView::needsLayout return true.
|
| + setBodyContent("\nd\n<ol>");
|
| + Text* emptyText = document().createTextNode("");
|
| + document().body()->insertBefore(emptyText, document().body()->firstChild());
|
| + document().frame()->selection().setSelection(VisibleSelection(Position(document().body(), 0), Position(document().body(), 2)));
|
| +
|
| + InsertListCommand* command = InsertListCommand::create(document(), InsertListCommand::OrderedList);
|
| + // This should not DCHECK.
|
| + EXPECT_TRUE(command->apply()) << "The insert ordered list command should have succeeded";
|
| + EXPECT_EQ("<ol><li>d</li></ol>", document().body()->innerHTML());
|
| +}
|
| +
|
| +}
|
|
|