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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
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 "core/editing/VisibleSelection.h" 5 #include "core/editing/VisibleSelection.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/editing/SelectionAdjuster.h" 9 #include "core/editing/SelectionAdjuster.h"
10 10
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_EQ(0u, range->endOffset()); 213 EXPECT_EQ(0u, range->endOffset());
214 EXPECT_EQ("", range->text()); 214 EXPECT_EQ("", range->text());
215 testFlatTreePositionsToEqualToDOMTreePositions(selection, 215 testFlatTreePositionsToEqualToDOMTreePositions(selection,
216 selectionInFlatTree); 216 selectionInFlatTree);
217 217
218 const VisibleSelection noSelection = 218 const VisibleSelection noSelection =
219 createVisibleSelection(SelectionInDOMTree::Builder().build()); 219 createVisibleSelection(SelectionInDOMTree::Builder().build());
220 EXPECT_EQ(NoSelection, noSelection.getSelectionType()); 220 EXPECT_EQ(NoSelection, noSelection.getSelectionType());
221 } 221 }
222 222
223 // For http://crbug.com/695317
224 TEST_F(VisibleSelectionTest, SelectAllWithInputElement) {
225 setBodyContent("<input>123");
226 Element* const htmlElement = document().documentElement();
227 Element* const input = document().querySelector("input");
228 Node* const lastChild = document().body()->lastChild();
229
230 const VisibleSelection& visibleSelectinInDOMTree = createVisibleSelection(
231 SelectionInDOMTree::Builder()
232 .collapse(Position::firstPositionInNode(htmlElement))
233 .extend(Position::lastPositionInNode(htmlElement))
234 .build());
235 EXPECT_EQ(SelectionInDOMTree::Builder()
236 .collapse(Position::beforeNode(input))
237 .extend(Position(lastChild, 3))
238 .build(),
239 visibleSelectinInDOMTree.asSelection());
240
241 const VisibleSelectionInFlatTree& visibleSelectinInFlatTree =
242 createVisibleSelection(
243 SelectionInFlatTree::Builder()
244 .collapse(PositionInFlatTree::firstPositionInNode(htmlElement))
245 .extend(PositionInFlatTree::lastPositionInNode(htmlElement))
246 .build());
247 EXPECT_EQ(SelectionInFlatTree::Builder()
248 .collapse(PositionInFlatTree::beforeNode(input))
249 .extend(PositionInFlatTree(lastChild, 3))
250 .build(),
251 visibleSelectinInFlatTree.asSelection());
252 }
253
223 TEST_F(VisibleSelectionTest, ShadowCrossing) { 254 TEST_F(VisibleSelectionTest, ShadowCrossing) {
224 const char* bodyContent = 255 const char* bodyContent =
225 "<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>"; 256 "<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>";
226 const char* shadowContent = 257 const char* shadowContent =
227 "<a><span id='s4'>44</span><content select=#two></content><span " 258 "<a><span id='s4'>44</span><content select=#two></content><span "
228 "id='s5'>55</span><content select=#one></content><span " 259 "id='s5'>55</span><content select=#one></content><span "
229 "id='s6'>66</span></a>"; 260 "id='s6'>66</span></a>";
230 setBodyContent(bodyContent); 261 setBodyContent(bodyContent);
231 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 262 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
232 263
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 Element* host = document().getElementById("host"); 508 Element* host = document().getElementById("host");
478 host->appendChild(sample); 509 host->appendChild(sample);
479 document().updateStyleAndLayout(); 510 document().updateStyleAndLayout();
480 511
481 // Simulates to restore selection from undo stack. 512 // Simulates to restore selection from undo stack.
482 selection = createVisibleSelection(selection.asSelection()); 513 selection = createVisibleSelection(selection.asSelection());
483 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); 514 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
484 } 515 }
485 516
486 } // namespace blink 517 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698