<!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>[185769] 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/185769">185769</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2015-06-19 14:55:55 -0700 (Fri, 19 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Various assertion failures occur when executing script in the midst of DOM insertion
https://bugs.webkit.org/show_bug.cgi?id=132482

Reviewed by Darin Adler.

Source/WebCore:

Prior to this change, when an element containing a &lt;script&gt; child was inserted into a document, the script was
executed in ScriptElement::insertedInto(). That script can access nodes that follow it in the newly-inserted
hierarchy but are not yet fully inserted, leading to at least the following problems:

    - The script could remove a node that is not yet marked as in the document.
    - The script could remove a named &lt;map&gt; that has yet to be added to TreeScope::m_imageMapsByName.
    - The script could remove a form control that has yet to be added to FormController::m_formElementsWithState.

These scenarios all result in assertion failures. This change ensures that each node in the newly-inserted
hierarchy is fully inserted before executing any scripts.

Tests: fast/dom/element-removed-while-inserting-parent-crash.html
       fast/dom/named-map-removed-while-inserting-parent-crash.html
       fast/forms/form-control-removed-while-inserting-parent-crash.html
       svg/dom/element-removed-while-inserting-parent-crash.html

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::shouldNotifySubtreeInsertions): Renamed from insertedInto().
Returned true in the case where insertedInto() would've called prepareScript().
(WebCore::ScriptElement::didNotifySubtreeInsertions): Called prepareScript().
(WebCore::ScriptElement::insertedInto): Renamed to shouldNotifySubtreeInsertions().
* dom/ScriptElement.h:
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::insertedInto): If shouldNotifySubtreeInsertions() is true, returned InsertionShouldCallDidNotifySubtreeInsertions.
Otherwise, returned InsertionDone.
(WebCore::HTMLScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
* html/HTMLScriptElement.h:
* svg/SVGScriptElement.cpp:
(WebCore::SVGScriptElement::insertedInto): Did the same as HTMLScriptElement::insertedInto().
(WebCore::SVGScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
* svg/SVGScriptElement.h:

LayoutTests:

Wrote named-map-removed-while-inserting-parent-crash.html by reducing the test case attached to bug 132482.
The remaining tests were taken from blink <a href="http://trac.webkit.org/projects/webkit/changeset/132482">r132482</a>.

* fast/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
* fast/dom/element-removed-while-inserting-parent-crash.html: Added.
* fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt: Added.
* fast/dom/named-map-removed-while-inserting-parent-crash.html: Added.
* fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt: Added.
* fast/forms/form-control-removed-while-inserting-parent-crash.html: Added.
* svg/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
* svg/dom/element-removed-while-inserting-parent-crash.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="#trunkSourceWebCoredomScriptElementcpp">trunk/Source/WebCore/dom/ScriptElement.cpp</a></li>
<li><a href="#trunkSourceWebCoredomScriptElementh">trunk/Source/WebCore/dom/ScriptElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLScriptElementcpp">trunk/Source/WebCore/html/HTMLScriptElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLScriptElementh">trunk/Source/WebCore/html/HTMLScriptElement.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGScriptElementcpp">trunk/Source/WebCore/svg/SVGScriptElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGScriptElementh">trunk/Source/WebCore/svg/SVGScriptElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomelementremovedwhileinsertingparentcrashexpectedtxt">trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomelementremovedwhileinsertingparentcrashhtml">trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#trunkLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashexpectedtxt">trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashhtml">trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#trunkLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashexpectedtxt">trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashhtml">trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html</a></li>
<li><a href="#trunkLayoutTestssvgdomelementremovedwhileinsertingparentcrashexpectedtxt">trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgdomelementremovedwhileinsertingparentcrashhtml">trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/LayoutTests/ChangeLog        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-06-19  Andy Estes  &lt;aestes@apple.com&gt;
+
+        Various assertion failures occur when executing script in the midst of DOM insertion
+        https://bugs.webkit.org/show_bug.cgi?id=132482
+
+        Reviewed by Darin Adler.
+
+        Wrote named-map-removed-while-inserting-parent-crash.html by reducing the test case attached to bug 132482.
+        The remaining tests were taken from blink r132482.
+
+        * fast/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/dom/element-removed-while-inserting-parent-crash.html: Added.
+        * fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/dom/named-map-removed-while-inserting-parent-crash.html: Added.
+        * fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt: Added.
+        * fast/forms/form-control-removed-while-inserting-parent-crash.html: Added.
+        * svg/dom/element-removed-while-inserting-parent-crash-expected.txt: Added.
+        * svg/dom/element-removed-while-inserting-parent-crash.html: Added.
+
</ins><span class="cx"> 2015-06-19  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove the useless LayoutTests/platform/wincairo/TestExpectations file
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomelementremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash-expected.txt        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomelementremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var element = document.createElement();
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.nextSibling.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(element);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash-expected.txt        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnamedmapremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/named-map-removed-while-inserting-parent-crash.html        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+
+&lt;!-- Ensures that TreeScope::m_imageMapsByName is created --&gt;
+&lt;map name&gt;&lt;/map&gt;
+
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var map = document.createElement('map');
+map.name = 'map';
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.parentNode.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(map);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash-expected.txt        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsformcontrolremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/form-control-removed-while-inserting-parent-crash.html        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var input = document.createElement('input');
+
+var script = document.createElement('script');
+script.textContent = 'document.currentScript.parentNode.remove()';
+
+var container = document.createElement('div');
+container.appendChild(script);
+container.appendChild(input);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgdomelementremovedwhileinsertingparentcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash-expected.txt        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestssvgdomelementremovedwhileinsertingparentcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html (0 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html                                (rev 0)
+++ trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var element = document.createElementNS('http://www.w3.org/2000/svg');
+
+var script = document.createElementNS('http://www.w3.org/2000/svg', 'script');
+script.id = 'script';
+script.textContent = 'document.getElementById(\'script\').nextSibling.remove()'; // document.currentScript doesn't work for SVGScriptElement.
+
+var container = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+container.appendChild(script);
+container.appendChild(element);
+
+document.body.appendChild(container);
+document.body.innerHTML = 'PASS';
+&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 (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/ChangeLog        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2015-06-19  Andy Estes  &lt;aestes@apple.com&gt;
+
+        Various assertion failures occur when executing script in the midst of DOM insertion
+        https://bugs.webkit.org/show_bug.cgi?id=132482
+
+        Reviewed by Darin Adler.
+
+        Prior to this change, when an element containing a &lt;script&gt; child was inserted into a document, the script was
+        executed in ScriptElement::insertedInto(). That script can access nodes that follow it in the newly-inserted
+        hierarchy but are not yet fully inserted, leading to at least the following problems:
+
+            - The script could remove a node that is not yet marked as in the document.
+            - The script could remove a named &lt;map&gt; that has yet to be added to TreeScope::m_imageMapsByName.
+            - The script could remove a form control that has yet to be added to FormController::m_formElementsWithState.
+
+        These scenarios all result in assertion failures. This change ensures that each node in the newly-inserted
+        hierarchy is fully inserted before executing any scripts.
+
+        Tests: fast/dom/element-removed-while-inserting-parent-crash.html
+               fast/dom/named-map-removed-while-inserting-parent-crash.html
+               fast/forms/form-control-removed-while-inserting-parent-crash.html
+               svg/dom/element-removed-while-inserting-parent-crash.html
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::shouldNotifySubtreeInsertions): Renamed from insertedInto().
+        Returned true in the case where insertedInto() would've called prepareScript().
+        (WebCore::ScriptElement::didNotifySubtreeInsertions): Called prepareScript().
+        (WebCore::ScriptElement::insertedInto): Renamed to shouldNotifySubtreeInsertions().
+        * dom/ScriptElement.h:
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::insertedInto): If shouldNotifySubtreeInsertions() is true, returned InsertionShouldCallDidNotifySubtreeInsertions.
+        Otherwise, returned InsertionDone.
+        (WebCore::HTMLScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
+        * html/HTMLScriptElement.h:
+        * svg/SVGScriptElement.cpp:
+        (WebCore::SVGScriptElement::insertedInto): Did the same as HTMLScriptElement::insertedInto().
+        (WebCore::SVGScriptElement::didNotifySubtreeInsertions): Called ScriptElement::didNotifySubtreeInsertions().
+        * svg/SVGScriptElement.h:
+
</ins><span class="cx"> 2015-06-19  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         All calls of ImageBuffer::create should null check the return value
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.cpp        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -79,12 +79,17 @@
</span><span class="cx">     stopLoadRequest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptElement::insertedInto(ContainerNode&amp; insertionPoint)
</del><ins>+bool ScriptElement::shouldNotifySubtreeInsertions(ContainerNode&amp; insertionPoint)
</ins><span class="cx"> {
</span><del>-    if (insertionPoint.inDocument() &amp;&amp; !m_parserInserted)
-        prepareScript(); // FIXME: Provide a real starting line number here.
</del><ins>+    return insertionPoint.inDocument() &amp;&amp; !m_parserInserted;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ScriptElement::didNotifySubtreeInsertions()
+{
+    ASSERT(!m_parserInserted);
+    prepareScript(); // FIXME: Provide a real starting line number here.
+}
+
</ins><span class="cx"> void ScriptElement::childrenChanged()
</span><span class="cx"> {
</span><span class="cx">     if (!m_parserInserted &amp;&amp; m_element.inDocument())
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.h (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.h        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/dom/ScriptElement.h        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -69,7 +69,8 @@
</span><span class="cx">     bool forceAsync() const { return m_forceAsync; }
</span><span class="cx"> 
</span><span class="cx">     // Helper functions used by our parent classes.
</span><del>-    void insertedInto(ContainerNode&amp;);
</del><ins>+    bool shouldNotifySubtreeInsertions(ContainerNode&amp;);
+    void didNotifySubtreeInsertions();
</ins><span class="cx">     void childrenChanged();
</span><span class="cx">     void handleSourceAttribute(const String&amp; sourceUrl);
</span><span class="cx">     void handleAsyncAttribute();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLScriptElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLScriptElement.cpp (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLScriptElement.cpp        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/html/HTMLScriptElement.cpp        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -70,10 +70,14 @@
</span><span class="cx"> Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode&amp; insertionPoint)
</span><span class="cx"> {
</span><span class="cx">     HTMLElement::insertedInto(insertionPoint);
</span><del>-    ScriptElement::insertedInto(insertionPoint);
-    return InsertionDone;
</del><ins>+    return shouldNotifySubtreeInsertions(insertionPoint) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLScriptElement::didNotifySubtreeInsertions()
+{
+    ScriptElement::didNotifySubtreeInsertions();
+}
+
</ins><span class="cx"> void HTMLScriptElement::setText(const String &amp;value)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLScriptElement&gt; protectFromMutationEvents(*this);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLScriptElement.h (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLScriptElement.h        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/html/HTMLScriptElement.h        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><ins>+    virtual void didNotifySubtreeInsertions() override;
</ins><span class="cx">     virtual void childrenChanged(const ChildChange&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual bool isURLAttribute(const Attribute&amp;) const override;
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGScriptElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGScriptElement.cpp (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGScriptElement.cpp        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/svg/SVGScriptElement.cpp        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -77,12 +77,16 @@
</span><span class="cx"> Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode&amp; rootParent)
</span><span class="cx"> {
</span><span class="cx">     SVGElement::insertedInto(rootParent);
</span><del>-    ScriptElement::insertedInto(rootParent);
</del><span class="cx">     if (rootParent.inDocument())
</span><span class="cx">         SVGExternalResourcesRequired::insertedIntoDocument(this);
</span><del>-    return InsertionDone;
</del><ins>+    return shouldNotifySubtreeInsertions(rootParent) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SVGScriptElement::didNotifySubtreeInsertions()
+{
+    ScriptElement::didNotifySubtreeInsertions();
+}
+
</ins><span class="cx"> void SVGScriptElement::childrenChanged(const ChildChange&amp; change)
</span><span class="cx"> {
</span><span class="cx">     SVGElement::childrenChanged(change);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGScriptElement.h (185768 => 185769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGScriptElement.h        2015-06-19 21:17:54 UTC (rev 185768)
+++ trunk/Source/WebCore/svg/SVGScriptElement.h        2015-06-19 21:55:55 UTC (rev 185769)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void parseAttribute(const QualifiedName&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><ins>+    virtual void didNotifySubtreeInsertions() override;
</ins><span class="cx">     virtual void childrenChanged(const ChildChange&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual void svgAttributeChanged(const QualifiedName&amp;) override;
</span></span></pre>
</div>
</div>

</body>
</html>