Title: [141198] trunk
Revision
141198
Author
[email protected]
Date
2013-01-29 18:17:15 -0800 (Tue, 29 Jan 2013)

Log Message

parserAppendChild and parserInsertBefore should ensure that child nodes are in the same document
https://bugs.webkit.org/show_bug.cgi?id=108260

Reviewed by Eric Seidel.

Source/WebCore:

Test: fast/parser/xml-error-adopted.xml

The check and adoption if the documents don't match is now moved into ContainerNode::parser* from HTMLConstructionSite.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::parserAppendChild):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertTextNode):
(WebCore::HTMLConstructionSite::findFosterSite):
(WebCore::HTMLConstructionSite::fosterParent):

LayoutTests:

* fast/parser/xml-error-adopted-expected.txt: Added.
* fast/parser/xml-error-adopted.xml: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141197 => 141198)


--- trunk/LayoutTests/ChangeLog	2013-01-30 02:11:05 UTC (rev 141197)
+++ trunk/LayoutTests/ChangeLog	2013-01-30 02:17:15 UTC (rev 141198)
@@ -1,3 +1,13 @@
+2013-01-29  Rafael Weinstein  <[email protected]>
+
+        parserAppendChild and parserInsertBefore should ensure that child nodes are in the same document
+        https://bugs.webkit.org/show_bug.cgi?id=108260
+
+        Reviewed by Eric Seidel.
+
+        * fast/parser/xml-error-adopted-expected.txt: Added.
+        * fast/parser/xml-error-adopted.xml: Added.
+
 2013-01-29  Kent Tamura  <[email protected]>
 
         INPUT_MULTIPLE_FIELDS_UI: The content should not overflow the <input> boundary

Added: trunk/LayoutTests/fast/parser/xml-error-adopted-expected.txt (0 => 141198)


--- trunk/LayoutTests/fast/parser/xml-error-adopted-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/parser/xml-error-adopted-expected.txt	2013-01-30 02:17:15 UTC (rev 141198)
@@ -0,0 +1,2 @@
+ALERT: PASS
+

Added: trunk/LayoutTests/fast/parser/xml-error-adopted.xml (0 => 141198)


--- trunk/LayoutTests/fast/parser/xml-error-adopted.xml	                        (rev 0)
+++ trunk/LayoutTests/fast/parser/xml-error-adopted.xml	2013-01-30 02:17:15 UTC (rev 141198)
@@ -0,0 +1,21 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml">
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+</script>
+
+<xhtml:iframe src="" (top.body = top.document.body) document.implementation.createHTMLDocument().adoptNode(top.body)"/>
+
+<script>
+function test() {
+    alert(body.ownerDocument === body.firstChild.ownerDocument ? 'PASS' : 'FAIL');
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+setTimeout(test, 0);
+</script>
+<elt attr="1" attr="2"/>
+</svg>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (141197 => 141198)


--- trunk/Source/WebCore/ChangeLog	2013-01-30 02:11:05 UTC (rev 141197)
+++ trunk/Source/WebCore/ChangeLog	2013-01-30 02:17:15 UTC (rev 141198)
@@ -1,3 +1,22 @@
+2013-01-29  Rafael Weinstein  <[email protected]>
+
+        parserAppendChild and parserInsertBefore should ensure that child nodes are in the same document
+        https://bugs.webkit.org/show_bug.cgi?id=108260
+
+        Reviewed by Eric Seidel.
+
+        Test: fast/parser/xml-error-adopted.xml
+
+        The check and adoption if the documents don't match is now moved into ContainerNode::parser* from HTMLConstructionSite.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::parserInsertBefore):
+        (WebCore::ContainerNode::parserAppendChild):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertTextNode):
+        (WebCore::HTMLConstructionSite::findFosterSite):
+        (WebCore::HTMLConstructionSite::fosterParent):
+
 2013-01-29  Shinya Kawanaka  <[email protected]>
 
         [Chromium] Cannot copy text when selecting readonly (or disabled) input elements

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (141197 => 141198)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2013-01-30 02:11:05 UTC (rev 141197)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2013-01-30 02:17:15 UTC (rev 141198)
@@ -329,11 +329,13 @@
     ASSERT(nextChild);
     ASSERT(nextChild->parentNode() == this);
     ASSERT(!newChild->isDocumentFragment());
-    ASSERT_WITH_SECURITY_IMPLICATION(document() == newChild->document());
 
     if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do
         return;
 
+    if (document() != newChild->document())
+        document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
+
     insertBeforeCommon(nextChild, newChild.get());
 
     newChild->updateAncestorConnectedSubframeCountForInsertion();
@@ -695,8 +697,10 @@
     ASSERT(newChild);
     ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events).
     ASSERT(!newChild->isDocumentFragment());
-    ASSERT_WITH_SECURITY_IMPLICATION(document() == newChild->document());
 
+    if (document() != newChild->document())
+        document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
+
     Node* last = m_lastChild;
     {
         NoEventDispatchAssertion assertNoEventDispatch;

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (141197 => 141198)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-01-30 02:11:05 UTC (rev 141197)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-01-30 02:17:15 UTC (rev 141198)
@@ -504,9 +504,6 @@
         ASSERT(currentPosition <= characters.length());
         task.child = textNode.release();
 
-        if (task.parent->document() != task.child->document())
-            task.parent->document()->adoptNode(task.child, ASSERT_NO_EXCEPTION);
-
         executeTask(task);
     }
 }
@@ -607,7 +604,7 @@
     // When a node is to be foster parented, the last template element with no table element is below it in the stack of open elements is the foster parent element (NOT the template's parent!)
     HTMLElementStack::ElementRecord* lastTemplateElement = m_openElements.topmost(templateTag.localName());
     if (lastTemplateElement && !m_openElements.inTableScope(tableTag)) {
-        task.parent = toHTMLTemplateElement(lastTemplateElement->element())->content();
+        task.parent = lastTemplateElement->element();
         return;
     }
 
@@ -645,9 +642,6 @@
     task.child = node;
     ASSERT(task.parent);
 
-    if (task.parent->document() != task.child->document())
-        task.parent->document()->adoptNode(task.child, ASSERT_NO_EXCEPTION);
-
     m_attachmentQueue.append(task);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to