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/ReplaceSelectionCommand.h" |
| 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/HTMLNames.h" |
| 9 #include "core/dom/DocumentFragment.h" |
| 10 #include "core/dom/ParserContentPolicy.h" |
| 11 #include "core/editing/EditingTestBase.h" |
| 12 #include "core/editing/FrameSelection.h" |
| 13 #include "core/editing/Position.h" |
| 14 #include "core/editing/VisibleSelection.h" |
| 15 #include "core/frame/FrameView.h" |
| 16 #include "core/frame/LocalFrame.h" |
| 17 #include "core/html/HTMLDocument.h" |
| 18 #include "core/testing/DummyPageHolder.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 |
| 21 #include <memory> |
| 22 |
| 23 namespace blink { |
| 24 |
| 25 class ReplaceSelectionCommandTest : public EditingTestBase { |
| 26 }; |
| 27 |
| 28 // This is a regression test for https://crbug.com/121163 |
| 29 TEST_F(ReplaceSelectionCommandTest, styleTagsInPastedHeadIncludedInContent) |
| 30 { |
| 31 document().setDesignMode("on"); |
| 32 dummyPageHolder().frame().selection().setSelection( |
| 33 VisibleSelection(Position(document().body(), 0))); |
| 34 |
| 35 DocumentFragment* fragment = document().createDocumentFragment(); |
| 36 fragment->parseHTML( |
| 37 "<head><style>foo { bar: baz; }</style></head>" |
| 38 "<body><p>Text</p></body>", |
| 39 document().documentElement(), |
| 40 DisallowScriptingAndPluginContent); |
| 41 |
| 42 ReplaceSelectionCommand::CommandOptions options = 0; |
| 43 ReplaceSelectionCommand* command = |
| 44 ReplaceSelectionCommand::create(document(), fragment, options); |
| 45 EXPECT_TRUE(command->apply()) |
| 46 << "the replace command should have succeeded"; |
| 47 |
| 48 EXPECT_EQ( |
| 49 "<head><style>foo { bar: baz; }</style></head>" |
| 50 "<body><p>Text</p></body>", |
| 51 document().body()->innerHTML()) |
| 52 << "the STYLE and P elements should have been pasted into the body " |
| 53 << "of the document"; |
| 54 } |
| 55 |
| 56 } // namespace blink |
OLD | NEW |