Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e376bf3fdbda4b97bceb331d02358dabf5461e0a |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp |
@@ -0,0 +1,59 @@ |
+// 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/ReplaceSelectionCommand.h" |
+ |
+#include "bindings/core/v8/ExceptionState.h" |
+#include "core/HTMLNames.h" |
+#include "core/dom/DocumentFragment.h" |
+#include "core/dom/ParserContentPolicy.h" |
+#include "core/editing/FrameSelection.h" |
+#include "core/editing/Position.h" |
+#include "core/editing/VisibleSelection.h" |
+#include "core/frame/FrameView.h" |
+#include "core/frame/LocalFrame.h" |
+#include "core/html/HTMLDocument.h" |
+#include "core/testing/DummyPageHolder.h" |
+ |
+#include <gtest/gtest.h> |
tkent
2016/07/06 04:05:20
We should not use <> for gtest.h because it's not
|
+#include <memory> |
+ |
+namespace blink { |
+ |
+namespace { |
yosin_UTC9
2016/07/06 03:44:00
You don't need to put TEST() in anonymous namespac
|
+ |
+// This is a regression test for https://crbug.com/121163 |
+TEST(ReplaceSelectionCommandTest, styleTagsInPastedHeadIncludedInContent) |
yosin_UTC9
2016/07/06 04:05:47
BTW, you can use EditingTestBase.
https://cs.chrom
|
+{ |
+ std::unique_ptr<DummyPageHolder> holder = |
+ DummyPageHolder::create(IntSize(1, 1)); |
+ Document& document = holder->document(); |
+ document.setDesignMode("on"); |
+ holder->frame().selection().setSelection( |
+ VisibleSelection(Position(document.body(), 0))); |
+ |
+ DocumentFragment* fragment = document.createDocumentFragment(); |
+ 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
|
+ "<head><style>foo { bar: baz; }</style></head>" |
+ "<body><p>Text</p></body>", |
+ document.documentElement(), |
+ DisallowScriptingAndPluginContent); |
+ |
+ ReplaceSelectionCommand::CommandOptions options = 0; |
+ ReplaceSelectionCommand* command = |
+ ReplaceSelectionCommand::create(document, fragment, options); |
+ EXPECT_TRUE(command->apply()) |
+ << "the replace command should have succeeded"; |
+ |
+ EXPECT_EQ( |
+ "<head><style>foo { bar: baz; }</style></head>" |
+ "<body><p>Text</p></body>", |
+ document.body()->innerHTML()) |
+ << "the STYLE and P elements should have been pasted into the body " |
+ << "of the document"; |
+} |
+ |
+} // namespace |
+ |
+} // namespace blink |