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

Unified Diff: Source/core/dom/PositionTest.cpp

Issue 1204203002: Bug fix: toPositionInComposedTree should treat positions with shadow roots (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/PositionTest.cpp
diff --git a/Source/core/dom/PositionTest.cpp b/Source/core/dom/PositionTest.cpp
index a78af36aecd35ea5bab98d13f1d22f435dd68053..b89ee79a27a71e48c1a0a09b9aeb0c3fb48f19b9 100644
--- a/Source/core/dom/PositionTest.cpp
+++ b/Source/core/dom/PositionTest.cpp
@@ -99,4 +99,39 @@ TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint)
EXPECT_EQ(PositionInComposedTree(anchor, PositionInComposedTree::PositionIsAfterChildren), toPositionInComposedTree(positionInDOMTree(*anchor, 1)));
}
+TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRoot)
+{
+ const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
+ const char* shadowContent = "<a><content select=#one></content></a>";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
+ RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
+
+ EXPECT_EQ(positionInComposedTree(*host, 0), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 0)));
+ EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAfterChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 1)));
+}
+
+TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRootContainingSingleContent)
+{
+ const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
+ const char* shadowContent = "<content select=#one></content>";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
+ RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
+
+ EXPECT_EQ(positionInComposedTree(*host, 0), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 0)));
+ EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAfterChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 1)));
+}
+
+TEST_F(PositionTest, ToPositionInComposedTreeWithEmptyShadowRoot)
+{
+ const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
+ const char* shadowContent = "";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
+ RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
+
+ EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAfterChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 0)));
+}
+
} // namespace blink
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698