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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2613cb521914a74004fca3c36533344f251fd646
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp
@@ -0,0 +1,56 @@
+// 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/EditingTestBase.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 "testing/gtest/include/gtest/gtest.h"
+
+#include <memory>
+
+namespace blink {
+
+class ReplaceSelectionCommandTest : public EditingTestBase {
+};
+
+// This is a regression test for https://crbug.com/121163
+TEST_F(ReplaceSelectionCommandTest, styleTagsInPastedHeadIncludedInContent)
+{
+ document().setDesignMode("on");
+ dummyPageHolder().frame().selection().setSelection(
+ VisibleSelection(Position(document().body(), 0)));
+
+ DocumentFragment* fragment = document().createDocumentFragment();
+ fragment->parseHTML(
+ "<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 blink
« 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