<!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>[204217] 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/204217">204217</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-08-05 20:17:09 -0700 (Fri, 05 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Align Range.insertNode() input validation with the specification
https://bugs.webkit.org/show_bug.cgi?id=160624

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/dom/ranges/Range-insertNode-expected.txt:

Source/WebCore:

Align Range.insertNode() input validation with the specification:
- https://dom.spec.whatwg.org/#dom-range-insertnode
- https://dom.spec.whatwg.org/#concept-range-insert (step 1)

In particular, if range’s start node is a ProcessingInstruction or
Comment node, is a Text node whose parent is null, or is node, then
we should throw a HierarchyRequestError.

Chrome behaves according to the specification.

No new tests, rebaselined existing test.

* dom/Range.cpp:
(WebCore::Range::insertNode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomrangesRangeinsertNodeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-insertNode-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomRangecpp">trunk/Source/WebCore/dom/Range.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (204216 => 204217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-06 02:33:08 UTC (rev 204216)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-06 03:17:09 UTC (rev 204217)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2016-08-05  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Align Range.insertNode() input validation with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160624
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/ranges/Range-insertNode-expected.txt:
+
+2016-08-05  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Window's named properties should be exposed on a WindowProperties object in its prototype
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160354
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomrangesRangeinsertNodeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-insertNode-expected.txt (204216 => 204217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-insertNode-expected.txt        2016-08-06 02:33:08 UTC (rev 204216)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-insertNode-expected.txt        2016-08-06 03:17:09 UTC (rev 204217)
</span><span class="lines">@@ -3,11 +3,8 @@
</span><span class="cx"> 
</span><span class="cx"> PASS 0,0: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0] 
</span><span class="cx"> PASS 0,0: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0] 
</span><del>-FAIL 0,1: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 0,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 0,1: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild 
+PASS 0,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild 
</ins><span class="cx"> PASS 0,2: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[1].firstChild 
</span><span class="cx"> PASS 0,2: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[1].firstChild 
</span><span class="cx"> PASS 0,3: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node foreignPara1 
</span><span class="lines">@@ -50,11 +47,8 @@
</span><span class="cx"> PASS 0,21: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node foreignDoctype 
</span><span class="cx"> PASS 1,0: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0] 
</span><span class="cx"> PASS 1,0: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0] 
</span><del>-FAIL 1,1: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 1,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 1,1: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0].firstChild 
+PASS 1,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0].firstChild 
</ins><span class="cx"> PASS 1,2: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[1].firstChild 
</span><span class="cx"> PASS 1,2: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[1].firstChild 
</span><span class="cx"> PASS 1,3: resulting DOM for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node foreignPara1 
</span><span class="lines">@@ -97,11 +91,8 @@
</span><span class="cx"> PASS 1,21: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node foreignDoctype 
</span><span class="cx"> PASS 2,0: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0] 
</span><span class="cx"> PASS 2,0: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0] 
</span><del>-FAIL 2,1: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 2,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;Ä&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 2,1: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0].firstChild 
+PASS 2,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0].firstChild 
</ins><span class="cx"> PASS 2,2: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[1].firstChild 
</span><span class="cx"> PASS 2,2: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[1].firstChild 
</span><span class="cx"> PASS 2,3: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node foreignPara1 
</span><span class="lines">@@ -144,11 +135,8 @@
</span><span class="cx"> PASS 2,21: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node foreignDoctype 
</span><span class="cx"> PASS 3,0: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0] 
</span><span class="cx"> PASS 3,0: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0] 
</span><del>-FAIL 3,1: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 3,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;Ä&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 3,1: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0].firstChild 
+PASS 3,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0].firstChild 
</ins><span class="cx"> PASS 3,2: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[1].firstChild 
</span><span class="cx"> PASS 3,2: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[1].firstChild 
</span><span class="cx"> PASS 3,3: resulting DOM for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node foreignPara1 
</span><span class="lines">@@ -193,11 +181,8 @@
</span><span class="cx"> PASS 4,0: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[0] 
</span><span class="cx"> PASS 4,1: resulting DOM for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild 
</span><span class="cx"> PASS 4,1: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild 
</span><del>-FAIL 4,2: resulting DOM for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 4,2: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild assert_true: First differing node: expected Text node &quot;Ijklmnop
-&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 4,2: resulting DOM for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild 
+PASS 4,2: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild 
</ins><span class="cx"> PASS 4,3: resulting DOM for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node foreignPara1 
</span><span class="cx"> PASS 4,3: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node foreignPara1 
</span><span class="cx"> PASS 4,4: resulting DOM for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node foreignPara1.firstChild 
</span><span class="lines">@@ -240,11 +225,8 @@
</span><span class="cx"> PASS 5,0: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[0] 
</span><span class="cx"> PASS 5,1: resulting DOM for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[0].firstChild 
</span><span class="cx"> PASS 5,1: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[0].firstChild 
</span><del>-FAIL 5,2: resulting DOM for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[1].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 5,2: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[1].firstChild assert_true: First differing node: expected Text node &quot;Ijklmnop
-&quot;, got Text node &quot;Ij&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 5,2: resulting DOM for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[1].firstChild 
+PASS 5,2: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[1].firstChild 
</ins><span class="cx"> PASS 5,3: resulting DOM for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node foreignPara1 
</span><span class="cx"> PASS 5,3: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node foreignPara1 
</span><span class="cx"> PASS 5,4: resulting DOM for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node foreignPara1.firstChild 
</span><span class="lines">@@ -295,10 +277,8 @@
</span><span class="cx"> PASS 6,4: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node foreignPara1.firstChild 
</span><span class="cx"> PASS 6,5: resulting DOM for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1 
</span><span class="cx"> PASS 6,5: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1 
</span><del>-FAIL 6,6: resulting DOM for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 6,6: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild assert_true: First differing node: expected Text node &quot;Opqrstuv&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 6,6: resulting DOM for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild 
+PASS 6,6: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild 
</ins><span class="cx"> PASS 6,7: resulting DOM for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node document 
</span><span class="cx"> PASS 6,7: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node document 
</span><span class="cx"> PASS 6,8: resulting DOM for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedDiv 
</span><span class="lines">@@ -341,10 +321,8 @@
</span><span class="cx"> PASS 7,4: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node foreignPara1.firstChild 
</span><span class="cx"> PASS 7,5: resulting DOM for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1 
</span><span class="cx"> PASS 7,5: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1 
</span><del>-FAIL 7,6: resulting DOM for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1.firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 7,6: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1.firstChild assert_true: First differing node: expected Text node &quot;Opqrstuv&quot;, got Text node &quot;Op&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 7,6: resulting DOM for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1.firstChild 
+PASS 7,6: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1.firstChild 
</ins><span class="cx"> PASS 7,7: resulting DOM for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node document 
</span><span class="cx"> PASS 7,7: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node document 
</span><span class="cx"> PASS 7,8: resulting DOM for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedDiv 
</span><span class="lines">@@ -383,10 +361,8 @@
</span><span class="cx"> PASS 8,2: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node paras[1].firstChild 
</span><span class="cx"> PASS 8,3: resulting DOM for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1 
</span><span class="cx"> PASS 8,3: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1 
</span><del>-FAIL 8,4: resulting DOM for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 8,4: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild assert_true: First differing node: expected Text node &quot;Efghijkl&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 8,4: resulting DOM for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild 
+PASS 8,4: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild 
</ins><span class="cx"> PASS 8,5: resulting DOM for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node detachedPara1 
</span><span class="cx"> PASS 8,5: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node detachedPara1 
</span><span class="cx"> PASS 8,6: resulting DOM for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node detachedPara1.firstChild 
</span><span class="lines">@@ -429,10 +405,8 @@
</span><span class="cx"> PASS 9,2: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node paras[1].firstChild 
</span><span class="cx"> PASS 9,3: resulting DOM for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1 
</span><span class="cx"> PASS 9,3: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1 
</span><del>-FAIL 9,4: resulting DOM for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1.firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 9,4: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1.firstChild assert_true: First differing node: expected Text node &quot;Efghijkl&quot;, got Text node &quot;Ef&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 9,4: resulting DOM for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1.firstChild 
+PASS 9,4: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1.firstChild 
</ins><span class="cx"> PASS 9,5: resulting DOM for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node detachedPara1 
</span><span class="cx"> PASS 9,5: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node detachedPara1 
</span><span class="cx"> PASS 9,6: resulting DOM for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node detachedPara1.firstChild 
</span><span class="lines">@@ -821,11 +795,8 @@
</span><span class="cx"> PASS 17,21: resulting range position for range [detachedPara1, 0, detachedPara1, 1], node foreignDoctype 
</span><span class="cx"> PASS 18,0: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0] 
</span><span class="cx"> PASS 18,0: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0] 
</span><del>-FAIL 18,1: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 18,1: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 18,1: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild 
+PASS 18,1: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[0].firstChild 
</ins><span class="cx"> PASS 18,2: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild 
</span><span class="cx"> PASS 18,2: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild 
</span><span class="cx"> PASS 18,3: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node foreignPara1 
</span><span class="lines">@@ -868,11 +839,8 @@
</span><span class="cx"> PASS 18,21: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 0], node foreignDoctype 
</span><span class="cx"> PASS 19,0: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0] 
</span><span class="cx"> PASS 19,0: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0] 
</span><del>-FAIL 19,1: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 19,1: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 19,1: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0].firstChild 
+PASS 19,1: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[0].firstChild 
</ins><span class="cx"> PASS 19,2: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[1].firstChild 
</span><span class="cx"> PASS 19,2: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node paras[1].firstChild 
</span><span class="cx"> PASS 19,3: resulting DOM for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node foreignPara1 
</span><span class="lines">@@ -915,11 +883,8 @@
</span><span class="cx"> PASS 19,21: resulting range position for range [paras[0].firstChild, 0, paras[1].firstChild, 8], node foreignDoctype 
</span><span class="cx"> PASS 20,0: resulting DOM for range [paras[0].firstChild, 3, paras[3], 1], node paras[0] 
</span><span class="cx"> PASS 20,0: resulting range position for range [paras[0].firstChild, 3, paras[3], 1], node paras[0] 
</span><del>-FAIL 20,1: resulting DOM for range [paras[0].firstChild, 3, paras[3], 1], node paras[0].firstChild assert_throws: A HIERARCHY_REQUEST_ERR DOMException must be thrown in this case function &quot;function () {
-                try {
-                    a...&quot; did not throw
-FAIL 20,1: resulting range position for range [paras[0].firstChild, 3, paras[3], 1], node paras[0].firstChild assert_true: First differing node: expected Text node &quot;Äb̈c̈d̈ëf̈g̈ḧ
-&quot;, got Text node &quot;Äb&quot; [Actual and expected mismatch for range's tree root.  ] expected true got false
</del><ins>+PASS 20,1: resulting DOM for range [paras[0].firstChild, 3, paras[3], 1], node paras[0].firstChild 
+PASS 20,1: resulting range position for range [paras[0].firstChild, 3, paras[3], 1], node paras[0].firstChild 
</ins><span class="cx"> PASS 20,2: resulting DOM for range [paras[0].firstChild, 3, paras[3], 1], node paras[1].firstChild 
</span><span class="cx"> PASS 20,2: resulting range position for range [paras[0].firstChild, 3, paras[3], 1], node paras[1].firstChild 
</span><span class="cx"> PASS 20,3: resulting DOM for range [paras[0].firstChild, 3, paras[3], 1], node foreignPara1 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204216 => 204217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-06 02:33:08 UTC (rev 204216)
+++ trunk/Source/WebCore/ChangeLog        2016-08-06 03:17:09 UTC (rev 204217)
</span><span class="lines">@@ -1,5 +1,27 @@
</span><span class="cx"> 2016-08-05  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Align Range.insertNode() input validation with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160624
+
+        Reviewed by Sam Weinig.
+
+        Align Range.insertNode() input validation with the specification:
+        - https://dom.spec.whatwg.org/#dom-range-insertnode
+        - https://dom.spec.whatwg.org/#concept-range-insert (step 1)
+
+        In particular, if range’s start node is a ProcessingInstruction or
+        Comment node, is a Text node whose parent is null, or is node, then
+        we should throw a HierarchyRequestError.
+
+        Chrome behaves according to the specification.
+
+        No new tests, rebaselined existing test.
+
+        * dom/Range.cpp:
+        (WebCore::Range::insertNode):
+
+2016-08-05  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [Web IDL] Add support for 'any' type in dictionaries
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160511
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Range.cpp (204216 => 204217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Range.cpp        2016-08-06 02:33:08 UTC (rev 204216)
+++ trunk/Source/WebCore/dom/Range.cpp        2016-08-06 03:17:09 UTC (rev 204217)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ClientRect.h&quot;
</span><span class="cx"> #include &quot;ClientRectList.h&quot;
</span><ins>+#include &quot;Comment.h&quot;
</ins><span class="cx"> #include &quot;DocumentFragment.h&quot;
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="lines">@@ -814,12 +815,20 @@
</span><span class="cx"> 
</span><span class="cx"> void Range::insertNode(Ref&lt;Node&gt;&amp;&amp; node, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    bool startIsCharacterData = is&lt;CharacterData&gt;(startContainer());
-    if (startIsCharacterData &amp;&amp; !startContainer().parentNode()) {
</del><ins>+    if (is&lt;Comment&gt;(startContainer()) || is&lt;ProcessingInstruction&gt;(startContainer())) {
</ins><span class="cx">         ec = HIERARCHY_REQUEST_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    bool startIsText = startIsCharacterData &amp;&amp; startContainer().nodeType() == Node::TEXT_NODE;
</del><ins>+    bool startIsText = startContainer().nodeType() == Node::TEXT_NODE;
+    if (startIsText &amp;&amp; !startContainer().parentNode()) {
+        ec = HIERARCHY_REQUEST_ERR;
+        return;
+    }
+    if (node.ptr() == &amp;startContainer()) {
+        ec = HIERARCHY_REQUEST_ERR;
+        return;
+    }
+
</ins><span class="cx">     RefPtr&lt;Node&gt; referenceNode = startIsText ? &amp;startContainer() : startContainer().traverseToChildAt(startOffset());
</span><span class="cx">     Node* parentNode = referenceNode ? referenceNode-&gt;parentNode() : &amp;startContainer();
</span><span class="cx">     if (!is&lt;ContainerNode&gt;(parentNode)) {
</span></span></pre>
</div>
</div>

</body>
</html>