Title: [114481] trunk
Revision
114481
Author
morr...@google.com
Date
2012-04-17 21:52:47 -0700 (Tue, 17 Apr 2012)

Log Message

ShadowRoot shouldn't be adopted by any Document.
https://bugs.webkit.org/show_bug.cgi?id=84127

Reviewed by Dimitri Glazkov.

Source/WebCore:

ShadowRoot cannot cannot be removed from its host, which means
ShadowRoot cannot be adopted by any Document directly because the
adoptNode() tries to remove it from its parent but it doesn't make
sense for ShadowRoot.

This change adds a guard to check such a case.

Test: fast/dom/shadow/adopt-node-with-shadow-root.html

* dom/Document.cpp:
(WebCore::Document::adoptNode):

LayoutTests:

* fast/dom/shadow/adopt-node-with-shadow-root-expected.txt: Added.
* fast/dom/shadow/adopt-node-with-shadow-root.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114480 => 114481)


--- trunk/LayoutTests/ChangeLog	2012-04-18 04:40:44 UTC (rev 114480)
+++ trunk/LayoutTests/ChangeLog	2012-04-18 04:52:47 UTC (rev 114481)
@@ -1,3 +1,13 @@
+2012-04-17  MORITA Hajime  <morr...@google.com>
+
+        ShadowRoot shouldn't be adopted by any Document.
+        https://bugs.webkit.org/show_bug.cgi?id=84127
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/adopt-node-with-shadow-root-expected.txt: Added.
+        * fast/dom/shadow/adopt-node-with-shadow-root.html: Added.
+
 2012-04-17  Jer Noble  <jer.no...@apple.com>
 
         REGRESSION (r114406-r114417): media/video-playing-and-pause.html failing on Lion Release (WebKit2 Tests)

Added: trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root-expected.txt (0 => 114481)


--- trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root-expected.txt	2012-04-18 04:52:47 UTC (rev 114481)
@@ -0,0 +1,5 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS document.adoptNode(shadow) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+

Added: trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root.html (0 => 114481)


--- trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/adopt-node-with-shadow-root.html	2012-04-18 04:52:47 UTC (rev 114481)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="console"></div>
+<object data="" id="root" _onload_="test()"/>
+<script>
+function test() {
+    var foreignDocument = document.getElementById('root').contentDocument;
+    shadow = new WebKitShadowRoot(foreignDocument.getElementById('s'));
+    shouldThrow("document.adoptNode(shadow)");
+    location.reload();
+}
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (114480 => 114481)


--- trunk/Source/WebCore/ChangeLog	2012-04-18 04:40:44 UTC (rev 114480)
+++ trunk/Source/WebCore/ChangeLog	2012-04-18 04:52:47 UTC (rev 114481)
@@ -1,3 +1,22 @@
+2012-04-17  MORITA Hajime  <morr...@google.com>
+
+        ShadowRoot shouldn't be adopted by any Document.
+        https://bugs.webkit.org/show_bug.cgi?id=84127
+
+        Reviewed by Dimitri Glazkov.
+
+        ShadowRoot cannot cannot be removed from its host, which means
+        ShadowRoot cannot be adopted by any Document directly because the
+        adoptNode() tries to remove it from its parent but it doesn't make
+        sense for ShadowRoot.
+
+        This change adds a guard to check such a case.
+
+        Test: fast/dom/shadow/adopt-node-with-shadow-root.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::adoptNode):
+
 2012-04-17  John Bauman  <jbau...@chromium.org>
 
         [chromium] Ensure RateLimiter waits for Swapbuffers completion

Modified: trunk/Source/WebCore/dom/Document.cpp (114480 => 114481)


--- trunk/Source/WebCore/dom/Document.cpp	2012-04-18 04:40:44 UTC (rev 114480)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-04-18 04:52:47 UTC (rev 114481)
@@ -978,6 +978,12 @@
         break;
     }       
     default:
+        if (source->isShadowRoot()) {
+            // ShadowRoot cannot disconnect itself from the host node.
+            ec = HIERARCHY_REQUEST_ERR;
+            return 0;
+        }
+
         // FIXME: What about <frame> and <object>?
         if (source->hasTagName(iframeTag)) {
             HTMLIFrameElement* iframe = static_cast<HTMLIFrameElement*>(source.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to