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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp

Issue 2720593005: Make PositionIterator to skip contents of INPUT/SELECT/TEXTAREA (Closed)
Patch Set: 2017-03-02T19:03:48 Add FrameSelectionTest.SelectAllWithInputElement Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp b/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
index 0b2fe466b9269423061422419cbc6a2e733475ee..28b63331be1aaedb98814a88d620fcc804b51b65 100644
--- a/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
@@ -220,6 +220,37 @@ TEST_F(VisibleSelectionTest, Initialisation) {
EXPECT_EQ(NoSelection, noSelection.getSelectionType());
}
+// For http://crbug.com/695317
+TEST_F(VisibleSelectionTest, SelectAllWithInputElement) {
+ setBodyContent("<input>123");
+ Element* const htmlElement = document().documentElement();
+ Element* const input = document().querySelector("input");
+ Node* const lastChild = document().body()->lastChild();
+
+ const VisibleSelection& visibleSelectinInDOMTree = createVisibleSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(Position::firstPositionInNode(htmlElement))
+ .extend(Position::lastPositionInNode(htmlElement))
+ .build());
+ EXPECT_EQ(SelectionInDOMTree::Builder()
+ .collapse(Position::beforeNode(input))
+ .extend(Position(lastChild, 3))
+ .build(),
+ visibleSelectinInDOMTree.asSelection());
+
+ const VisibleSelectionInFlatTree& visibleSelectinInFlatTree =
+ createVisibleSelection(
+ SelectionInFlatTree::Builder()
+ .collapse(PositionInFlatTree::firstPositionInNode(htmlElement))
+ .extend(PositionInFlatTree::lastPositionInNode(htmlElement))
+ .build());
+ EXPECT_EQ(SelectionInFlatTree::Builder()
+ .collapse(PositionInFlatTree::beforeNode(input))
+ .extend(PositionInFlatTree(lastChild, 3))
+ .build(),
+ visibleSelectinInFlatTree.asSelection());
+}
+
TEST_F(VisibleSelectionTest, ShadowCrossing) {
const char* bodyContent =
"<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>";

Powered by Google App Engine
This is Rietveld 408576698