<!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>[205581] trunk/Source/WebCore</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/205581">205581</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2016-09-07 18:49:49 -0700 (Wed, 07 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce abstract class LoadableScript for classic script and module graph
https://bugs.webkit.org/show_bug.cgi?id=161674

Reviewed by Ryosuke Niwa.

To prepare for ScriptModuleGraph, we introduce the abstract class over the classic script
and the module script, LoadableScript.

No behavior change.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/LoadableClassicScript.cpp: Added. LoadableClassicScript is the derived class from the
LoadableScript. In the module patch, we will introduce LoadableScriptModuleGraph which is also
the derived class from the LoadableScript. It is used for the external classic script.
A CachedResourceHandle used here alone does not prevent the underlying CachedResource from purging its
data buffer. This LoadableClassicScript holds a client until this class is destroyed in order to
guarantee that the data buffer will not be purged.
(WebCore::LoadableClassicScript::create):
(WebCore::LoadableClassicScript::LoadableClassicScript):
(WebCore::LoadableClassicScript::~LoadableClassicScript):
(WebCore::LoadableClassicScript::isLoaded):
(WebCore::LoadableClassicScript::wasErrored): Beyond the boolean value, this can return the detail
of the error. This detailed information will be used to report it to the inspector in the ScriptElement.
(WebCore::LoadableClassicScript::wasCanceled):
(WebCore::LoadableClassicScript::notifyFinished): Nosniff and cross-origin loading errors are handled here,
instead of exposing CachedScript*.
(WebCore::LoadableClassicScript::execute): Execute the cached script by using the given ScriptElement.
* dom/LoadableClassicScript.h: Copied from Source/WebCore/dom/PendingScript.h.
(isType):
* dom/LoadableScript.cpp: Copied from Source/WebCore/dom/ScriptRunner.h. New wrapper for CachedScript
and ScriptModuleGraph. We introduce a new wrapper to handle the above 2 things in the same way.
We take the way to introduce a new wrapper instead of introducing a new interface that is inherited by
CachedScript and ScriptModuleGraph. This is because ScriptModuleGraph is ref-counted while CachedScript
is managed by CachedResourceHandle. While this patch does not contain ScriptModuleGraph part, this
should be added in the module patch and at that time, this should be managed by this LoadableScript's
subclass. And we introduce TypeCasts traits for LoadableScript to allow `is&lt;&gt;` and `downcast&lt;&gt;`.
(WebCore::LoadableScript::addClient):
(WebCore::LoadableScript::removeClient):
(WebCore::LoadableScript::notifyClientFinished):
* dom/LoadableScript.h: Copied from Source/WebCore/dom/ScriptRunner.h.
(WebCore::LoadableScript::~LoadableScript):
(WebCore::LoadableScript::isClassicScript):
(WebCore::LoadableScript::isModuleGraph):
* dom/LoadableScriptClient.h: Copied from Source/WebCore/dom/ScriptRunner.h.
(WebCore::LoadableScriptClient::~LoadableScriptClient):
* dom/PendingScript.cpp: Use LoadableScript instead of CachedScript.
(WebCore::PendingScript::create):
(WebCore::PendingScript::PendingScript):
(WebCore::PendingScript::~PendingScript):
(WebCore::PendingScript::loadableScript):
(WebCore::PendingScript::notifyFinished):
(WebCore::PendingScript::isLoaded):
(WebCore::PendingScript::wasErrored):
(WebCore::PendingScript::cachedScript): Deleted.
* dom/PendingScript.h:
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::ScriptElement):
(WebCore::ScriptElement::handleSourceAttribute): Change sourceUrl to sourceURL to be consistent.
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::requestClassicScript): requestScript is renamed to requestClassicScript.
(WebCore::ScriptElement::requestScriptWithCache): Extract the code requesting the
CachedScript from requestScript. This will also be used by the module fetcher.
(WebCore::ScriptElement::executeScript): Now inspector error reporting is also done in this function.
When an error occurs, LoadableScript::wasErrored() returns the error which may include the information
to report the error to the inspector. nosniff and cross-origin loading errors are now detected by the
LoadableClassicScript and reported through this wasErrored().
(WebCore::ScriptElement::stopLoadRequest):
(WebCore::ScriptElement::executeScriptAndDispatchEvent):
(WebCore::ScriptElement::executeScriptForScriptRunner): Move the code from ScriptRunner. This function
calls removeClient(*this) because ScriptRunner is driven by the ScriptElement's notification. Only when using
ScriptRunner, we call addClient(*this) for ScriptElement. This is tricky, we should refactor this in the separated
bug (https://bugs.webkit.org/show_bug.cgi?id=161726).
(WebCore::ScriptElement::executeScriptForHTMLScriptRunner): Move the code from HTMLScriptRunner.
(WebCore::ScriptElement::notifyFinished):
(WebCore::ScriptElement::requestScript): Deleted.
(WebCore::ScriptElement::execute): Deleted.
* dom/ScriptElement.h:
(WebCore::ScriptElement::loadableScript):
(WebCore::ScriptElement::cachedScript): Deleted.
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::queueScriptForExecution):
(WebCore::ScriptRunner::timerFired): Use ScriptElement::executeScriptForScriptRunner.
* dom/ScriptRunner.h:
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
(WebCore::requestPendingScript):
(WebCore::HTMLScriptRunner::requestParsingBlockingScript):
(WebCore::HTMLScriptRunner::sourceFromPendingScript): Deleted.
* html/parser/HTMLScriptRunner.h: Use ScriptElement::executeScriptForHTMLScriptRunner.
* xml/parser/XMLDocumentParserLibxml2.cpp: Currently, we do nothing about XMLDocument in this patch.
We should support the module script, but before that, we should refactor this pending script handling.
(WebCore::XMLDocumentParser::endElementNs):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomPendingScriptcpp">trunk/Source/WebCore/dom/PendingScript.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPendingScripth">trunk/Source/WebCore/dom/PendingScript.h</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="#trunkSourceWebCoredomScriptRunnercpp">trunk/Source/WebCore/dom/ScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCoredomScriptRunnerh">trunk/Source/WebCore/dom/ScriptRunner.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLScriptRunnercpp">trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLScriptRunnerh">trunk/Source/WebCore/html/parser/HTMLScriptRunner.h</a></li>
<li><a href="#trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp">trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomLoadableClassicScriptcpp">trunk/Source/WebCore/dom/LoadableClassicScript.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLoadableClassicScripth">trunk/Source/WebCore/dom/LoadableClassicScript.h</a></li>
<li><a href="#trunkSourceWebCoredomLoadableScriptcpp">trunk/Source/WebCore/dom/LoadableScript.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLoadableScripth">trunk/Source/WebCore/dom/LoadableScript.h</a></li>
<li><a href="#trunkSourceWebCoredomLoadableScriptClienth">trunk/Source/WebCore/dom/LoadableScriptClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -1437,6 +1437,8 @@
</span><span class="cx">     dom/InlineStyleSheetOwner.cpp
</span><span class="cx">     dom/KeyboardEvent.cpp
</span><span class="cx">     dom/LiveNodeList.cpp
</span><ins>+    dom/LoadableClassicScript.cpp
+    dom/LoadableScript.cpp
</ins><span class="cx">     dom/MessageChannel.cpp
</span><span class="cx">     dom/MessageEvent.cpp
</span><span class="cx">     dom/MessagePort.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/ChangeLog        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -1,3 +1,99 @@
</span><ins>+2016-09-07  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Introduce abstract class LoadableScript for classic script and module graph
+        https://bugs.webkit.org/show_bug.cgi?id=161674
+
+        Reviewed by Ryosuke Niwa.
+
+        To prepare for ScriptModuleGraph, we introduce the abstract class over the classic script
+        and the module script, LoadableScript.
+
+        No behavior change.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/LoadableClassicScript.cpp: Added. LoadableClassicScript is the derived class from the
+        LoadableScript. In the module patch, we will introduce LoadableScriptModuleGraph which is also
+        the derived class from the LoadableScript. It is used for the external classic script.
+        A CachedResourceHandle used here alone does not prevent the underlying CachedResource from purging its
+        data buffer. This LoadableClassicScript holds a client until this class is destroyed in order to
+        guarantee that the data buffer will not be purged.
+        (WebCore::LoadableClassicScript::create):
+        (WebCore::LoadableClassicScript::LoadableClassicScript):
+        (WebCore::LoadableClassicScript::~LoadableClassicScript):
+        (WebCore::LoadableClassicScript::isLoaded):
+        (WebCore::LoadableClassicScript::wasErrored): Beyond the boolean value, this can return the detail
+        of the error. This detailed information will be used to report it to the inspector in the ScriptElement.
+        (WebCore::LoadableClassicScript::wasCanceled):
+        (WebCore::LoadableClassicScript::notifyFinished): Nosniff and cross-origin loading errors are handled here,
+        instead of exposing CachedScript*.
+        (WebCore::LoadableClassicScript::execute): Execute the cached script by using the given ScriptElement.
+        * dom/LoadableClassicScript.h: Copied from Source/WebCore/dom/PendingScript.h.
+        (isType):
+        * dom/LoadableScript.cpp: Copied from Source/WebCore/dom/ScriptRunner.h. New wrapper for CachedScript
+        and ScriptModuleGraph. We introduce a new wrapper to handle the above 2 things in the same way.
+        We take the way to introduce a new wrapper instead of introducing a new interface that is inherited by
+        CachedScript and ScriptModuleGraph. This is because ScriptModuleGraph is ref-counted while CachedScript
+        is managed by CachedResourceHandle. While this patch does not contain ScriptModuleGraph part, this
+        should be added in the module patch and at that time, this should be managed by this LoadableScript's
+        subclass. And we introduce TypeCasts traits for LoadableScript to allow `is&lt;&gt;` and `downcast&lt;&gt;`.
+        (WebCore::LoadableScript::addClient):
+        (WebCore::LoadableScript::removeClient):
+        (WebCore::LoadableScript::notifyClientFinished):
+        * dom/LoadableScript.h: Copied from Source/WebCore/dom/ScriptRunner.h.
+        (WebCore::LoadableScript::~LoadableScript):
+        (WebCore::LoadableScript::isClassicScript):
+        (WebCore::LoadableScript::isModuleGraph):
+        * dom/LoadableScriptClient.h: Copied from Source/WebCore/dom/ScriptRunner.h.
+        (WebCore::LoadableScriptClient::~LoadableScriptClient):
+        * dom/PendingScript.cpp: Use LoadableScript instead of CachedScript.
+        (WebCore::PendingScript::create):
+        (WebCore::PendingScript::PendingScript):
+        (WebCore::PendingScript::~PendingScript):
+        (WebCore::PendingScript::loadableScript):
+        (WebCore::PendingScript::notifyFinished):
+        (WebCore::PendingScript::isLoaded):
+        (WebCore::PendingScript::wasErrored):
+        (WebCore::PendingScript::cachedScript): Deleted.
+        * dom/PendingScript.h:
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::ScriptElement):
+        (WebCore::ScriptElement::handleSourceAttribute): Change sourceUrl to sourceURL to be consistent.
+        (WebCore::ScriptElement::prepareScript):
+        (WebCore::ScriptElement::requestClassicScript): requestScript is renamed to requestClassicScript.
+        (WebCore::ScriptElement::requestScriptWithCache): Extract the code requesting the
+        CachedScript from requestScript. This will also be used by the module fetcher.
+        (WebCore::ScriptElement::executeScript): Now inspector error reporting is also done in this function.
+        When an error occurs, LoadableScript::wasErrored() returns the error which may include the information
+        to report the error to the inspector. nosniff and cross-origin loading errors are now detected by the
+        LoadableClassicScript and reported through this wasErrored().
+        (WebCore::ScriptElement::stopLoadRequest):
+        (WebCore::ScriptElement::executeScriptAndDispatchEvent):
+        (WebCore::ScriptElement::executeScriptForScriptRunner): Move the code from ScriptRunner. This function
+        calls removeClient(*this) because ScriptRunner is driven by the ScriptElement's notification. Only when using
+        ScriptRunner, we call addClient(*this) for ScriptElement. This is tricky, we should refactor this in the separated
+        bug (https://bugs.webkit.org/show_bug.cgi?id=161726).
+        (WebCore::ScriptElement::executeScriptForHTMLScriptRunner): Move the code from HTMLScriptRunner.
+        (WebCore::ScriptElement::notifyFinished):
+        (WebCore::ScriptElement::requestScript): Deleted.
+        (WebCore::ScriptElement::execute): Deleted.
+        * dom/ScriptElement.h:
+        (WebCore::ScriptElement::loadableScript):
+        (WebCore::ScriptElement::cachedScript): Deleted.
+        * dom/ScriptRunner.cpp:
+        (WebCore::ScriptRunner::queueScriptForExecution):
+        (WebCore::ScriptRunner::timerFired): Use ScriptElement::executeScriptForScriptRunner.
+        * dom/ScriptRunner.h:
+        * html/parser/HTMLScriptRunner.cpp:
+        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
+        (WebCore::requestPendingScript):
+        (WebCore::HTMLScriptRunner::requestParsingBlockingScript):
+        (WebCore::HTMLScriptRunner::sourceFromPendingScript): Deleted.
+        * html/parser/HTMLScriptRunner.h: Use ScriptElement::executeScriptForHTMLScriptRunner.
+        * xml/parser/XMLDocumentParserLibxml2.cpp: Currently, we do nothing about XMLDocument in this patch.
+        We should support the module script, but before that, we should refactor this pending script handling.
+        (WebCore::XMLDocumentParser::endElementNs):
+
</ins><span class="cx"> 2016-09-07  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, revert r205533.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -6100,6 +6100,11 @@
</span><span class="cx">                 E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
</span><span class="cx">                 E38838981BAD145F00D62EE3 /* ScriptModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */; };
</span><span class="cx">                 E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */; };
</span><ins>+                E3B2F0EB1D7F4C9D00B0C9D1 /* LoadableClassicScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */; };
+                E3B2F0EC1D7F4CA100B0C9D1 /* LoadableScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */; };
+                E3B2F0ED1D7F4CA300B0C9D1 /* LoadableScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E71D7F35EC00B0C9D1 /* LoadableScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                E3B2F0EE1D7F4CA900B0C9D1 /* LoadableScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                E3B2F0F01D7F4CB500B0C9D1 /* LoadableClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
</span><span class="cx">                 E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E401E0A41C3C0B8300F34D10 /* StyleChange.h in Headers */ = {isa = PBXBuildFile; fileRef = E401E0A31C3C0B8300F34D10 /* StyleChange.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -13677,6 +13682,11 @@
</span><span class="cx">                 E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableClassicScript.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableClassicScript.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E3B2F0E71D7F35EC00B0C9D1 /* LoadableScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableScript.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableScriptClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableScript.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E401E0A31C3C0B8300F34D10 /* StyleChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleChange.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -23037,6 +23047,11 @@
</span><span class="cx">                                 14CF7C2009F7110600EB3665 /* KeyboardEvent.idl */,
</span><span class="cx">                                 BC7FA61E0D1F0CBD00DB22A9 /* LiveNodeList.cpp */,
</span><span class="cx">                                 BC7FA61F0D1F0CBD00DB22A9 /* LiveNodeList.h */,
</span><ins>+                                E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */,
+                                E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */,
+                                E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */,
+                                E3B2F0E71D7F35EC00B0C9D1 /* LoadableScript.h */,
+                                E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */,
</ins><span class="cx">                                 BC9A6144146859D9006057FD /* make_dom_exceptions.pl */,
</span><span class="cx">                                 BC9A6145146859D9006057FD /* make_event_factory.pl */,
</span><span class="cx">                                 BC9A6146146859D9006057FD /* make_names.pl */,
</span><span class="lines">@@ -24944,6 +24959,7 @@
</span><span class="cx">                                 C5137CF311A58378004ADB99 /* JSDOMStringList.h in Headers */,
</span><span class="cx">                                 BC64649811D82349006455B0 /* JSDOMStringMap.h in Headers */,
</span><span class="cx">                                 7694563D1214D97C0007CBAE /* JSDOMTokenList.h in Headers */,
</span><ins>+                                E3B2F0F01D7F4CB500B0C9D1 /* LoadableClassicScript.h in Headers */,
</ins><span class="cx">                                 2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */,
</span><span class="cx">                                 BC6932740D7E293900AE44D1 /* JSDOMWindowBase.h in Headers */,
</span><span class="cx">                                 652FBBBC0DE27CB60001D386 /* JSDOMWindowCustom.h in Headers */,
</span><span class="lines">@@ -25330,6 +25346,7 @@
</span><span class="cx">                                 B2FA3DF10AB75A6F000E5AC4 /* JSSVGRenderingIntent.h in Headers */,
</span><span class="cx">                                 B2FA3DF30AB75A6F000E5AC4 /* JSSVGScriptElement.h in Headers */,
</span><span class="cx">                                 B2FA3DF50AB75A6F000E5AC4 /* JSSVGSetElement.h in Headers */,
</span><ins>+                                E3B2F0EE1D7F4CA900B0C9D1 /* LoadableScriptClient.h in Headers */,
</ins><span class="cx">                                 B2FA3DF70AB75A6F000E5AC4 /* JSSVGStopElement.h in Headers */,
</span><span class="cx">                                 B2FA3DF90AB75A6F000E5AC4 /* JSSVGStringList.h in Headers */,
</span><span class="cx">                                 B2FA3DFB0AB75A6F000E5AC4 /* JSSVGStyleElement.h in Headers */,
</span><span class="lines">@@ -26941,6 +26958,7 @@
</span><span class="cx">                                 37F818FD0D657606005E1F05 /* WebCoreURLResponse.h in Headers */,
</span><span class="cx">                                 44A20DB90F84166C00B3E1FE /* WebCoreURLResponseIOS.h in Headers */,
</span><span class="cx">                                 93F199F008245E59001E9ABC /* WebCoreView.h in Headers */,
</span><ins>+                                E3B2F0ED1D7F4CA300B0C9D1 /* LoadableScript.h in Headers */,
</ins><span class="cx">                                 A5E616741894581F009ADF50 /* WebDebuggerAgent.h in Headers */,
</span><span class="cx">                                 FE0D84E910484348001A179E /* WebEvent.h in Headers */,
</span><span class="cx">                                 225A16B50D5C11E900090295 /* WebEventRegion.h in Headers */,
</span><span class="lines">@@ -27666,6 +27684,7 @@
</span><span class="cx">                                 43EDD67E1B485DBF00640E75 /* CombinedFiltersAlphabet.cpp in Sources */,
</span><span class="cx">                                 26E944D81AC4B2DD007B85B5 /* CombinedURLFilters.cpp in Sources */,
</span><span class="cx">                                 A584FE341864D5AF00843B10 /* CommandLineAPIHost.cpp in Sources */,
</span><ins>+                                E3B2F0EB1D7F4C9D00B0C9D1 /* LoadableClassicScript.cpp in Sources */,
</ins><span class="cx">                                 A584FE2B1863870F00843B10 /* CommandLineAPIModule.cpp in Sources */,
</span><span class="cx">                                 6550B6A1099DF0270090D781 /* Comment.cpp in Sources */,
</span><span class="cx">                                 E1FE137418402A6700892F13 /* CommonCryptoUtilities.cpp in Sources */,
</span><span class="lines">@@ -27764,6 +27783,7 @@
</span><span class="cx">                                 E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */,
</span><span class="cx">                                 BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */,
</span><span class="cx">                                 49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */,
</span><ins>+                                E3B2F0EC1D7F4CA100B0C9D1 /* LoadableScript.cpp in Sources */,
</ins><span class="cx">                                 BC604A430DB5634E00204739 /* CSSCanvasValue.cpp in Sources */,
</span><span class="cx">                                 E1EBBBD40AAC9B87001FE8E2 /* CSSCharsetRule.cpp in Sources */,
</span><span class="cx">                                 BCEA478F097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomLoadableClassicScriptcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/LoadableClassicScript.cpp (0 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableClassicScript.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/LoadableClassicScript.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -0,0 +1,115 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;LoadableClassicScript.h&quot;
+
+#include &quot;ScriptElement.h&quot;
+#include &quot;ScriptSourceCode.h&quot;
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/text/StringImpl.h&gt;
+
+namespace WebCore {
+
+Ref&lt;LoadableClassicScript&gt; LoadableClassicScript::create(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp; cachedScript, const String&amp; crossOriginMode, SecurityOrigin&amp; securityOrigin)
+{
+    ASSERT(cachedScript);
+    auto script = adoptRef(*new LoadableClassicScript(WTFMove(cachedScript), crossOriginMode, securityOrigin));
+    cachedScript-&gt;addClient(script.ptr());
+    return script;
+}
+
+LoadableClassicScript::LoadableClassicScript(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp; cachedScript, const String&amp; crossOriginMode, SecurityOrigin&amp; securityOrigin)
+    : m_cachedScript(cachedScript)
+    , m_securityOrigin(securityOrigin)
+    , m_requestUsesAccessControl(!crossOriginMode.isNull())
+{
+}
+
+LoadableClassicScript::~LoadableClassicScript()
+{
+    m_cachedScript-&gt;removeClient(this);
+}
+
+bool LoadableClassicScript::isLoaded() const
+{
+    return m_cachedScript-&gt;isLoaded();
+}
+
+Optional&lt;LoadableScript::Error&gt; LoadableClassicScript::wasErrored() const
+{
+    if (m_error)
+        return m_error;
+
+    if (m_cachedScript-&gt;errorOccurred())
+        return Error { ErrorType::CachedScript, Nullopt };
+
+    return Nullopt;
+}
+
+bool LoadableClassicScript::wasCanceled() const
+{
+    return m_cachedScript-&gt;wasCanceled();
+}
+
+void LoadableClassicScript::notifyFinished(CachedResource*)
+{
+    if (!m_error &amp;&amp; m_requestUsesAccessControl &amp;&amp; !m_cachedScript-&gt;passesSameOriginPolicyCheck(m_securityOrigin.get())) {
+        static NeverDestroyed&lt;String&gt; consoleMessage(ASCIILiteral(&quot;Cross-origin script load denied by Cross-Origin Resource Sharing policy.&quot;));
+        m_error = Error {
+            ErrorType::CrossOriginLoad,
+            ConsoleMessage {
+                MessageSource::JS,
+                MessageLevel::Error,
+                consoleMessage
+            }
+        };
+    }
+
+#if ENABLE(NOSNIFF)
+    if (!m_error &amp;&amp; !m_cachedScript-&gt;mimeTypeAllowedByNosniff()) {
+        m_error = Error {
+            ErrorType::Nosniff,
+            ConsoleMessage {
+                MessageSource::Security,
+                MessageLevel::Error,
+                makeString(
+                    &quot;Refused to execute script from '&quot;, m_cachedScript-&gt;url().stringCenterEllipsizedToLength()
+                    &quot;' because its MIME type ('&quot;, m_cachedScript-&gt;mimeType(), &quot;') is not executable, and strict MIME type checking is enabled.&quot;)
+            }
+        };
+    }
+#endif
+
+    notifyClientFinished();
+}
+
+void LoadableClassicScript::execute(ScriptElement&amp; scriptElement)
+{
+    ASSERT(!wasErrored());
+    scriptElement.executeScript(ScriptSourceCode(m_cachedScript.get()));
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableClassicScripthfromrev205580trunkSourceWebCoredomPendingScripth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/LoadableClassicScript.h (from rev 205580, trunk/Source/WebCore/dom/PendingScript.h) (0 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableClassicScript.h                                (rev 0)
+++ trunk/Source/WebCore/dom/LoadableClassicScript.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &quot;CachedResourceClient.h&quot;
+#include &quot;CachedResourceHandle.h&quot;
+#include &quot;CachedScript.h&quot;
+#include &quot;LoadableScript.h&quot;
+#include &quot;LoadableScriptClient.h&quot;
+#include &quot;SecurityOrigin.h&quot;
+#include &lt;wtf/TypeCasts.h&gt;
+
+namespace WebCore {
+
+// A CachedResourceHandle alone does not prevent the underlying CachedResource
+// from purging its data buffer. This class holds a client until this class is
+// destroyed in order to guarantee that the data buffer will not be purged.
+class LoadableClassicScript final : public LoadableScript, private CachedResourceClient {
+public:
+    ~LoadableClassicScript();
+
+    static Ref&lt;LoadableClassicScript&gt; create(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp;, const String&amp; crossOriginMode, SecurityOrigin&amp;);
+    bool isLoaded() const override;
+    Optional&lt;Error&gt; wasErrored() const override;
+    bool wasCanceled() const override;
+
+    CachedScript&amp; cachedScript() { return *m_cachedScript; }
+    bool isClassicScript() const final { return true; }
+
+    void execute(ScriptElement&amp;) override;
+
+private:
+    LoadableClassicScript(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp;, const String&amp; crossOriginMode, SecurityOrigin&amp;);
+
+    void notifyFinished(CachedResource*) override;
+
+    CachedResourceHandle&lt;CachedScript&gt; m_cachedScript;
+    Ref&lt;SecurityOrigin&gt; m_securityOrigin;
+    Optional&lt;Error&gt; m_error { Nullopt };
+    bool m_requestUsesAccessControl;
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LoadableClassicScript)
+    static bool isType(const WebCore::LoadableScript&amp; script) { return script.isClassicScript(); }
+SPECIALIZE_TYPE_TRAITS_END()
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableScriptcppfromrev205580trunkSourceWebCoredomScriptRunnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/LoadableScript.cpp (from rev 205580, trunk/Source/WebCore/dom/ScriptRunner.h) (0 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableScript.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/LoadableScript.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;LoadableScript.h&quot;
+
+#include &quot;LoadableScriptClient.h&quot;
+
+namespace WebCore {
+
+void LoadableScript::addClient(LoadableScriptClient&amp; client)
+{
+    m_clients.add(&amp;client);
+    if (isLoaded()) {
+        Ref&lt;LoadableScript&gt; protectedThis(*this);
+        client.notifyFinished(*this);
+    }
+}
+
+void LoadableScript::removeClient(LoadableScriptClient&amp; client)
+{
+    m_clients.remove(&amp;client);
+}
+
+void LoadableScript::notifyClientFinished()
+{
+    RefPtr&lt;LoadableScript&gt; protectedThis(this);
+
+    Vector&lt;LoadableScriptClient*&gt; vector;
+    for (auto&amp; pair : m_clients)
+        vector.append(pair.key);
+    for (auto&amp; client : vector)
+        client-&gt;notifyFinished(*this);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableScripthfromrev205580trunkSourceWebCoredomScriptRunnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/LoadableScript.h (from rev 205580, trunk/Source/WebCore/dom/ScriptRunner.h) (0 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableScript.h                                (rev 0)
+++ trunk/Source/WebCore/dom/LoadableScript.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;runtime/ConsoleTypes.h&gt;
+#include &lt;wtf/HashCountedSet.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WebCore {
+
+class LoadableScriptClient;
+class ScriptElement;
+
+class LoadableScript : public RefCounted&lt;LoadableScript&gt; {
+public:
+    enum class ErrorType {
+        CachedScript,
+        CrossOriginLoad,
+        Nosniff,
+    };
+
+    struct ConsoleMessage {
+        MessageSource source;
+        MessageLevel level;
+        String message;
+    };
+
+    struct Error {
+        ErrorType type;
+        Optional&lt;ConsoleMessage&gt; consoleMessage;
+    };
+
+    virtual ~LoadableScript() { }
+
+    virtual bool isLoaded() const = 0;
+    virtual Optional&lt;Error&gt; wasErrored() const = 0;
+    virtual bool wasCanceled() const = 0;
+
+    virtual void execute(ScriptElement&amp;) = 0;
+
+    void addClient(LoadableScriptClient&amp;);
+    void removeClient(LoadableScriptClient&amp;);
+
+    virtual bool isClassicScript() const { return false; }
+    virtual bool isModuleGraph() const { return false; }
+
+protected:
+    void notifyClientFinished();
+
+private:
+    HashCountedSet&lt;LoadableScriptClient*&gt; m_clients;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableScriptClienthfromrev205580trunkSourceWebCoredomScriptRunnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/LoadableScriptClient.h (from rev 205580, trunk/Source/WebCore/dom/ScriptRunner.h) (0 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableScriptClient.h                                (rev 0)
+++ trunk/Source/WebCore/dom/LoadableScriptClient.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+class LoadableScript;
+
+class LoadableScriptClient {
+public:
+    virtual ~LoadableScriptClient() { }
+
+    virtual void notifyFinished(LoadableScript&amp;) = 0;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomPendingScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/PendingScript.cpp (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/PendingScript.cpp        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/PendingScript.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -26,16 +26,15 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;PendingScript.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;CachedScript.h&quot;
</del><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;PendingScriptClient.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-Ref&lt;PendingScript&gt; PendingScript::create(Element&amp; element, CachedScript&amp; cachedScript)
</del><ins>+Ref&lt;PendingScript&gt; PendingScript::create(Element&amp; element, LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><del>-    Ref&lt;PendingScript&gt; pendingScript = adoptRef(*new PendingScript(element, cachedScript));
-    cachedScript.addClient(&amp;pendingScript.get());
</del><ins>+    Ref&lt;PendingScript&gt; pendingScript = adoptRef(*new PendingScript(element, loadableScript));
+    loadableScript.addClient(pendingScript.get());
</ins><span class="cx">     return pendingScript;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -50,21 +49,21 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PendingScript::PendingScript(Element&amp; element, CachedScript&amp; cachedScript)
</del><ins>+PendingScript::PendingScript(Element&amp; element, LoadableScript&amp; loadableScript)
</ins><span class="cx">     : m_element(element)
</span><del>-    , m_cachedScript(&amp;cachedScript)
</del><ins>+    , m_loadableScript(&amp;loadableScript)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PendingScript::~PendingScript()
</span><span class="cx"> {
</span><del>-    if (m_cachedScript)
-        m_cachedScript-&gt;removeClient(this);
</del><ins>+    if (m_loadableScript)
+        m_loadableScript-&gt;removeClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-CachedScript* PendingScript::cachedScript() const
</del><ins>+LoadableScript* PendingScript::loadableScript() const
</ins><span class="cx"> {
</span><del>-    return m_cachedScript.get();
</del><ins>+    return m_loadableScript.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PendingScript::notifyClientFinished()
</span><span class="lines">@@ -74,7 +73,7 @@
</span><span class="cx">         m_client-&gt;notifyFinished(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PendingScript::notifyFinished(CachedResource*)
</del><ins>+void PendingScript::notifyFinished(LoadableScript&amp;)
</ins><span class="cx"> {
</span><span class="cx">     notifyClientFinished();
</span><span class="cx"> }
</span><span class="lines">@@ -81,9 +80,14 @@
</span><span class="cx"> 
</span><span class="cx"> bool PendingScript::isLoaded() const
</span><span class="cx"> {
</span><del>-    return m_cachedScript &amp;&amp; m_cachedScript-&gt;isLoaded();
</del><ins>+    return m_loadableScript &amp;&amp; m_loadableScript-&gt;isLoaded();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PendingScript::wasErrored() const
+{
+    return m_loadableScript &amp;&amp; m_loadableScript-&gt;wasErrored();
+}
+
</ins><span class="cx"> void PendingScript::setClient(PendingScriptClient* client)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_client);
</span></span></pre></div>
<a id="trunkSourceWebCoredomPendingScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/PendingScript.h (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/PendingScript.h        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/PendingScript.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -25,8 +25,8 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include &quot;CachedResourceClient.h&quot;
-#include &quot;CachedResourceHandle.h&quot;
</del><ins>+#include &quot;LoadableScript.h&quot;
+#include &quot;LoadableScriptClient.h&quot;
</ins><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/text/TextPosition.h&gt;
</span><span class="lines">@@ -37,14 +37,11 @@
</span><span class="cx"> class Element;
</span><span class="cx"> class PendingScriptClient;
</span><span class="cx"> 
</span><del>-// A container for an external script which may be loaded and executed.
-//
-// A CachedResourceHandle alone does not prevent the underlying CachedResource
-// from purging its data buffer. This class holds a dummy client open for its
-// lifetime in order to guarantee that the data buffer will not be purged.
-class PendingScript final : public RefCounted&lt;PendingScript&gt;, public CachedResourceClient {
</del><ins>+// A container for scripts which may be loaded and executed.
+// This can hold LoadableScript and non external inline script.
+class PendingScript final : public RefCounted&lt;PendingScript&gt;, public LoadableScriptClient {
</ins><span class="cx"> public:
</span><del>-    static Ref&lt;PendingScript&gt; create(Element&amp;, CachedScript&amp;);
</del><ins>+    static Ref&lt;PendingScript&gt; create(Element&amp;, LoadableScript&amp;);
</ins><span class="cx">     static Ref&lt;PendingScript&gt; create(Element&amp;, TextPosition scriptStartPosition);
</span><span class="cx"> 
</span><span class="cx">     virtual ~PendingScript();
</span><span class="lines">@@ -57,18 +54,19 @@
</span><span class="cx">     Element&amp; element() { return m_element.get(); }
</span><span class="cx">     const Element&amp; element() const { return m_element.get(); }
</span><span class="cx"> 
</span><del>-    CachedScript* cachedScript() const;
-    bool needsLoading() const { return cachedScript(); }
</del><ins>+    LoadableScript* loadableScript() const;
+    bool needsLoading() const { return loadableScript(); }
</ins><span class="cx"> 
</span><span class="cx">     bool isLoaded() const;
</span><ins>+    bool wasErrored() const;
</ins><span class="cx"> 
</span><del>-    void notifyFinished(CachedResource*) override;
</del><ins>+    void notifyFinished(LoadableScript&amp;) override;
</ins><span class="cx"> 
</span><span class="cx">     void setClient(PendingScriptClient*);
</span><span class="cx">     void clearClient();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    PendingScript(Element&amp;, CachedScript&amp;);
</del><ins>+    PendingScript(Element&amp;, LoadableScript&amp;);
</ins><span class="cx">     PendingScript(Element&amp;, TextPosition startingPosition);
</span><span class="cx"> 
</span><span class="cx">     void notifyClientFinished();
</span><span class="lines">@@ -75,7 +73,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;Element&gt; m_element;
</span><span class="cx">     TextPosition m_startingPosition; // Only used for inline script tags.
</span><del>-    CachedResourceHandle&lt;CachedScript&gt; m_cachedScript;
</del><ins>+    RefPtr&lt;LoadableScript&gt; m_loadableScript;
</ins><span class="cx">     PendingScriptClient* m_client { nullptr };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.cpp        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -37,8 +37,10 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLParserIdioms.h&quot;
</span><span class="cx"> #include &quot;IgnoreDestructiveWriteCountIncrementer.h&quot;
</span><ins>+#include &quot;LoadableClassicScript.h&quot;
</ins><span class="cx"> #include &quot;MIMETypeRegistry.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><ins>+#include &quot;PendingScript.h&quot;
</ins><span class="cx"> #include &quot;SVGNames.h&quot;
</span><span class="cx"> #include &quot;SVGScriptElement.h&quot;
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><span class="lines">@@ -68,7 +70,6 @@
</span><span class="cx">     , m_willExecuteWhenDocumentFinishedParsing(false)
</span><span class="cx">     , m_forceAsync(!parserInserted)
</span><span class="cx">     , m_willExecuteInOrder(false)
</span><del>-    , m_requestUsesAccessControl(false)
</del><span class="cx"> {
</span><span class="cx">     if (parserInserted &amp;&amp; m_element.document().scriptableDocumentParser() &amp;&amp; !m_element.document().isInDocumentWrite())
</span><span class="cx">         m_startLineNumber = m_element.document().scriptableDocumentParser()-&gt;textPosition().m_line;
</span><span class="lines">@@ -96,9 +97,9 @@
</span><span class="cx">         prepareScript(); // FIXME: Provide a real starting line number here.
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptElement::handleSourceAttribute(const String&amp; sourceUrl)
</del><ins>+void ScriptElement::handleSourceAttribute(const String&amp; sourceURL)
</ins><span class="cx"> {
</span><del>-    if (ignoresLoadRequest() || sourceUrl.isEmpty())
</del><ins>+    if (ignoresLoadRequest() || sourceURL.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     prepareScript(); // FIXME: Provide a real starting line number here.
</span><span class="lines">@@ -227,9 +228,10 @@
</span><span class="cx">     else
</span><span class="cx">         m_characterEncoding = document.charset();
</span><span class="cx"> 
</span><del>-    if (hasSourceAttribute())
-        if (!requestScript(sourceAttributeValue()))
</del><ins>+    if (hasSourceAttribute()) {
+        if (!requestClassicScript(sourceAttributeValue()))
</ins><span class="cx">             return false;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     if (hasSourceAttribute() &amp;&amp; deferAttributeValue() &amp;&amp; m_parserInserted &amp;&amp; !asyncAttributeValue()) {
</span><span class="cx">         m_willExecuteWhenDocumentFinishedParsing = true;
</span><span class="lines">@@ -240,12 +242,14 @@
</span><span class="cx">         m_willBeParserExecuted = true;
</span><span class="cx">         m_readyToBeParserExecuted = true;
</span><span class="cx">     } else if (hasSourceAttribute() &amp;&amp; !asyncAttributeValue() &amp;&amp; !m_forceAsync) {
</span><ins>+        ASSERT(m_loadableScript);
</ins><span class="cx">         m_willExecuteInOrder = true;
</span><del>-        document.scriptRunner()-&gt;queueScriptForExecution(this, m_cachedScript, ScriptRunner::IN_ORDER_EXECUTION);
-        m_cachedScript-&gt;addClient(this);
</del><ins>+        document.scriptRunner()-&gt;queueScriptForExecution(this, *m_loadableScript, ScriptRunner::IN_ORDER_EXECUTION);
+        m_loadableScript-&gt;addClient(*this);
</ins><span class="cx">     } else if (hasSourceAttribute()) {
</span><del>-        m_element.document().scriptRunner()-&gt;queueScriptForExecution(this, m_cachedScript, ScriptRunner::ASYNC_EXECUTION);
-        m_cachedScript-&gt;addClient(this);
</del><ins>+        ASSERT(m_loadableScript);
+        m_element.document().scriptRunner()-&gt;queueScriptForExecution(this, *m_loadableScript, ScriptRunner::ASYNC_EXECUTION);
+        m_loadableScript-&gt;addClient(*this);
</ins><span class="cx">     } else {
</span><span class="cx">         // Reset line numbering for nested writes.
</span><span class="cx">         TextPosition position = document.isInDocumentWrite() ? TextPosition() : scriptStartPosition;
</span><span class="lines">@@ -255,39 +259,26 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ScriptElement::requestScript(const String&amp; sourceUrl)
</del><ins>+bool ScriptElement::requestClassicScript(const String&amp; sourceURL)
</ins><span class="cx"> {
</span><span class="cx">     Ref&lt;Document&gt; originalDocument(m_element.document());
</span><del>-    if (!m_element.dispatchBeforeLoadEvent(sourceUrl))
</del><ins>+    if (!m_element.dispatchBeforeLoadEvent(sourceURL))
</ins><span class="cx">         return false;
</span><del>-    if (!m_element.inDocument() || &amp;m_element.document() != originalDocument.ptr())
</del><ins>+    bool didEventListenerDisconnectThisElement = !m_element.inDocument() || &amp;m_element.document() != originalDocument.ptr();
+    if (didEventListenerDisconnectThisElement)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    ASSERT(!m_cachedScript);
-    if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
-        bool hasKnownNonce = m_element.document().contentSecurityPolicy()-&gt;allowScriptWithNonce(m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr), m_element.isInUserAgentShadowTree());
-        ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
-
-        CachedResourceRequest request(ResourceRequest(m_element.document().completeURL(sourceUrl)), options);
-
-        m_element.document().contentSecurityPolicy()-&gt;upgradeInsecureRequestIfNeeded(request.mutableResourceRequest(), ContentSecurityPolicy::InsecureRequestType::Load);
-
</del><ins>+    ASSERT(!m_loadableScript);
+    if (!stripLeadingAndTrailingHTMLSpaces(sourceURL).isEmpty()) {
</ins><span class="cx">         String crossOriginMode = m_element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr);
</span><del>-        if (!crossOriginMode.isNull()) {
-            m_requestUsesAccessControl = true;
-            StoredCredentials allowCredentials = equalLettersIgnoringASCIICase(crossOriginMode, &quot;use-credentials&quot;) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
-            ASSERT(m_element.document().securityOrigin());
-            updateRequestForAccessControl(request.mutableResourceRequest(), *m_element.document().securityOrigin(), allowCredentials);
</del><ins>+        auto request = requestScriptWithCache(m_element.document().completeURL(sourceURL), m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr), crossOriginMode);
+        if (request) {
+            m_loadableScript = LoadableClassicScript::create(WTFMove(request), crossOriginMode, *m_element.document().securityOrigin());
+            m_isExternalScript = true;
</ins><span class="cx">         }
</span><del>-        request.setCharset(scriptCharset());
-        request.setInitiator(&amp;element());
-
-        m_cachedScript = m_element.document().cachedResourceLoader().requestScript(request);
-        m_isExternalScript = true;
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_cachedScript)
</del><ins>+    if (m_loadableScript)
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     callOnMainThread([this, element = Ref&lt;Element&gt;(m_element)] {
</span><span class="lines">@@ -296,6 +287,28 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+CachedResourceHandle&lt;CachedScript&gt; ScriptElement::requestScriptWithCache(const URL&amp; sourceURL, const String&amp; nonceAttribute, const String&amp; crossOriginMode)
+{
+    bool hasKnownNonce = m_element.document().contentSecurityPolicy()-&gt;allowScriptWithNonce(nonceAttribute, m_element.isInUserAgentShadowTree());
+    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+    options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
+
+    CachedResourceRequest request(ResourceRequest(sourceURL), options);
+
+    m_element.document().contentSecurityPolicy()-&gt;upgradeInsecureRequestIfNeeded(request.mutableResourceRequest(), ContentSecurityPolicy::InsecureRequestType::Load);
+
+    if (!crossOriginMode.isNull()) {
+        StoredCredentials allowCredentials = equalLettersIgnoringASCIICase(crossOriginMode, &quot;use-credentials&quot;) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
+        ASSERT(m_element.document().securityOrigin());
+        updateRequestForAccessControl(request.mutableResourceRequest(), *m_element.document().securityOrigin(), allowCredentials);
+    }
+
+    request.setCharset(scriptCharset());
+    request.setInitiator(&amp;element());
+
+    return m_element.document().cachedResourceLoader().requestScript(request);
+}
+
</ins><span class="cx"> void ScriptElement::executeScript(const ScriptSourceCode&amp; sourceCode)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_alreadyStarted);
</span><span class="lines">@@ -311,13 +324,6 @@
</span><span class="cx">             return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if ENABLE(NOSNIFF)
-    if (m_isExternalScript &amp;&amp; m_cachedScript &amp;&amp; !m_cachedScript-&gt;mimeTypeAllowedByNosniff()) {
-        m_element.document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, &quot;Refused to execute script from '&quot; + m_cachedScript-&gt;url().stringCenterEllipsizedToLength() + &quot;' because its MIME type ('&quot; + m_cachedScript-&gt;mimeType() + &quot;') is not executable, and strict MIME type checking is enabled.&quot;);
-        return;
-    }
-#endif
-
</del><span class="cx">     Ref&lt;Document&gt; document(m_element.document());
</span><span class="cx">     if (Frame* frame = document-&gt;frame()) {
</span><span class="cx">         IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.ptr() : nullptr);
</span><span class="lines">@@ -332,51 +338,62 @@
</span><span class="cx"> 
</span><span class="cx"> void ScriptElement::stopLoadRequest()
</span><span class="cx"> {
</span><del>-    if (m_cachedScript) {
</del><ins>+    if (m_loadableScript) {
</ins><span class="cx">         if (!m_willBeParserExecuted)
</span><del>-            m_cachedScript-&gt;removeClient(this);
-        m_cachedScript = nullptr;
</del><ins>+            m_loadableScript-&gt;removeClient(*this);
+        m_loadableScript = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptElement::execute(CachedScript* cachedScript)
</del><ins>+void ScriptElement::executeScriptAndDispatchEvent(LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><del>-    ASSERT(!m_willBeParserExecuted);
-    ASSERT(cachedScript);
-    if (cachedScript-&gt;errorOccurred())
</del><ins>+    if (Optional&lt;LoadableScript::Error&gt; error = loadableScript.wasErrored()) {
+        if (Optional&lt;LoadableScript::ConsoleMessage&gt; message = error-&gt;consoleMessage)
+            m_element.document().addConsoleMessage(message-&gt;source, message-&gt;level, message-&gt;message);
</ins><span class="cx">         dispatchErrorEvent();
</span><del>-    else if (!cachedScript-&gt;wasCanceled()) {
-        executeScript(ScriptSourceCode(cachedScript));
</del><ins>+    } else if (!loadableScript.wasCanceled()) {
+        ASSERT(!loadableScript.wasErrored());
+        loadableScript.execute(*this);
</ins><span class="cx">         dispatchLoadEvent();
</span><span class="cx">     }
</span><del>-    cachedScript-&gt;removeClient(this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptElement::notifyFinished(CachedResource* resource)
</del><ins>+void ScriptElement::executeScriptForScriptRunner(LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_willBeParserExecuted);
</span><ins>+    executeScriptAndDispatchEvent(loadableScript);
+    loadableScript.removeClient(*this);
+}
</ins><span class="cx"> 
</span><del>-    // CachedResource possibly invokes this notifyFinished() more than
</del><ins>+void ScriptElement::executeScriptForHTMLScriptRunner(PendingScript&amp; pendingScript)
+{
+    IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(&amp;m_element.document());
+    if (auto* loadableScript = pendingScript.loadableScript())
+        executeScriptAndDispatchEvent(*loadableScript);
+    else {
+        ASSERT(!pendingScript.wasErrored());
+        executeScript(ScriptSourceCode(scriptContent(), m_element.document().url(), pendingScript.startingPosition()));
+        dispatchLoadEvent();
+    }
+}
+
+void ScriptElement::notifyFinished(LoadableScript&amp;)
+{
+    ASSERT(!m_willBeParserExecuted);
+
+    // LoadableScript possibly invokes this notifyFinished() more than
</ins><span class="cx">     // once because ScriptElement doesn't unsubscribe itself from
</span><del>-    // CachedResource here and does it in execute() instead.
-    // We use m_cachedScript to check if this function is already called.
-    ASSERT_UNUSED(resource, resource == m_cachedScript);
-    if (!m_cachedScript)
</del><ins>+    // LoadableScript here and does it in execute() instead.
+    // We use m_loadableScript to check if this function is already called.
+    if (!m_loadableScript)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_requestUsesAccessControl &amp;&amp; !m_cachedScript-&gt;passesSameOriginPolicyCheck(*m_element.document().securityOrigin())) {
-        dispatchErrorEvent();
-        static NeverDestroyed&lt;String&gt; consoleMessage(ASCIILiteral(&quot;Cross-origin script load denied by Cross-Origin Resource Sharing policy.&quot;));
-        m_element.document().addConsoleMessage(MessageSource::JS, MessageLevel::Error, consoleMessage);
-        return;
-    }
-
</del><span class="cx">     if (m_willExecuteInOrder)
</span><span class="cx">         m_element.document().scriptRunner()-&gt;notifyScriptReady(this, ScriptRunner::IN_ORDER_EXECUTION);
</span><span class="cx">     else
</span><span class="cx">         m_element.document().scriptRunner()-&gt;notifyScriptReady(this, ScriptRunner::ASYNC_EXECUTION);
</span><span class="cx"> 
</span><del>-    m_cachedScript = nullptr;
</del><ins>+    m_loadableScript = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ScriptElement::ignoresLoadRequest() const
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.h (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.h        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/ScriptElement.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -18,12 +18,14 @@
</span><span class="cx">  *
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef ScriptElement_h
-#define ScriptElement_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;CachedResourceClient.h&quot;
</span><span class="cx"> #include &quot;CachedResourceHandle.h&quot;
</span><ins>+#include &quot;LoadableScript.h&quot;
+#include &quot;LoadableScriptClient.h&quot;
</ins><span class="cx"> #include &quot;Timer.h&quot;
</span><ins>+#include &quot;URL.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/TextPosition.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -32,10 +34,11 @@
</span><span class="cx"> class CachedScript;
</span><span class="cx"> class ContainerNode;
</span><span class="cx"> class Element;
</span><ins>+class PendingScript;
</ins><span class="cx"> class ScriptElement;
</span><span class="cx"> class ScriptSourceCode;
</span><span class="cx"> 
</span><del>-class ScriptElement : private CachedResourceClient {
</del><ins>+class ScriptElement : private LoadableScriptClient {
</ins><span class="cx"> public:
</span><span class="cx">     virtual ~ScriptElement();
</span><span class="cx"> 
</span><span class="lines">@@ -48,8 +51,10 @@
</span><span class="cx">     String scriptCharset() const { return m_characterEncoding; }
</span><span class="cx">     WEBCORE_EXPORT String scriptContent() const;
</span><span class="cx">     void executeScript(const ScriptSourceCode&amp;);
</span><del>-    void execute(CachedScript*);
</del><span class="cx"> 
</span><ins>+    void executeScriptForScriptRunner(LoadableScript&amp;);
+    void executeScriptForHTMLScriptRunner(PendingScript&amp;);
+
</ins><span class="cx">     // XML parser calls these
</span><span class="cx">     virtual void dispatchLoadEvent() = 0;
</span><span class="cx">     void dispatchErrorEvent();
</span><span class="lines">@@ -58,7 +63,7 @@
</span><span class="cx">     bool willBeParserExecuted() const { return m_willBeParserExecuted; }
</span><span class="cx">     bool readyToBeParserExecuted() const { return m_readyToBeParserExecuted; }
</span><span class="cx">     bool willExecuteWhenDocumentFinishedParsing() const { return m_willExecuteWhenDocumentFinishedParsing; }
</span><del>-    CachedResourceHandle&lt;CachedScript&gt; cachedScript() { return m_cachedScript; }
</del><ins>+    LoadableScript* loadableScript() { return m_loadableScript.get(); }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     ScriptElement(Element&amp;, bool createdByParser, bool isEvaluated);
</span><span class="lines">@@ -72,10 +77,12 @@
</span><span class="cx">     bool shouldCallFinishedInsertingSubtree(ContainerNode&amp;);
</span><span class="cx">     void finishedInsertingSubtree();
</span><span class="cx">     void childrenChanged();
</span><del>-    void handleSourceAttribute(const String&amp; sourceUrl);
</del><ins>+    void handleSourceAttribute(const String&amp; sourceURL);
</ins><span class="cx">     void handleAsyncAttribute();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    void executeScriptAndDispatchEvent(LoadableScript&amp;);
+
</ins><span class="cx">     // https://html.spec.whatwg.org/multipage/scripting.html#concept-script-type
</span><span class="cx">     enum class ScriptType { Classic, Module };
</span><span class="cx">     Optional&lt;ScriptType&gt; determineScriptType(LegacyTypeSupport) const;
</span><span class="lines">@@ -82,10 +89,12 @@
</span><span class="cx">     bool ignoresLoadRequest() const;
</span><span class="cx">     bool isScriptForEventSupported() const;
</span><span class="cx"> 
</span><del>-    bool requestScript(const String&amp; sourceUrl);
</del><ins>+    CachedResourceHandle&lt;CachedScript&gt; requestScriptWithCache(const URL&amp;, const String&amp; nonceAttribute, const String&amp; crossoriginAttribute);
+
+    bool requestClassicScript(const String&amp; sourceURL);
</ins><span class="cx">     void stopLoadRequest();
</span><span class="cx"> 
</span><del>-    void notifyFinished(CachedResource*) override;
</del><ins>+    void notifyFinished(LoadableScript&amp;) override;
</ins><span class="cx"> 
</span><span class="cx">     virtual String sourceAttributeValue() const = 0;
</span><span class="cx">     virtual String charsetAttributeValue() const = 0;
</span><span class="lines">@@ -98,7 +107,6 @@
</span><span class="cx">     virtual bool hasSourceAttribute() const = 0;
</span><span class="cx"> 
</span><span class="cx">     Element&amp; m_element;
</span><del>-    CachedResourceHandle&lt;CachedScript&gt; m_cachedScript;
</del><span class="cx">     WTF::OrdinalNumber m_startLineNumber;
</span><span class="cx">     bool m_parserInserted : 1;
</span><span class="cx">     bool m_isExternalScript : 1;
</span><span class="lines">@@ -109,9 +117,9 @@
</span><span class="cx">     bool m_willExecuteWhenDocumentFinishedParsing : 1;
</span><span class="cx">     bool m_forceAsync : 1;
</span><span class="cx">     bool m_willExecuteInOrder : 1;
</span><del>-    bool m_requestUsesAccessControl : 1;
</del><span class="cx">     String m_characterEncoding;
</span><span class="cx">     String m_fallbackCharacterEncoding;
</span><ins>+    RefPtr&lt;LoadableScript&gt; m_loadableScript;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // FIXME: replace with downcast&lt;ScriptElement&gt;.
</span><span class="lines">@@ -118,5 +126,3 @@
</span><span class="cx"> ScriptElement* toScriptElementIfPossible(Element*);
</span><span class="cx"> 
</span><span class="cx"> }
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCoredomScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptRunner.cpp (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptRunner.cpp        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/ScriptRunner.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ScriptRunner.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;CachedScript.h&quot;
</del><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;PendingScript.h&quot;
</span><span class="cx"> #include &quot;ScriptElement.h&quot;
</span><span class="lines">@@ -49,10 +48,9 @@
</span><span class="cx">         m_document.decrementLoadEventDelayCount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, CachedResourceHandle&lt;CachedScript&gt; cachedScript, ExecutionType executionType)
</del><ins>+void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, LoadableScript&amp; loadableScript, ExecutionType executionType)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(scriptElement);
</span><del>-    ASSERT(cachedScript.get());
</del><span class="cx"> 
</span><span class="cx">     Element&amp; element = scriptElement-&gt;element();
</span><span class="cx">     ASSERT(element.inDocument());
</span><span class="lines">@@ -61,11 +59,11 @@
</span><span class="cx"> 
</span><span class="cx">     switch (executionType) {
</span><span class="cx">     case ASYNC_EXECUTION:
</span><del>-        m_pendingAsyncScripts.add(scriptElement, PendingScript::create(element, *cachedScript));
</del><ins>+        m_pendingAsyncScripts.add(scriptElement, PendingScript::create(element, loadableScript));
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case IN_ORDER_EXECUTION:
</span><del>-        m_scriptsToExecuteInOrder.append(PendingScript::create(element, *cachedScript));
</del><ins>+        m_scriptsToExecuteInOrder.append(PendingScript::create(element, loadableScript));
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -117,7 +115,8 @@
</span><span class="cx">             continue;
</span><span class="cx">         auto* scriptElement = toScriptElementIfPossible(&amp;script-&gt;element());
</span><span class="cx">         ASSERT(scriptElement);
</span><del>-        scriptElement-&gt;execute(script-&gt;cachedScript());
</del><ins>+        ASSERT(script-&gt;needsLoading());
+        scriptElement-&gt;executeScriptForScriptRunner(*script-&gt;loadableScript());
</ins><span class="cx">         m_document.decrementLoadEventDelayCount();
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptRunner.h (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptRunner.h        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/dom/ScriptRunner.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -23,10 +23,8 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef ScriptRunner_h
-#define ScriptRunner_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><del>-#include &quot;CachedResourceHandle.h&quot;
</del><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="lines">@@ -34,10 +32,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class CachedScript;
</del><span class="cx"> class Document;
</span><span class="cx"> class PendingScript;
</span><span class="cx"> class ScriptElement;
</span><ins>+class LoadableScript;
</ins><span class="cx"> 
</span><span class="cx"> class ScriptRunner {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(ScriptRunner); WTF_MAKE_FAST_ALLOCATED;
</span><span class="lines">@@ -46,7 +44,7 @@
</span><span class="cx">     ~ScriptRunner();
</span><span class="cx"> 
</span><span class="cx">     enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION };
</span><del>-    void queueScriptForExecution(ScriptElement*, CachedResourceHandle&lt;CachedScript&gt;, ExecutionType);
</del><ins>+    void queueScriptForExecution(ScriptElement*, LoadableScript&amp;, ExecutionType);
</ins><span class="cx">     bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty() || !m_scriptsToExecuteInOrder.isEmpty() || !m_pendingAsyncScripts.isEmpty(); }
</span><span class="cx">     void suspend();
</span><span class="cx">     void resume();
</span><span class="lines">@@ -63,5 +61,3 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;HTMLScriptRunner.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;CachedScript.h&quot;
-#include &quot;CachedResourceLoader.h&quot;
</del><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;EventNames.h&quot;
</span><span class="lines">@@ -89,17 +87,6 @@
</span><span class="cx">     return Event::create(eventNames().loadEvent, false, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ScriptSourceCode HTMLScriptRunner::sourceFromPendingScript(const PendingScript&amp; script, bool&amp; errorOccurred) const
-{
-    if (script.cachedScript()) {
-        errorOccurred = script.cachedScript()-&gt;errorOccurred();
-        ASSERT(script.cachedScript()-&gt;isLoaded());
-        return ScriptSourceCode(script.cachedScript());
-    }
-    errorOccurred = false;
-    return ScriptSourceCode(script.element().textContent(), documentURLForScriptExecution(m_document), script.startingPosition());
-}
-
</del><span class="cx"> bool HTMLScriptRunner::isPendingScriptReady(const PendingScript&amp; script)
</span><span class="cx"> {
</span><span class="cx">     if (!m_document)
</span><span class="lines">@@ -125,9 +112,6 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLScriptRunner::executePendingScriptAndDispatchEvent(RefPtr&lt;PendingScript&gt; pendingScript)
</span><span class="cx"> {
</span><del>-    bool errorOccurred = false;
-    ScriptSourceCode sourceCode = sourceFromPendingScript(*pendingScript, errorOccurred);
-
</del><span class="cx">     // Stop watching loads before executeScript to prevent recursion if the script reloads itself.
</span><span class="cx">     if (pendingScript-&gt;watchingForLoad())
</span><span class="cx">         stopWatchingForLoad(*pendingScript);
</span><span class="lines">@@ -137,14 +121,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (auto* scriptElement = toScriptElementIfPossible(&amp;pendingScript-&gt;element())) {
</span><span class="cx">         NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
</span><del>-        IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_document);
-        if (errorOccurred)
-            scriptElement-&gt;dispatchErrorEvent();
-        else {
-            ASSERT(isExecutingScript());
-            scriptElement-&gt;executeScript(sourceCode);
-            pendingScript-&gt;element().dispatchEvent(createScriptLoadEvent());
-        }
</del><ins>+        scriptElement-&gt;executeScriptForHTMLScriptRunner(*pendingScript);
</ins><span class="cx">     }
</span><span class="cx">     ASSERT(!isExecutingScript());
</span><span class="cx"> }
</span><span class="lines">@@ -236,8 +213,8 @@
</span><span class="cx"> {
</span><span class="cx">     auto&amp; scriptElement = *toScriptElementIfPossible(script);
</span><span class="cx">     ASSERT(scriptElement.willBeParserExecuted());
</span><del>-    ASSERT(scriptElement.cachedScript());
-    return PendingScript::create(*script, *scriptElement.cachedScript());
</del><ins>+    ASSERT(scriptElement.loadableScript());
+    return PendingScript::create(*script, *scriptElement.loadableScript());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLScriptRunner::requestParsingBlockingScript(Element* element)
</span><span class="lines">@@ -246,7 +223,7 @@
</span><span class="cx">     m_parserBlockingScript = requestPendingScript(element);
</span><span class="cx">     ASSERT(m_parserBlockingScript-&gt;needsLoading());
</span><span class="cx"> 
</span><del>-    // We only care about a load callback if cachedScript is not already
</del><ins>+    // We only care about a load callback if LoadableScript is not already
</ins><span class="cx">     // in the cache. Callers will attempt to run the m_parserBlockingScript
</span><span class="cx">     // if possible before returning control to the parser.
</span><span class="cx">     if (!m_parserBlockingScript-&gt;isLoaded())
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLScriptRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.h (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.h        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.h        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -32,8 +32,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class CachedResource;
-class CachedScript;
</del><span class="cx"> class Document;
</span><span class="cx"> class Element;
</span><span class="cx"> class Frame;
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (205580 => 205581)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2016-09-08 01:34:19 UTC (rev 205580)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2016-09-08 01:49:49 UTC (rev 205581)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLStyleElement.h&quot;
</span><span class="cx"> #include &quot;HTMLTemplateElement.h&quot;
</span><ins>+#include &quot;LoadableClassicScript.h&quot;
</ins><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;ProcessingInstruction.h&quot;
</span><span class="cx"> #include &quot;ResourceError.h&quot;
</span><span class="lines">@@ -920,8 +921,10 @@
</span><span class="cx"> 
</span><span class="cx">         if (scriptElement-&gt;readyToBeParserExecuted())
</span><span class="cx">             scriptElement-&gt;executeScript(ScriptSourceCode(scriptElement-&gt;scriptContent(), document()-&gt;url(), m_scriptStartPosition));
</span><del>-        else if (scriptElement-&gt;willBeParserExecuted()) {
-            m_pendingScript = scriptElement-&gt;cachedScript();
</del><ins>+        else if (scriptElement-&gt;willBeParserExecuted() &amp;&amp; scriptElement-&gt;loadableScript() &amp;&amp; is&lt;LoadableClassicScript&gt;(*scriptElement-&gt;loadableScript())) {
+            // FIXME: Allow &quot;module&quot; scripts for XML documents.
+            // https://bugs.webkit.org/show_bug.cgi?id=161651
+            m_pendingScript = &amp;downcast&lt;LoadableClassicScript&gt;(*scriptElement-&gt;loadableScript()).cachedScript();
</ins><span class="cx">             m_scriptElement = &amp;element;
</span><span class="cx">             m_pendingScript-&gt;addClient(this);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>