<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196998] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196998">196998</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-23 14:35:44 -0800 (Tue, 23 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Calling importNode on shadow root causes a crash
https://bugs.webkit.org/show_bug.cgi?id=154570

Reviewed by Anders Carlsson.

Source/WebCore:

The bug was caused by a missing check in cloneNode. Added cloneNodeForBindings to explicitly throw
an NotSupportedError when it's called on a shadow root. We don't clone shadow root when deep-cloning
the tree so we don't have to check that condition.

The behavior of cloneNode is specified at:
http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface
(it current says we should throw DATA_CLONE_ERR but I have an spec bug filed at
https://github.com/w3c/webcomponents/issues/393)

The behavior of importNode and adoptNode are specified in DOM4 specification:
https://dom.spec.whatwg.org/#dom-document-importnode
https://dom.spec.whatwg.org/#dom-document-adoptnode

Tests: fast/shadow-dom/Document-prototype-adoptNode.html
       fast/shadow-dom/Document-prototype-importNode.html
       fast/shadow-dom/Node-prototype-cloneNode.html

* dom/Document.cpp:
(WebCore::Document::importNode): Throw NotSupportedError when importing a shadow root.
* dom/Node.cpp:
(WebCore::Node::cloneNodeForBindings): Added.
* dom/Node.h:
* dom/Node.idl: Use cloneNodeForBindings here.

LayoutTests:

Added W3C-style testharness tests for calling cloneNode on a shadow root.

Also added tests for adoptNode and importNode.

* fast/shadow-dom/Document-prototype-adoptNode-expected.txt: Added.
* fast/shadow-dom/Document-prototype-adoptNode.html: Added.
* fast/shadow-dom/Document-prototype-importNode-expected.txt: Added.
* fast/shadow-dom/Document-prototype-importNode.html: Added.
* fast/shadow-dom/Node-prototype-cloneNode-expected.txt: Added.
* fast/shadow-dom/Node-prototype-cloneNode.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomNodecpp">trunk/Source/WebCore/dom/Node.cpp</a></li>
<li><a href="#trunkSourceWebCoredomNodeh">trunk/Source/WebCore/dom/Node.h</a></li>
<li><a href="#trunkSourceWebCoredomNodeidl">trunk/Source/WebCore/dom/Node.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodehtml">trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeimportNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeimportNodehtml">trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomNodeprototypecloneNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomNodeprototypecloneNodehtml">trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/LayoutTests/ChangeLog        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-02-22  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Calling importNode on shadow root causes a crash
+        https://bugs.webkit.org/show_bug.cgi?id=154570
+
+        Reviewed by Anders Carlsson.
+
+        Added W3C-style testharness tests for calling cloneNode on a shadow root.
+
+        Also added tests for adoptNode and importNode.
+
+        * fast/shadow-dom/Document-prototype-adoptNode-expected.txt: Added.
+        * fast/shadow-dom/Document-prototype-adoptNode.html: Added.
+        * fast/shadow-dom/Document-prototype-importNode-expected.txt: Added.
+        * fast/shadow-dom/Document-prototype-importNode.html: Added.
+        * fast/shadow-dom/Node-prototype-cloneNode-expected.txt: Added.
+        * fast/shadow-dom/Node-prototype-cloneNode.html: Added.
+
</ins><span class="cx"> 2016-02-23  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r196892): No longer emit error message when CSP form-action directive is used as a source expression
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS adoptNode on a shadow root in open mode must throw a HierarchyRequestError 
+PASS adoptNode on a shadow root in closed mode must throw a HierarchyRequestError 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;DOM and Shadow DOM: Document.prototype.adoptNode&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The adoptNode(node) method must throw a HierarchyRequestError exception if node is a shadow root.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-adoptnode&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testAdoptNode(mode) {
+    test(function () {
+        var newDocument = document.implementation.createHTMLDocument();
+        assert_throws({'name': 'HierarchyRequestError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            newDocument.adoptNode(shadowRoot);
+        });
+    }, 'adoptNode on a shadow root in ' + mode + ' mode must throw a HierarchyRequestError');
+}
+
+testAdoptNode('open');
+testAdoptNode('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeimportNodeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS importNode on a shadow root in open mode must throw a NotSupportedError 
+PASS importNode on a shadow root in closed mode must throw a NotSupportedError 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeimportNodehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;DOM and Shadow DOM: Document.prototype.importNode&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The importNode(node, deep) method must throw a NotSupportedError exception if node is a shadow root.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-importnode&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testImportNode(mode) {
+    test(function () {
+        var newDocument = document.implementation.createHTMLDocument();
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            newDocument.importNode(shadowRoot);
+        });
+    }, 'importNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+}
+
+testImportNode('open');
+testImportNode('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomNodeprototypecloneNodeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+
+PASS cloneNode on a shadow root in open mode must throw a NotSupportedError 
+PASS cloneNode on a shadow root in closed mode must throw a NotSupportedError 
+PASS cloneNode on an open shadow root must throw a NotSupportedError 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomNodeprototypecloneNodehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html (0 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Extensions to Node interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Invoking the cloneNode() method on a ShadowRoot instance must always throw a NotSupportedError.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testCloneNode(mode) {
+    test(function () {
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            shadowRoot.cloneNode(false);
+        }, 'cloneNode(false) on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            shadowRoot.cloneNode(false);
+        }, 'cloneNode(true) on a closed shadow root must throw a NotSupportedError');
+
+    }, 'cloneNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+}
+
+testCloneNode('open');
+testCloneNode('closed');
+
+test(function () {
+    var element = document.createElement('div');
+    var shadowRoot = element.attachShadow({mode: 'open'});
+
+    assert_equals(element.cloneNode(false).shadowRoot, null, 'cloneNode(false) on an open shadow host mode must clone its shadow root');
+    assert_equals(element.cloneNode(true).shadowRoot, null, 'cloneNode(true) on an open shadow host mode must clone its shadow root');
+}, 'cloneNode on an open shadow root must throw a NotSupportedError');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/Source/WebCore/ChangeLog        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-02-22  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Calling importNode on shadow root causes a crash
+        https://bugs.webkit.org/show_bug.cgi?id=154570
+
+        Reviewed by Anders Carlsson.
+
+        The bug was caused by a missing check in cloneNode. Added cloneNodeForBindings to explicitly throw
+        an NotSupportedError when it's called on a shadow root. We don't clone shadow root when deep-cloning
+        the tree so we don't have to check that condition.
+
+        The behavior of cloneNode is specified at:
+        http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface
+        (it current says we should throw DATA_CLONE_ERR but I have an spec bug filed at
+        https://github.com/w3c/webcomponents/issues/393)
+
+        The behavior of importNode and adoptNode are specified in DOM4 specification:
+        https://dom.spec.whatwg.org/#dom-document-importnode
+        https://dom.spec.whatwg.org/#dom-document-adoptnode
+
+        Tests: fast/shadow-dom/Document-prototype-adoptNode.html
+               fast/shadow-dom/Document-prototype-importNode.html
+               fast/shadow-dom/Node-prototype-cloneNode.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::importNode): Throw NotSupportedError when importing a shadow root.
+        * dom/Node.cpp:
+        (WebCore::Node::cloneNodeForBindings): Added.
+        * dom/Node.h:
+        * dom/Node.idl: Use cloneNodeForBindings here.
+
</ins><span class="cx"> 2016-02-23  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r196892): No longer emit error message when CSP form-action directive is used as a source expression
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -985,12 +985,15 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     switch (importedNode-&gt;nodeType()) {
</span><ins>+    case DOCUMENT_FRAGMENT_NODE:
+        if (importedNode-&gt;isShadowRoot())
+            break;
+        FALLTHROUGH;
</ins><span class="cx">     case ELEMENT_NODE:
</span><span class="cx">     case TEXT_NODE:
</span><span class="cx">     case CDATA_SECTION_NODE:
</span><span class="cx">     case PROCESSING_INSTRUCTION_NODE:
</span><span class="cx">     case COMMENT_NODE:
</span><del>-    case DOCUMENT_FRAGMENT_NODE:
</del><span class="cx">         return importedNode-&gt;cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf);
</span><span class="cx"> 
</span><span class="cx">     case ATTRIBUTE_NODE:
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.cpp (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.cpp        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/Source/WebCore/dom/Node.cpp        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -602,6 +602,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;Node&gt; Node::cloneNodeForBindings(bool deep, ExceptionCode&amp; ec)
+{
+    if (UNLIKELY(isShadowRoot())) {
+        ec = NOT_SUPPORTED_ERR;
+        return nullptr;
+    }
+    return cloneNode(deep);
+}
+
</ins><span class="cx"> const AtomicString&amp; Node::prefix() const
</span><span class="cx"> {
</span><span class="cx">     // For nodes other than elements and attributes, the prefix is always null
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.h (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.h        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/Source/WebCore/dom/Node.h        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx">     };
</span><span class="cx">     virtual Ref&lt;Node&gt; cloneNodeInternal(Document&amp;, CloningOperation) = 0;
</span><span class="cx">     Ref&lt;Node&gt; cloneNode(bool deep) { return cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf); }
</span><ins>+    RefPtr&lt;Node&gt; cloneNodeForBindings(bool deep, ExceptionCode&amp;);
</ins><span class="cx"> 
</span><span class="cx">     virtual const AtomicString&amp; localName() const;
</span><span class="cx">     virtual const AtomicString&amp; namespaceURI() const;
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.idl (196997 => 196998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.idl        2016-02-23 22:29:01 UTC (rev 196997)
+++ trunk/Source/WebCore/dom/Node.idl        2016-02-23 22:35:44 UTC (rev 196998)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx">     [Custom, RaisesException] Node appendChild([CustomReturn] Node newChild);
</span><span class="cx"> 
</span><span class="cx">     boolean            hasChildNodes();
</span><del>-    [NewObject] Node cloneNode([Default=Undefined] optional boolean deep);
</del><ins>+    [NewObject, RaisesException, ImplementedAs=cloneNodeForBindings] Node cloneNode([Default=Undefined] optional boolean deep);
</ins><span class="cx">     void               normalize();
</span><span class="cx"> 
</span><span class="cx">     // Introduced in DOM Level 2:
</span></span></pre>
</div>
</div>

</body>
</html>