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

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: Add expectation check 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 Node* foo = body->firstChild();
338 Selection().SetSelection(SelectionInDOMTree::Builder()
339 .Collapse(Position(body, 0))
340 // SELECT@AfterAnchor is invalid in flat tree.
341 .Extend(Position::AfterNode(select))
342 .Build());
343 // Should not crash inside.
344 const VisibleSelectionInFlatTree& selection =
345 Selection().ComputeVisibleSelectionInFlatTree();
346
347 // This only records the current behavior. It might be changed in the future.
348 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Base());
349 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Extent());
350 }
351
331 } // namespace blink 352 } // 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