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

Side by Side 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 unified diff | Download patch
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/Editor.h"
6
7 #include "core/dom/Document.h"
8 #include "core/editing/EditingTestBase.h"
9 #include "core/html/HTMLBodyElement.h"
10 #include "core/html/HTMLDivElement.h"
11 #include "core/html/HTMLHeadElement.h"
12 #include "core/html/HTMLHtmlElement.h"
13
14 namespace blink {
15
16 class EditorTest : public EditingTestBase {
17 protected:
18 void makeDocumentEmpty();
19 };
20
21 void EditorTest::makeDocumentEmpty()
22 {
23 while (document().firstChild())
24 document().removeChild(document().firstChild());
25 }
26
27 TEST_F(EditorTest, tidyUpHTMLStructureFromBody)
28 {
29 RefPtrWillBeRawPtr<Element> body = HTMLBodyElement::create(document());
30 makeDocumentEmpty();
31 document().setDesignMode("on");
32 document().appendChild(body);
33 Editor::tidyUpHTMLStructure(document());
34
35 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
36 EXPECT_EQ(body, document().body());
37 EXPECT_EQ(document().documentElement(), body->parentNode());
38 }
39
40 TEST_F(EditorTest, tidyUpHTMLStructureFromDiv)
41 {
42 RefPtrWillBeRawPtr<Element> div = HTMLDivElement::create(document());
43 makeDocumentEmpty();
44 document().setDesignMode("on");
45 document().appendChild(div);
46 Editor::tidyUpHTMLStructure(document());
47
48 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
49 EXPECT_TRUE(isHTMLBodyElement(document().body()));
50 EXPECT_EQ(document().body(), div->parentNode());
51 }
52
53 TEST_F(EditorTest, tidyUpHTMLStructureFromHead)
54 {
55 RefPtrWillBeRawPtr<Element> head = HTMLHeadElement::create(document());
56 makeDocumentEmpty();
57 document().setDesignMode("on");
58 document().appendChild(head);
59 Editor::tidyUpHTMLStructure(document());
60
61 EXPECT_TRUE(isHTMLHtmlElement(document().documentElement()));
62 EXPECT_TRUE(isHTMLBodyElement(document().body()));
63 EXPECT_EQ(document().documentElement(), head->parentNode());
64 }
65
66 } // namespace blink
OLDNEW
« 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