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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 2850443002: Stop flat tree selection canonicalization from using invalid positions (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Position.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 Selection().SetSelectedRange( 322 Selection().SetSelectedRange(
323 EphemeralRange(Position(text, 0), Position(text, 12)), 323 EphemeralRange(Position(text, 0), Position(text, 12)),
324 VP_DEFAULT_AFFINITY, SelectionDirectionalMode::kNonDirectional, 0); 324 VP_DEFAULT_AFFINITY, SelectionDirectionalMode::kNonDirectional, 0);
325 325
326 EXPECT_TRUE(Selection().IsHandleVisible()) 326 EXPECT_TRUE(Selection().IsHandleVisible())
327 << "If handles were present before" 327 << "If handles were present before"
328 "selectSetSelectedRange they should be present after it."; 328 "selectSetSelectedRange they should be present after it.";
329 } 329 }
330 330
331 // Regression test for crbug.com/702756
332 // Test case excerpted from editing/undo/redo_correct_selection.html
333 TEST_F(FrameSelectionTest, SelectInvalidPositionInFlatTreeDoesntCrash) {
334 SetBodyContent("foo<option><select></select></option>");
335 Element* body = GetDocument().body();
336 Element* select = GetDocument().QuerySelector("select");
337 Selection().SetSelection(SelectionInDOMTree::Builder()
338 .Collapse(Position(body, 0))
339 // SELECT@AfterAnchor is invalid in flat tree.
340 .Extend(Position::AfterNode(select))
341 .Build());
342 // The test passes if it doesn't crash inside.
343 Selection().ComputeVisibleSelectionInFlatTree();
yosin_UTC9 2017/04/27 07:02:28 nit: Let's have EXPECT_EQ() to compare expected Vi
Xiaocheng 2017/04/27 07:20:46 The expected selection in flat tree should be '|fo
344 }
345
331 } // namespace blink 346 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Position.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698