Commit 58787ec6 authored by tanvir.rizvi's avatar tanvir.rizvi Committed by Commit Bot

Crash in CompositeEditCommand::InsertNodeBefore

InsertNodeBefore crashes if the passed ref_child
is disconnected.

Bug: 755808
Change-Id: I4c07836b6d0f055f2cdfd8f94c326fcaaf03d6ca
Reviewed-on: https://chromium-review.googlesource.com/893243Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Tanvir Rizvi <tanvir.rizvi@samsung.com>
Cr-Commit-Position: refs/heads/master@{#533222}
parent 91707a70
......@@ -288,6 +288,7 @@ void CompositeEditCommand::InsertNodeBefore(
ShouldAssumeContentIsAlwaysEditable
should_assume_content_is_always_editable) {
DCHECK_NE(GetDocument().body(), ref_child);
ABORT_EDITING_COMMAND_IF(!ref_child->parentNode());
// TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
......
......@@ -134,4 +134,16 @@ TEST_F(CompositeEditCommandTest,
body->InnerHTMLAsString());
}
TEST_F(CompositeEditCommandTest, InsertNodeOnDisconnectedParent) {
SetBodyContent("<p><b></b></p>");
SampleCommand& sample = *new SampleCommand(GetDocument());
Node* insert_child = GetDocument().QuerySelector("b");
Element* ref_child = GetDocument().QuerySelector("p");
ref_child->remove();
EditingState editing_state;
// editing state should abort here.
sample.InsertNodeBefore(insert_child, ref_child, &editing_state);
EXPECT_TRUE(editing_state.IsAborted());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment