Index: third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp |
index 2b1baab6ed0e4bf2e136f5b2b41d7e6268fd9dc3..d9f21d60b2a9c50ee18c24ca503419049dd39e55 100644 |
--- a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp |
@@ -36,4 +36,38 @@ TEST_F(VisiblePositionTest, ShadowV0DistributedNodes) |
EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), createVisiblePosition(PositionInFlatTree(two, 0)).deepEquivalent()); |
} |
+#if DCHECK_IS_ON() |
+ |
+TEST_F(VisiblePositionTest, NullIsValid) |
+{ |
+ EXPECT_TRUE(VisiblePosition().isValid()); |
+} |
+ |
+TEST_F(VisiblePositionTest, NonNullIsValidInCleanTree) |
+{ |
+ setBodyContent("<p>one</p>"); |
+ |
+ Element* paragraph = document().querySelector("p"); |
+ Position position(paragraph->firstChild(), 1); |
+ EXPECT_TRUE(createVisiblePosition(position).isValid()); |
+} |
+ |
+TEST_F(VisiblePositionTest, NonNullInvalidatedAfterMutation) |
+{ |
+ setBodyContent("<p>one</p>"); |
+ |
+ Element* paragraph = document().querySelector("p"); |
+ Position position(paragraph->firstChild(), 1); |
+ VisiblePosition nullVisiblePosition; |
+ VisiblePosition nonNullVisiblePosition = createVisiblePosition(position); |
+ |
+ Element* div = document().createElement("div", ASSERT_NO_EXCEPTION); |
+ document().body()->appendChild(div); |
+ |
+ EXPECT_TRUE(nullVisiblePosition.isValid()); |
+ EXPECT_FALSE(nonNullVisiblePosition.isValid()); |
+} |
+ |
+#endif |
yosin_UTC9
2016/09/20 13:55:51
Let's check "display" property change.
Not sure ab
Xiaocheng
2016/09/21 06:31:49
Done.
|
+ |
} // namespace blink |