Index: third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp |
index acb6dfce1e28e4d368833cf0285fb1618bbfaf80..6742cf730ddc00438c1023a6652fcf5d4d4970f7 100644 |
--- a/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/SurroundingTextTest.cpp |
@@ -4,15 +4,16 @@ |
#include "core/editing/SurroundingText.h" |
+#include <memory> |
#include "core/dom/Document.h" |
#include "core/dom/Range.h" |
#include "core/dom/Text.h" |
#include "core/editing/Position.h" |
#include "core/editing/VisibleSelection.h" |
#include "core/html/HTMLElement.h" |
+#include "core/html/TextControlElement.h" |
#include "core/testing/DummyPageHolder.h" |
#include "testing/gtest/include/gtest/gtest.h" |
-#include <memory> |
namespace blink { |
@@ -276,4 +277,21 @@ TEST_F(SurroundingTextTest, TreeRangeSelection) { |
} |
} |
+TEST_F(SurroundingTextTest, TextAreaSelection) { |
+ SetHTML(String("<textarea id='selection'>abc def ghi</textarea>")); |
+ |
+ TextControlElement* text_ctrl = |
+ (TextControlElement*)GetDocument().getElementById("selection"); |
+ |
+ text_ctrl->SetSelectionRange(4, 7); |
+ VisibleSelection selection = CreateVisibleSelection(text_ctrl->Selection()); |
+ |
+ SurroundingText surrounding_text( |
+ *CreateRange(FirstEphemeralRangeOf(selection)), 10); |
+ |
+ EXPECT_EQ("abc def ghi", surrounding_text.Content().SimplifyWhiteSpace()); |
+ EXPECT_EQ(4u, surrounding_text.StartOffsetInContent()); |
+ EXPECT_EQ(7u, surrounding_text.EndOffsetInContent()); |
+} |
+ |
} // namespace blink |