Index: third_party/WebKit/Source/core/layout/LayoutTextTest.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp b/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp |
index 9c551bbcf4df3a69b7405733b165cb34ab898c3b..1a6517c0299cfdb50defbfd214d215de0cdc01a2 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp |
@@ -85,4 +85,88 @@ TEST_F(LayoutTextTest, WidthLengthBeyondLength) |
ASSERT_LE(width, 20.f); |
} |
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersInsertAfterWS) |
+{ |
+ setBodyInnerHTML("<span></span> <span id='span'></span>"); |
+ |
+ Element* span = document().getElementById("span"); |
+ Node* whitespace1 = span->previousSibling(); |
+ EXPECT_TRUE(whitespace1->layoutObject()); |
+ |
+ Node* whitespace2 = Text::create(document(), " "); |
+ document().body()->insertBefore(whitespace2, span, ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ EXPECT_TRUE(whitespace1->layoutObject()); |
+ EXPECT_FALSE(whitespace2->layoutObject()); |
+} |
+ |
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersInsertBeforeWS) |
+{ |
+ setBodyInnerHTML("<span id='span'></span> <span></span>"); |
+ |
+ Element* span = document().getElementById("span"); |
+ Node* whitespace2 = span->nextSibling(); |
+ EXPECT_TRUE(whitespace2->layoutObject()); |
+ |
+ Node* whitespace1 = Text::create(document(), " "); |
+ document().body()->insertBefore(whitespace1, whitespace2, ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ EXPECT_TRUE(whitespace1->layoutObject()); |
+ EXPECT_FALSE(whitespace2->layoutObject()); |
+} |
+ |
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersDisplayNone) |
+{ |
+ setBodyInnerHTML("<span></span> <span style='display:none'></span> <span></span>"); |
+ |
+ // First <span> |
+ Node* child = document().body()->firstChild(); |
+ ASSERT_TRUE(child); |
+ |
+ // First whitespace node |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_TRUE(child->isTextNode()); |
+ EXPECT_TRUE(child->layoutObject()); |
+ |
+ // <span display:none> |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_FALSE(child->layoutObject()); |
+ |
+ // Second whitespace node |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_TRUE(child->isTextNode()); |
+ EXPECT_FALSE(child->layoutObject()); |
+} |
+ |
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersComment) |
+{ |
+ setBodyInnerHTML("<span></span> <!-- --> <span></span>"); |
+ |
+ // First <span> |
+ Node* child = document().body()->firstChild(); |
+ ASSERT_TRUE(child); |
+ |
+ // First whitespace node |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_TRUE(child->isTextNode()); |
+ EXPECT_TRUE(child->layoutObject()); |
+ |
+ // Comment node |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_FALSE(child->layoutObject()); |
+ |
+ // Second whitespace node |
+ child = child->nextSibling(); |
+ ASSERT_TRUE(child); |
+ EXPECT_TRUE(child->isTextNode()); |
+ EXPECT_FALSE(child->layoutObject()); |
+} |
+ |
} // namespace blink |