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/FrameSelection.h" | |
12 #include "core/editing/Position.h" | |
13 #include "core/editing/VisibleSelection.h" | |
14 #include "core/frame/FrameView.h" | |
15 #include "core/frame/LocalFrame.h" | |
16 #include "core/html/HTMLDocument.h" | |
17 #include "core/testing/DummyPageHolder.h" | |
18 | |
19 #include <gtest/gtest.h> | |
tkent
2016/07/06 04:05:20
We should not use <> for gtest.h because it's not
| |
20 #include <memory> | |
21 | |
22 namespace blink { | |
23 | |
24 namespace { | |
yosin_UTC9
2016/07/06 03:44:00
You don't need to put TEST() in anonymous namespac
| |
25 | |
26 // This is a regression test for https://crbug.com/121163 | |
27 TEST(ReplaceSelectionCommandTest, styleTagsInPastedHeadIncludedInContent) | |
yosin_UTC9
2016/07/06 04:05:47
BTW, you can use EditingTestBase.
https://cs.chrom
| |
28 { | |
29 std::unique_ptr<DummyPageHolder> holder = | |
30 DummyPageHolder::create(IntSize(1, 1)); | |
31 Document& document = holder->document(); | |
32 document.setDesignMode("on"); | |
33 holder->frame().selection().setSelection( | |
34 VisibleSelection(Position(document.body(), 0))); | |
35 | |
36 DocumentFragment* fragment = document.createDocumentFragment(); | |
37 fragment->parseHTML( | |
yosin_UTC9
2016/07/06 03:44:01
This is the reason why it is better to use gTest r
tkent
2016/07/06 04:05:20
The copy command needs a user gesture. So it's im
| |
38 "<head><style>foo { bar: baz; }</style></head>" | |
39 "<body><p>Text</p></body>", | |
40 document.documentElement(), | |
41 DisallowScriptingAndPluginContent); | |
42 | |
43 ReplaceSelectionCommand::CommandOptions options = 0; | |
44 ReplaceSelectionCommand* command = | |
45 ReplaceSelectionCommand::create(document, fragment, options); | |
46 EXPECT_TRUE(command->apply()) | |
47 << "the replace command should have succeeded"; | |
48 | |
49 EXPECT_EQ( | |
50 "<head><style>foo { bar: baz; }</style></head>" | |
51 "<body><p>Text</p></body>", | |
52 document.body()->innerHTML()) | |
53 << "the STYLE and P elements should have been pasted into the body " | |
54 << "of the document"; | |
55 } | |
56 | |
57 } // namespace | |
58 | |
59 } // namespace blink | |
OLD | NEW |