| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/editing/commands/ApplyStyleCommand.h" |
| 6 |
| 7 #include "core/css/StylePropertySet.h" |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/editing/EditingTestBase.h" |
| 10 #include "core/editing/FrameSelection.h" |
| 11 #include "core/frame/LocalFrame.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class ApplyStyleCommandTest : public EditingTestBase {}; |
| 16 |
| 17 // This is a regression test for https://crbug.com/675727 |
| 18 TEST_F(ApplyStyleCommandTest, RemoveRedundantBlocksWithStarEditableStyle) { |
| 19 // The second <div> below is redundant from Blink's perspective (no siblings |
| 20 // && no attributes) and will be removed by |
| 21 // |DeleteSelectionCommand::removeRedundantBlocks()|. |
| 22 setBodyContent( |
| 23 "<div><div>" |
| 24 "<div></div>" |
| 25 "<ul>" |
| 26 "<li>" |
| 27 "<div></div>" |
| 28 "<input>" |
| 29 "<style> * {-webkit-user-modify: read-write;}</style><div></div>" |
| 30 "</li>" |
| 31 "</ul></div></div>"); |
| 32 |
| 33 Element* li = document().querySelector("li"); |
| 34 |
| 35 LocalFrame* frame = document().frame(); |
| 36 frame->selection().setSelection( |
| 37 SelectionInDOMTree::Builder() |
| 38 .collapse(Position(li, PositionAnchorType::BeforeAnchor)) |
| 39 .build()); |
| 40 |
| 41 MutableStylePropertySet* style = |
| 42 MutableStylePropertySet::create(HTMLQuirksMode); |
| 43 style->setProperty(CSSPropertyTextAlign, "center"); |
| 44 ApplyStyleCommand::create(document(), EditingStyle::create(style), |
| 45 InputEvent::InputType::FormatJustifyCenter, |
| 46 ApplyStyleCommand::ForceBlockProperties) |
| 47 ->apply(EditCommandSource::kDOM); |
| 48 // Shouldn't crash. |
| 49 } |
| 50 |
| 51 } // namespace blink |
| OLD | NEW |