| 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/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 |
| OLD | NEW |