| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "public/web/WebElement.h" | 6 #include "public/web/WebElement.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/shadow/ShadowRoot.h" | 10 #include "core/dom/shadow/ShadowRoot.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 OwnPtr<DummyPageHolder> m_pageHolder; | 72 OwnPtr<DummyPageHolder> m_pageHolder; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 void WebElementTest::insertHTML(String html) | 75 void WebElementTest::insertHTML(String html) |
| 76 { | 76 { |
| 77 document().documentElement()->setInnerHTML(html, ASSERT_NO_EXCEPTION); | 77 document().documentElement()->setInnerHTML(html, ASSERT_NO_EXCEPTION); |
| 78 } | 78 } |
| 79 | 79 |
| 80 WebElement WebElementTest::testElement() | 80 WebElement WebElementTest::testElement() |
| 81 { | 81 { |
| 82 return WebElement(document().getElementById("testElement")); | 82 Element* element = document().getElementById("testElement"); |
| 83 ASSERT(element); |
| 84 return WebElement(element); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void WebElementTest::SetUp() | 87 void WebElementTest::SetUp() |
| 86 { | 88 { |
| 87 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); | 89 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 88 } | 90 } |
| 89 | 91 |
| 90 TEST_F(WebElementTest, HasNonEmptyLayoutSize) | 92 TEST_F(WebElementTest, HasNonEmptyLayoutSize) |
| 91 { | 93 { |
| 92 insertHTML(s_emptyBlock); | 94 insertHTML(s_emptyBlock); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 112 | 114 |
| 113 insertHTML(s_blockWithText); | 115 insertHTML(s_blockWithText); |
| 114 EXPECT_TRUE(testElement().hasNonEmptyLayoutSize()); | 116 EXPECT_TRUE(testElement().hasNonEmptyLayoutSize()); |
| 115 | 117 |
| 116 insertHTML(s_emptyBlock); | 118 insertHTML(s_emptyBlock); |
| 117 RefPtrWillBeRawPtr<ShadowRoot> root = document().getElementById("testElement
")->createShadowRootInternal(ShadowRootType::OpenByDefault, ASSERT_NO_EXCEPTION)
; | 119 RefPtrWillBeRawPtr<ShadowRoot> root = document().getElementById("testElement
")->createShadowRootInternal(ShadowRootType::OpenByDefault, ASSERT_NO_EXCEPTION)
; |
| 118 root->setInnerHTML("<div>Hello World</div>", ASSERT_NO_EXCEPTION); | 120 root->setInnerHTML("<div>Hello World</div>", ASSERT_NO_EXCEPTION); |
| 119 EXPECT_TRUE(testElement().hasNonEmptyLayoutSize()); | 121 EXPECT_TRUE(testElement().hasNonEmptyLayoutSize()); |
| 120 } | 122 } |
| 121 | 123 |
| 124 TEST_F(WebElementTest, IsEditable) |
| 125 { |
| 126 insertHTML("<div id=testElement></div>"); |
| 127 EXPECT_FALSE(testElement().isEditable()); |
| 128 |
| 129 insertHTML("<div id=testElement contenteditable=true></div>"); |
| 130 EXPECT_TRUE(testElement().isEditable()); |
| 131 |
| 132 insertHTML( |
| 133 "<div style='-webkit-user-modify: read-write'>" |
| 134 " <div id=testElement></div>" |
| 135 "</div>" |
| 136 ); |
| 137 EXPECT_TRUE(testElement().isEditable()); |
| 138 |
| 139 insertHTML( |
| 140 "<div style='-webkit-user-modify: read-write'>" |
| 141 " <div id=testElement style='-webkit-user-modify: read-only'></div>" |
| 142 "</div>" |
| 143 ); |
| 144 EXPECT_FALSE(testElement().isEditable()); |
| 145 |
| 146 insertHTML("<input id=testElement>"); |
| 147 EXPECT_TRUE(testElement().isEditable()); |
| 148 |
| 149 insertHTML("<input id=testElement readonly>"); |
| 150 EXPECT_FALSE(testElement().isEditable()); |
| 151 |
| 152 insertHTML("<input id=testElement disabled>"); |
| 153 EXPECT_FALSE(testElement().isEditable()); |
| 154 |
| 155 insertHTML("<fieldset disabled><div><input id=testElement></div></fieldset>"
); |
| 156 EXPECT_FALSE(testElement().isEditable()); |
| 157 } |
| 158 |
| 122 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |