Title: [88810] branches/chromium/742
Revision
88810
Author
[email protected]
Date
2011-06-14 09:32:50 -0700 (Tue, 14 Jun 2011)

Log Message

Merge 87863
BUG=82653
Review URL: http://codereview.chromium.org/7150014

Modified Paths

Added Paths

Diff

Copied: branches/chromium/742/LayoutTests/fast/dom/document-set-body-expected.txt (from rev 87863, trunk/LayoutTests/fast/dom/document-set-body-expected.txt) (0 => 88810)


--- branches/chromium/742/LayoutTests/fast/dom/document-set-body-expected.txt	                        (rev 0)
+++ branches/chromium/742/LayoutTests/fast/dom/document-set-body-expected.txt	2011-06-14 16:32:50 UTC (rev 88810)
@@ -0,0 +1,11 @@
+Tests setting document.body
+
+PASS document1.body = iframe1 threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS iframe1.parentNode is document.body
+PASS document1.body = document1.createElement('iframe') threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS document1.body != document.body is true
+PASS document1.body is body1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: branches/chromium/742/LayoutTests/fast/dom/document-set-body.html (from rev 87863, trunk/LayoutTests/fast/dom/document-set-body.html) (0 => 88810)


--- branches/chromium/742/LayoutTests/fast/dom/document-set-body.html	                        (rev 0)
+++ branches/chromium/742/LayoutTests/fast/dom/document-set-body.html	2011-06-14 16:32:50 UTC (rev 88810)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p>Tests setting document.body</p>
+<div id="console"></div>
+<script>
+iframe1 = document.createElement('iframe');
+document.body.appendChild(iframe1);
+document1 = iframe1.contentDocument.implementation.createHTMLDocument("document");
+
+shouldThrow("document1.body = iframe1", "'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'");
+shouldBe("iframe1.parentNode", "document.body");
+
+shouldThrow("document1.body = document1.createElement('iframe')", "'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'");
+
+document1.body = document.body;
+shouldBeTrue("document1.body != document.body");
+
+body1 = document1.createElement('body');
+document1.body = body1;
+shouldBe("document1.body", "body1")
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: branches/chromium/742/Source/WebCore/dom/Document.cpp (88809 => 88810)


--- branches/chromium/742/Source/WebCore/dom/Document.cpp	2011-06-14 16:29:17 UTC (rev 88809)
+++ branches/chromium/742/Source/WebCore/dom/Document.cpp	2011-06-14 16:32:50 UTC (rev 88810)
@@ -1966,11 +1966,21 @@
 
 void Document::setBody(PassRefPtr<HTMLElement> newBody, ExceptionCode& ec)
 {
-    if (!newBody || !documentElement()) { 
+    ec = 0;
+
+    if (!newBody || !documentElement() || !newBody->hasTagName(bodyTag)) { 
         ec = HIERARCHY_REQUEST_ERR;
         return;
     }
 
+    if (newBody->document() && newBody->document() != this) {
+        RefPtr<Node> node = importNode(newBody.get(), true, ec);
+        if (ec)
+            return;
+        
+        newBody = toHTMLElement(node.get());
+    }
+
     HTMLElement* b = body();
     if (!b)
         documentElement()->appendChild(newBody, ec);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to