summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--third_party/WebKit/Source/core/editing/EditingTestBase.cpp4
-rw-r--r--third_party/WebKit/Source/core/editing/EditingTestBase.h2
-rw-r--r--third_party/WebKit/Source/core/editing/StyledMarkupSerializerTest.cpp25
3 files changed, 28 insertions, 3 deletions
diff --git a/third_party/WebKit/Source/core/editing/EditingTestBase.cpp b/third_party/WebKit/Source/core/editing/EditingTestBase.cpp
index 16226f7..6b25128 100644
--- a/third_party/WebKit/Source/core/editing/EditingTestBase.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingTestBase.cpp
@@ -44,9 +44,9 @@ void EditingTestBase::setBodyContent(const char* bodyContent)
document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXCEPTION);
}
-PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::setShadowContent(const char* shadowContent)
+PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::setShadowContent(const char* shadowContent, const char* host)
{
- RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithIDAndSetInnerHTML(document(), host, shadowContent);
document().recalcDistribution();
return shadowRoot.release();
}
diff --git a/third_party/WebKit/Source/core/editing/EditingTestBase.h b/third_party/WebKit/Source/core/editing/EditingTestBase.h
index 0a7266a..ab4be06 100644
--- a/third_party/WebKit/Source/core/editing/EditingTestBase.h
+++ b/third_party/WebKit/Source/core/editing/EditingTestBase.h
@@ -26,7 +26,7 @@ protected:
static PassRefPtrWillBeRawPtr<ShadowRoot> createShadowRootForElementWithIDAndSetInnerHTML(TreeScope&, const char* hostElementID, const char* shadowRootContent);
void setBodyContent(const char*);
- PassRefPtrWillBeRawPtr<ShadowRoot> setShadowContent(const char*);
+ PassRefPtrWillBeRawPtr<ShadowRoot> setShadowContent(const char* shadowContent, const char* host = "host");
void updateLayoutAndStyleForPainting();
static Position positionInDOMTree(Node& anchor, int offset);
diff --git a/third_party/WebKit/Source/core/editing/StyledMarkupSerializerTest.cpp b/third_party/WebKit/Source/core/editing/StyledMarkupSerializerTest.cpp
index 15dfabd..553b764 100644
--- a/third_party/WebKit/Source/core/editing/StyledMarkupSerializerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/StyledMarkupSerializerTest.cpp
@@ -192,4 +192,29 @@ TEST_F(StyledMarkupSerializerTest, ShadowTreeStyle)
EXPECT_EQ(serializedDOM, serializedICT);
}
+TEST_F(StyledMarkupSerializerTest, AcrossShadow)
+{
+ const char* bodyContent = "<p id='host1'>[<span id='one'>11</span>]</p><p id='host2'>[<span id='two'>22</span>]</p>";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
+ RefPtrWillBeRawPtr<Element> two = document().getElementById("two");
+ Position startDOM(toText(one->firstChild()), 0);
+ Position endDOM(toText(two->firstChild()), 2);
+ const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM, endDOM, AnnotateForInterchange);
+
+ bodyContent = "<p id='host1'><span id='one'>11</span></p><p id='host2'><span id='two'>22</span></p>";
+ const char* shadowContent1 = "[<content select=#one></content>]";
+ const char* shadowContent2 = "[<content select=#two></content>]";
+ setBodyContent(bodyContent);
+ setShadowContent(shadowContent1, "host1");
+ setShadowContent(shadowContent2, "host2");
+ one = document().getElementById("one");
+ two = document().getElementById("two");
+ PositionInComposedTree startICT(toText(one->firstChild()), 0);
+ PositionInComposedTree endICT(toText(two->firstChild()), 2);
+ const std::string& serializedICT = serializePart<EditingInComposedTreeStrategy>(startICT, endICT, AnnotateForInterchange);
+
+ EXPECT_EQ(serializedDOM, serializedICT);
+}
+
} // namespace blink