| 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 820361524d7ec7d7b3b2654f36d96020d1046710..8d762b26265ad6ee75b9247b6b8f7aa0507ec1b9 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleSelectionTest.cpp
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "core/dom/Range.h"
|
| #include "core/editing/EditingTestBase.h"
|
| +#include "core/editing/SelectionAdjuster.h"
|
|
|
| #define LOREM_IPSUM \
|
| "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor " \
|
| @@ -350,4 +351,29 @@ TEST_F(VisibleSelectionTest, WordGranularity)
|
| }
|
| }
|
|
|
| +// This is for crbug.com/627783, simulating restoring selection
|
| +// in undo stack.
|
| +TEST_F(VisibleSelectionTest, validatePositionsIfNeededWithShadowHost)
|
| +{
|
| + setBodyContent("<div id=host></div><div id=sample>foo</div>");
|
| + setShadowContent("<content>", "host");
|
| + Element* sample = document().getElementById("sample");
|
| +
|
| + // Simulates saving selection in undo stack.
|
| + VisibleSelection selection(Position(sample->firstChild(), 0));
|
| + EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
|
| +
|
| + // Simulates modifying DOM tree to invalidate distribution.
|
| + Element* host = document().getElementById("host");
|
| + host->appendChild(sample);
|
| +
|
| + // Simulates to restore selection from undo stack.
|
| + selection.validatePositionsIfNeeded();
|
| + EXPECT_EQ(Position(sample->firstChild(), 0), selection.start());
|
| +
|
| + VisibleSelectionInFlatTree selectionInFlatTree;
|
| + SelectionAdjuster::adjustSelectionInFlatTree(&selectionInFlatTree, selection);
|
| + EXPECT_EQ(PositionInFlatTree(sample->firstChild(), 0), selectionInFlatTree.start());
|
| +}
|
| +
|
| } // namespace blink
|
|
|