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

Unified Diff: third_party/WebKit/Source/core/editing/EditorTest.cpp

Issue 1828623002: Make Editor::tidyUpHTMLStructure() handles BODY element correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: third_party/WebKit/Source/core/editing/EditorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditorTest.cpp b/third_party/WebKit/Source/core/editing/EditorTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b92e8a45c8c2d0b1cfaeb7d7ae44c84221ecd820
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/EditorTest.cpp
@@ -0,0 +1,66 @@
+// 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/Editor.h"
+
+#include "core/dom/Document.h"
+#include "core/editing/EditingTestBase.h"
+#include "core/html/HTMLBodyElement.h"
+#include "core/html/HTMLDivElement.h"
+#include "core/html/HTMLHeadElement.h"
+#include "core/html/HTMLHtmlElement.h"
+
+namespace blink {
+
+class EditorTest : public EditingTestBase {
+protected:
+ void makeDocumentEmpty();
+};
+
+void EditorTest::makeDocumentEmpty()
+{
+ while (document().firstChild())
+ document().removeChild(document().firstChild());
+}
+
+TEST_F(EditorTest, tidyUpHTMLStructureFromBody)
+{
+ RefPtrWillBeRawPtr<Element> body = HTMLBodyElement::create(document());
+ makeDocumentEmpty();
+ document().setDesignMode("on");
+ document().appendChild(body);
+ Editor::tidyUpHTMLStructure(document());
+
+ EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
+ EXPECT_EQ(body, document().body());
+ EXPECT_EQ(document().documentElement(), body->parentNode());
+}
+
+TEST_F(EditorTest, tidyUpHTMLStructureFromDiv)
+{
+ RefPtrWillBeRawPtr<Element> div = HTMLDivElement::create(document());
+ makeDocumentEmpty();
+ document().setDesignMode("on");
+ document().appendChild(div);
+ Editor::tidyUpHTMLStructure(document());
+
+ EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
+ EXPECT_TRUE(isHTMLBodyElement(document().body()));
+ EXPECT_EQ(document().body(), div->parentNode());
+}
+
+TEST_F(EditorTest, tidyUpHTMLStructureFromHead)
+{
+ RefPtrWillBeRawPtr<Element> head = HTMLHeadElement::create(document());
+ makeDocumentEmpty();
+ document().setDesignMode("on");
+ document().appendChild(head);
+ Editor::tidyUpHTMLStructure(document());
+
+ EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
+ EXPECT_TRUE(isHTMLBodyElement(document().body()));
+ EXPECT_EQ(document().documentElement(), head->parentNode());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/html/HTMLHeadElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698