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

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

Issue 2595783002: [Editing] Add null check in |DeleteSelectionCommand::removeRedundantBlocks()| (Closed)
Patch Set: dominicc's suggestion: Use unit test instead of layout test Created 4 years 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
Index: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommandTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommandTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5357b8e35e2e444e785e6b943538fe652c855396
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommandTest.cpp
@@ -0,0 +1,51 @@
+// 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/ApplyStyleCommand.h"
+
+#include "core/css/StylePropertySet.h"
+#include "core/dom/Document.h"
+#include "core/editing/EditingTestBase.h"
+#include "core/editing/FrameSelection.h"
+#include "core/frame/LocalFrame.h"
+
+namespace blink {
+
+class ApplyStyleCommandTest : public EditingTestBase {};
+
+// This is a regression test for https://crbug.com/675727
+TEST_F(ApplyStyleCommandTest, RemoveRedundantBlocksWithStarEditableStyle) {
+ // The second <div> below is redundant from Blink's perspective (no siblings
+ // && no attributes) and will be removed by
+ // |DeleteSelectionCommand::removeRedundantBlocks()|.
+ setBodyContent(
+ "<div><div>"
+ "<div></div>"
+ "<ul>"
+ "<li>"
+ "<div></div>"
+ "<input>"
+ "<style> * {-webkit-user-modify: read-write;}</style><div></div>"
+ "</li>"
+ "</ul></div></div>");
+
+ Element* li = document().querySelector("li");
+
+ LocalFrame* frame = document().frame();
+ frame->selection().setSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(Position(li, PositionAnchorType::BeforeAnchor))
+ .build());
+
+ MutableStylePropertySet* style =
+ MutableStylePropertySet::create(HTMLQuirksMode);
+ style->setProperty(CSSPropertyTextAlign, "center");
+ ApplyStyleCommand::create(document(), EditingStyle::create(style),
+ InputEvent::InputType::FormatJustifyCenter,
+ ApplyStyleCommand::ForceBlockProperties)
+ ->apply(EditCommandSource::kDOM);
+ // Shouldn't crash.
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698