| Index: third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp b/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..11a71b534e44ffe437de9119adb8e80fdc1f5979
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp
|
| @@ -0,0 +1,32 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/editing/RelocatablePosition.h"
|
| +
|
| +#include "core/editing/EditingTestBase.h"
|
| +#include "core/editing/VisiblePosition.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class RelocatablePositionTest : public EditingTestBase {
|
| +};
|
| +
|
| +TEST_F(RelocatablePositionTest, position)
|
| +{
|
| + setBodyContent("<b>foo</b><textarea>bar</textarea>");
|
| + Node* boldface = document().querySelector("b", ASSERT_NO_EXCEPTION);
|
| + Node* textarea = document().querySelector("textarea", ASSERT_NO_EXCEPTION);
|
| +
|
| + RelocatablePosition relocatablePosition(Position(textarea, PositionAnchorType::BeforeAnchor));
|
| + textarea->remove();
|
| +
|
| + // RelocatablePosition should track the given Position even if its original
|
| + // anchor node is moved away from the document.
|
| + Position expectedPosition(boldface, PositionAnchorType::AfterAnchor);
|
| + Position trackedPosition = relocatablePosition.position();
|
| + EXPECT_TRUE(trackedPosition.anchorNode()->inShadowIncludingDocument());
|
| + EXPECT_EQ(createVisiblePosition(expectedPosition).deepEquivalent(), createVisiblePosition(trackedPosition).deepEquivalent());
|
| +}
|
| +
|
| +} // namespace blink
|
|
|