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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp

Issue 2121613003: Include style tags when pasting HTML content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EditorTestBase. Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698