<!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>[210585] trunk/Source</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/210585">210585</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-01-11 04:12:37 -0800 (Wed, 11 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Decouple module loading initiator from ScriptElement
https://bugs.webkit.org/show_bug.cgi?id=166888

Reviewed by Saam Barati and Ryosuke Niwa.

Source/JavaScriptCore:

Add ScriptFetcher and JSScriptFetcher.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/ModuleLoaderPrototype.js:
(requestFetch):
(requestInstantiate):
(requestSatisfy):
(requestInstantiateAll):
(requestLink):
(moduleEvaluation):
(loadAndEvaluateModule):
(importModule):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LowLevelInterpreter.asm:
* runtime/Completion.cpp:
(JSC::loadAndEvaluateModule):
(JSC::loadModule):
(JSC::linkAndEvaluateModule):
* runtime/Completion.h:
* runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::loadAndEvaluateModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::resolve):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::instantiate):
(JSC::JSModuleLoader::evaluate):
* runtime/JSModuleLoader.h:
* runtime/JSScriptFetcher.cpp: Copied from Source/WebCore/dom/LoadableScript.cpp.
(JSC::JSScriptFetcher::destroy):
* runtime/JSScriptFetcher.h: Added.
(JSC::JSScriptFetcher::createStructure):
(JSC::JSScriptFetcher::create):
(JSC::JSScriptFetcher::fetcher):
(JSC::JSScriptFetcher::JSScriptFetcher):
* runtime/JSType.h:
* runtime/ScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
(JSC::ScriptFetcher::~ScriptFetcher):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:

Source/WebCore:

Previously, we use ScriptElement (JSElement for ScriptElement) as the module loading initiator.
This element is used to transfer the metadata like charset throughout the module pipeline.
As a result, our module loader in the browser side is tightly coupled with ScriptElement.
It is not good since it prevent us from using the module loader in the non-DOM environment like
Web Workers.

So we decouple the necessary informations from ScriptElement. We move these information to
LoadableScript. And we use JSScriptFetcher to transfer LoadableScript through the JS implemented
module loader pipeline. We select LoadableScript instead of LoadableModuleScript since this initiator
information will be leveraged even in classic scripts once we implement the dynamic import.

No behavior change.

* ForwardingHeaders/runtime/JSScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
* ForwardingHeaders/runtime/ScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
* bindings/js/CachedModuleScript.cpp:
(WebCore::CachedModuleScript::create):
(WebCore::CachedModuleScript::load):
(WebCore::CachedModuleScript::CachedModuleScript): Deleted.
* bindings/js/CachedModuleScript.h:
Now we can merge CachedModuleScript to LoadableScript. But we do not do this in this patch since
we focus on decoupling the initiator information from ScriptElement.

(WebCore::CachedModuleScript::nonce): Deleted.
(WebCore::CachedModuleScript::crossOriginMode): Deleted.
* bindings/js/CachedModuleScriptLoader.cpp:
(WebCore::CachedModuleScriptLoader::load):
* bindings/js/CachedModuleScriptLoader.h:
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::moduleLoaderResolve):
(WebCore::JSDOMWindowBase::moduleLoaderFetch):
(WebCore::JSDOMWindowBase::moduleLoaderEvaluate):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::loadModule):
(WebCore::JSMainThreadExecState::linkAndEvaluateModule):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::ScriptController::loadModuleScript):
(WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
(WebCore::ScriptController::linkAndEvaluateModuleScript):
* bindings/js/ScriptController.h:
* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::fetch):
* bindings/js/ScriptModuleLoader.h:
* dom/LoadableClassicScript.cpp:
(WebCore::LoadableClassicScript::create):
(WebCore::LoadableClassicScript::~LoadableClassicScript):
(WebCore::LoadableClassicScript::isLoaded):
(WebCore::LoadableClassicScript::error):
(WebCore::LoadableClassicScript::wasCanceled):
(WebCore::LoadableClassicScript::notifyFinished):
(WebCore::LoadableClassicScript::load):
* dom/LoadableClassicScript.h:
* dom/LoadableModuleScript.cpp:
(WebCore::LoadableModuleScript::create):
(WebCore::LoadableModuleScript::LoadableModuleScript):
(WebCore::LoadableModuleScript::load):
* dom/LoadableModuleScript.h:
* dom/LoadableScript.cpp:
(WebCore::LoadableScript::requestScriptWithCache):
* dom/LoadableScript.h:
(WebCore::LoadableScript::LoadableScript):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestClassicScript):
(WebCore::ScriptElement::requestModuleScript):
(WebCore::ScriptElement::executeModuleScript):
(WebCore::ScriptElement::requestScriptWithCacheForModuleScript): Deleted.
(WebCore::ScriptElement::requestScriptWithCache): Deleted.
* dom/ScriptElement.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsModuleLoaderPrototypejs">trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLLIntDatacpp">trunk/Source/JavaScriptCore/llint/LLIntData.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreterasm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletioncpp">trunk/Source/JavaScriptCore/runtime/Completion.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletionh">trunk/Source/JavaScriptCore/runtime/Completion.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleLoadercpp">trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleLoaderh">trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTypeh">trunk/Source/JavaScriptCore/runtime/JSType.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMcpp">trunk/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMh">trunk/Source/JavaScriptCore/runtime/VM.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsCachedModuleScriptcpp">trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsCachedModuleScripth">trunk/Source/WebCore/bindings/js/CachedModuleScript.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsCachedModuleScriptLoadercpp">trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsCachedModuleScriptLoaderh">trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowBasecpp">trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSMainThreadExecStateh">trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptControllercpp">trunk/Source/WebCore/bindings/js/ScriptController.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptControllerh">trunk/Source/WebCore/bindings/js/ScriptController.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptModuleLoadercpp">trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptModuleLoaderh">trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h</a></li>
<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="#trunkSourceWebCoredomLoadableModuleScriptcpp">trunk/Source/WebCore/dom/LoadableModuleScript.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLoadableModuleScripth">trunk/Source/WebCore/dom/LoadableModuleScript.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="#trunkSourceWebCoredomScriptElementcpp">trunk/Source/WebCore/dom/ScriptElement.cpp</a></li>
<li><a href="#trunkSourceWebCoredomScriptElementh">trunk/Source/WebCore/dom/ScriptElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSScriptFetchercpp">trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSScriptFetcherh">trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeScriptFetcherh">trunk/Source/JavaScriptCore/runtime/ScriptFetcher.h</a></li>
<li><a href="#trunkSourceWebCoreForwardingHeadersruntimeJSScriptFetcherh">trunk/Source/WebCore/ForwardingHeaders/runtime/JSScriptFetcher.h</a></li>
<li><a href="#trunkSourceWebCoreForwardingHeadersruntimeScriptFetcherh">trunk/Source/WebCore/ForwardingHeaders/runtime/ScriptFetcher.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -784,6 +784,7 @@
</span><span class="cx">     runtime/JSPropertyNameIterator.cpp
</span><span class="cx">     runtime/JSProxy.cpp
</span><span class="cx">     runtime/JSScope.cpp
</span><ins>+    runtime/JSScriptFetcher.cpp
</ins><span class="cx">     runtime/JSSegmentedVariableObject.cpp
</span><span class="cx">     runtime/JSSet.cpp
</span><span class="cx">     runtime/JSSetIterator.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2017-01-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Decouple module loading initiator from ScriptElement
+        https://bugs.webkit.org/show_bug.cgi?id=166888
+
+        Reviewed by Saam Barati and Ryosuke Niwa.
+
+        Add ScriptFetcher and JSScriptFetcher.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * builtins/ModuleLoaderPrototype.js:
+        (requestFetch):
+        (requestInstantiate):
+        (requestSatisfy):
+        (requestInstantiateAll):
+        (requestLink):
+        (moduleEvaluation):
+        (loadAndEvaluateModule):
+        (importModule):
+        * llint/LLIntData.cpp:
+        (JSC::LLInt::Data::performAssertions):
+        * llint/LowLevelInterpreter.asm:
+        * runtime/Completion.cpp:
+        (JSC::loadAndEvaluateModule):
+        (JSC::loadModule):
+        (JSC::linkAndEvaluateModule):
+        * runtime/Completion.h:
+        * runtime/JSModuleLoader.cpp:
+        (JSC::JSModuleLoader::loadAndEvaluateModule):
+        (JSC::JSModuleLoader::loadModule):
+        (JSC::JSModuleLoader::linkAndEvaluateModule):
+        (JSC::JSModuleLoader::resolve):
+        (JSC::JSModuleLoader::fetch):
+        (JSC::JSModuleLoader::instantiate):
+        (JSC::JSModuleLoader::evaluate):
+        * runtime/JSModuleLoader.h:
+        * runtime/JSScriptFetcher.cpp: Copied from Source/WebCore/dom/LoadableScript.cpp.
+        (JSC::JSScriptFetcher::destroy):
+        * runtime/JSScriptFetcher.h: Added.
+        (JSC::JSScriptFetcher::createStructure):
+        (JSC::JSScriptFetcher::create):
+        (JSC::JSScriptFetcher::fetcher):
+        (JSC::JSScriptFetcher::JSScriptFetcher):
+        * runtime/JSType.h:
+        * runtime/ScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
+        (JSC::ScriptFetcher::~ScriptFetcher):
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+
</ins><span class="cx"> 2017-01-10  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement JSSourceCode to propagate SourceCode in module pipeline
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -2372,6 +2372,9 @@
</span><span class="cx">                 FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FA3AB211C8494524AB390267 /* JSSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */; };
</span><span class="cx">                 BDFCB2BBE90F41349E1B0BED /* JSSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3032175DF1AD47D8998B34E1 /* JSSourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                14815F5F991C46BEB98D0016 /* JSScriptFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 11C197C2624848EDA84CED7F /* JSScriptFetcher.cpp */; };
+                9064337DD4B0402BAF34A592 /* JSScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BA93C9590484C5BAD9316EA /* JSScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CEAE7D7B889B477BA93ABA6C /* ScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852151A9C3842389B3215B7 /* ScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx"> /* End PBXBuildFile section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXContainerItemProxy section */
</span><span class="lines">@@ -4900,6 +4903,9 @@
</span><span class="cx">                 FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSSourceCode.cpp; path = JSSourceCode.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3032175DF1AD47D8998B34E1 /* JSSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSSourceCode.h; path = JSSourceCode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                11C197C2624848EDA84CED7F /* JSScriptFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSScriptFetcher.cpp; path = JSScriptFetcher.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                6BA93C9590484C5BAD9316EA /* JSScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSScriptFetcher.h; path = JSScriptFetcher.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                8852151A9C3842389B3215B7 /* ScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptFetcher.h; path = ScriptFetcher.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx"> /* End PBXFileReference section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXFrameworksBuildPhase section */
</span><span class="lines">@@ -6740,6 +6746,9 @@
</span><span class="cx">                                 425BA1337E4344E1B269A671 /* SourceOrigin.h */,
</span><span class="cx">                                 F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */,
</span><span class="cx">                                 3032175DF1AD47D8998B34E1 /* JSSourceCode.h */,
</span><ins>+                                11C197C2624848EDA84CED7F /* JSScriptFetcher.cpp */,
+                                6BA93C9590484C5BAD9316EA /* JSScriptFetcher.h */,
+                                8852151A9C3842389B3215B7 /* ScriptFetcher.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = runtime;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -9114,6 +9123,8 @@
</span><span class="cx">                                 86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
</span><span class="cx">                                 2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */,
</span><span class="cx">                                 BDFCB2BBE90F41349E1B0BED /* JSSourceCode.h in Headers */,
</span><ins>+                                9064337DD4B0402BAF34A592 /* JSScriptFetcher.h in Headers */,
+                                CEAE7D7B889B477BA93ABA6C /* ScriptFetcher.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -10502,6 +10513,7 @@
</span><span class="cx">                                 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
</span><span class="cx">                                 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
</span><span class="cx">                                 FA3AB211C8494524AB390267 /* JSSourceCode.cpp in Sources */,
</span><ins>+                                14815F5F991C46BEB98D0016 /* JSScriptFetcher.cpp in Sources */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsModuleLoaderPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Loader.
</span><span class="cx"> 
</span><del>-function requestFetch(key, initiator)
</del><ins>+function requestFetch(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#request-fetch
</span><span class="cx"> 
</span><span class="lines">@@ -220,7 +220,7 @@
</span><span class="cx">     //     Take the key and fetch the resource actually.
</span><span class="cx">     //     For example, JavaScriptCore shell can provide the hook fetching the resource
</span><span class="cx">     //     from the local file system.
</span><del>-    var fetchPromise = this.fetch(key, initiator).then((source) =&gt; {
</del><ins>+    var fetchPromise = this.fetch(key, fetcher).then((source) =&gt; {
</ins><span class="cx">         @setStateToMax(entry, @ModuleInstantiate);
</span><span class="cx">         return source;
</span><span class="cx">     });
</span><span class="lines">@@ -228,7 +228,7 @@
</span><span class="cx">     return fetchPromise;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function requestInstantiate(key, initiator)
</del><ins>+function requestInstantiate(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#request-instantiate
</span><span class="cx"> 
</span><span class="lines">@@ -238,7 +238,7 @@
</span><span class="cx">     if (entry.instantiate)
</span><span class="cx">         return entry.instantiate;
</span><span class="cx"> 
</span><del>-    var instantiatePromise = this.requestFetch(key, initiator).then((source) =&gt; {
</del><ins>+    var instantiatePromise = this.requestFetch(key, fetcher).then((source) =&gt; {
</ins><span class="cx">         // Hook point.
</span><span class="cx">         // 3. Loader.instantiate
</span><span class="cx">         //     https://whatwg.github.io/loader/#browser-instantiate
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx">         //     by parsing the module source code.
</span><span class="cx">         //     It has the chance to provide the optional module instance that is different from
</span><span class="cx">         //     the ordinary one.
</span><del>-        return this.instantiate(key, source, initiator).then((optionalInstance) =&gt; {
</del><ins>+        return this.instantiate(key, source, fetcher).then((optionalInstance) =&gt; {
</ins><span class="cx">             this.commitInstantiated(entry, optionalInstance, source);
</span><span class="cx">             return entry;
</span><span class="cx">         });
</span><span class="lines">@@ -255,7 +255,7 @@
</span><span class="cx">     return instantiatePromise;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function requestSatisfy(key, initiator)
</del><ins>+function requestSatisfy(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#satisfy-instance
</span><span class="cx"> 
</span><span class="lines">@@ -265,7 +265,7 @@
</span><span class="cx">     if (entry.satisfy)
</span><span class="cx">         return entry.satisfy;
</span><span class="cx"> 
</span><del>-    var satisfyPromise = this.requestInstantiate(key, initiator).then((entry) =&gt; {
</del><ins>+    var satisfyPromise = this.requestInstantiate(key, fetcher).then((entry) =&gt; {
</ins><span class="cx">         var depLoads = [];
</span><span class="cx">         for (var i = 0, length = entry.dependencies.length; i &lt; length; ++i) {
</span><span class="cx">             let pair = entry.dependencies[i];
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx">             //     https://whatwg.github.io/loader/#browser-resolve
</span><span class="cx">             //     Take the name and resolve it to the unique identifier for the resource location.
</span><span class="cx">             //     For example, take the &quot;jquery&quot; and return the URL for the resource.
</span><del>-            var promise = this.resolve(pair.key, key, initiator).then((depKey) =&gt; {
</del><ins>+            var promise = this.resolve(pair.key, key, fetcher).then((depKey) =&gt; {
</ins><span class="cx">                 var depEntry = this.ensureRegistered(depKey);
</span><span class="cx"> 
</span><span class="cx">                 // Recursive resolving. The dependencies of this entry is being resolved or already resolved.
</span><span class="lines">@@ -294,7 +294,7 @@
</span><span class="cx">                     });
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                return this.requestSatisfy(depKey, initiator).then((entry) =&gt; {
</del><ins>+                return this.requestSatisfy(depKey, fetcher).then((entry) =&gt; {
</ins><span class="cx">                     pair.value = entry.module;
</span><span class="cx">                     return entry;
</span><span class="cx">                 });
</span><span class="lines">@@ -312,16 +312,16 @@
</span><span class="cx">     return satisfyPromise;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function requestInstantiateAll(key, initiator)
</del><ins>+function requestInstantiateAll(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#request-instantiate-all
</span><span class="cx"> 
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><del>-    return this.requestSatisfy(key, initiator);
</del><ins>+    return this.requestSatisfy(key, fetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function requestLink(key, initiator)
</del><ins>+function requestLink(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#request-link
</span><span class="cx"> 
</span><span class="lines">@@ -334,26 +334,26 @@
</span><span class="cx">         return deferred.@promise;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return this.requestInstantiateAll(key, initiator).then((entry) =&gt; {
-        this.link(entry, initiator);
</del><ins>+    return this.requestInstantiateAll(key, fetcher).then((entry) =&gt; {
+        this.link(entry, fetcher);
</ins><span class="cx">         return entry;
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function requestReady(key, initiator)
</del><ins>+function requestReady(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#request-ready
</span><span class="cx"> 
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><del>-    return this.requestLink(key, initiator).then((entry) =&gt; {
-        this.moduleEvaluation(entry.module, initiator);
</del><ins>+    return this.requestLink(key, fetcher).then((entry) =&gt; {
+        this.moduleEvaluation(entry.module, fetcher);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Linking semantics.
</span><span class="cx"> 
</span><del>-function link(entry, initiator)
</del><ins>+function link(entry, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#link
</span><span class="cx"> 
</span><span class="lines">@@ -373,15 +373,15 @@
</span><span class="cx">     var dependencies = entry.dependencies;
</span><span class="cx">     for (var i = 0, length = dependencies.length; i &lt; length; ++i) {
</span><span class="cx">         var pair = dependencies[i];
</span><del>-        this.link(pair.value.registryEntry, initiator);
</del><ins>+        this.link(pair.value.registryEntry, fetcher);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    this.moduleDeclarationInstantiation(entry.module, initiator);
</del><ins>+    this.moduleDeclarationInstantiation(entry.module, fetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Module semantics.
</span><span class="cx"> 
</span><del>-function moduleEvaluation(moduleRecord, initiator)
</del><ins>+function moduleEvaluation(moduleRecord, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     // http://www.ecma-international.org/ecma-262/6.0/#sec-moduleevaluation
</span><span class="cx"> 
</span><span class="lines">@@ -398,9 +398,9 @@
</span><span class="cx">     for (var i = 0, length = dependencies.length; i &lt; length; ++i) {
</span><span class="cx">         var pair = dependencies[i];
</span><span class="cx">         var requiredModuleRecord = pair.value;
</span><del>-        this.moduleEvaluation(requiredModuleRecord, initiator);
</del><ins>+        this.moduleEvaluation(requiredModuleRecord, fetcher);
</ins><span class="cx">     }
</span><del>-    this.evaluate(entry.key, moduleRecord, initiator);
</del><ins>+    this.evaluate(entry.key, moduleRecord, fetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // APIs to control the module loader.
</span><span class="lines">@@ -431,7 +431,7 @@
</span><span class="cx">     @throwTypeError(&quot;Requested module is already ready to be executed.&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function loadAndEvaluateModule(moduleName, referrer, initiator)
</del><ins>+function loadAndEvaluateModule(moduleName, referrer, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -439,12 +439,12 @@
</span><span class="cx">     // resolve: moduleName =&gt; Promise(moduleKey)
</span><span class="cx">     // Take the name and resolve it to the unique identifier for the resource location.
</span><span class="cx">     // For example, take the &quot;jquery&quot; and return the URL for the resource.
</span><del>-    return this.resolve(moduleName, referrer, initiator).then((key) =&gt; {
-        return this.requestReady(key, initiator);
</del><ins>+    return this.resolve(moduleName, referrer, fetcher).then((key) =&gt; {
+        return this.requestReady(key, fetcher);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function loadModule(moduleName, referrer, initiator)
</del><ins>+function loadModule(moduleName, referrer, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -452,14 +452,14 @@
</span><span class="cx">     // resolve: moduleName =&gt; Promise(moduleKey)
</span><span class="cx">     // Take the name and resolve it to the unique identifier for the resource location.
</span><span class="cx">     // For example, take the &quot;jquery&quot; and return the URL for the resource.
</span><del>-    return this.resolve(moduleName, referrer, initiator).then((key) =&gt; {
-        return this.requestInstantiateAll(key, initiator);
</del><ins>+    return this.resolve(moduleName, referrer, fetcher).then((key) =&gt; {
+        return this.requestInstantiateAll(key, fetcher);
</ins><span class="cx">     }).then((entry) =&gt; {
</span><span class="cx">         return entry.key;
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function linkAndEvaluateModule(key, initiator)
</del><ins>+function linkAndEvaluateModule(key, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -467,11 +467,11 @@
</span><span class="cx">     if (entry.state &lt; @ModuleLink)
</span><span class="cx">         @throwTypeError(&quot;Requested module is not instantiated yet.&quot;);
</span><span class="cx"> 
</span><del>-    this.link(entry, initiator);
-    return this.moduleEvaluation(entry.module, initiator);
</del><ins>+    this.link(entry, fetcher);
+    return this.moduleEvaluation(entry.module, fetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function importModule(moduleName, referrer, initiator)
</del><ins>+function importModule(moduleName, referrer, fetcher)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -479,10 +479,10 @@
</span><span class="cx">     // resolve: moduleName =&gt; Promise(moduleKey)
</span><span class="cx">     // Take the name and resolve it to the unique identifier for the resource location.
</span><span class="cx">     // For example, take the &quot;jquery&quot; and return the URL for the resource.
</span><del>-    return this.resolve(moduleName, referrer, initiator).then((key) =&gt; {
-        return this.requestInstantiateAll(key, initiator);
</del><ins>+    return this.resolve(moduleName, referrer, fetcher).then((key) =&gt; {
+        return this.requestInstantiateAll(key, fetcher);
</ins><span class="cx">     }).then((entry) =&gt; {
</span><del>-        this.linkAndEvaluateModule(entry.key, initiator);
</del><ins>+        this.linkAndEvaluateModule(entry.key, fetcher);
</ins><span class="cx">         return this.getModuleNamespaceObject(entry.module);
</span><span class="cx">     });
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLLIntDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LLIntData.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LLIntData.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/llint/LLIntData.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -156,21 +156,21 @@
</span><span class="cx">     
</span><span class="cx">     STATIC_ASSERT(StringType == 6);
</span><span class="cx">     STATIC_ASSERT(SymbolType == 7);
</span><del>-    STATIC_ASSERT(ObjectType == 22);
-    STATIC_ASSERT(FinalObjectType == 23);
-    STATIC_ASSERT(JSFunctionType == 25);
-    STATIC_ASSERT(ArrayType == 33);
-    STATIC_ASSERT(DerivedArrayType == 34);
-    STATIC_ASSERT(ProxyObjectType == 52);
-    STATIC_ASSERT(Int8ArrayType == 35);
-    STATIC_ASSERT(Int16ArrayType == 36);
-    STATIC_ASSERT(Int32ArrayType == 37);
-    STATIC_ASSERT(Uint8ArrayType == 38);
-    STATIC_ASSERT(Uint8ClampedArrayType == 39);
-    STATIC_ASSERT(Uint16ArrayType == 40);
-    STATIC_ASSERT(Uint32ArrayType == 41);
-    STATIC_ASSERT(Float32ArrayType == 42);
-    STATIC_ASSERT(Float64ArrayType == 43);
</del><ins>+    STATIC_ASSERT(ObjectType == 23);
+    STATIC_ASSERT(FinalObjectType == 24);
+    STATIC_ASSERT(JSFunctionType == 26);
+    STATIC_ASSERT(ArrayType == 34);
+    STATIC_ASSERT(DerivedArrayType == 35);
+    STATIC_ASSERT(ProxyObjectType == 53);
+    STATIC_ASSERT(Int8ArrayType == 36);
+    STATIC_ASSERT(Int16ArrayType == 37);
+    STATIC_ASSERT(Int32ArrayType == 38);
+    STATIC_ASSERT(Uint8ArrayType == 39);
+    STATIC_ASSERT(Uint8ClampedArrayType == 40);
+    STATIC_ASSERT(Uint16ArrayType == 41);
+    STATIC_ASSERT(Uint32ArrayType == 42);
+    STATIC_ASSERT(Float32ArrayType == 43);
+    STATIC_ASSERT(Float64ArrayType == 44);
</ins><span class="cx">     STATIC_ASSERT(MasqueradesAsUndefined == 1);
</span><span class="cx">     STATIC_ASSERT(ImplementsDefaultHasInstance == 2);
</span><span class="cx">     STATIC_ASSERT(FirstConstantRegisterIndex == 0x40000000);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -345,24 +345,24 @@
</span><span class="cx"> # Type constants.
</span><span class="cx"> const StringType = 6
</span><span class="cx"> const SymbolType = 7
</span><del>-const ObjectType = 22
-const FinalObjectType = 23
-const JSFunctionType = 25
-const ArrayType = 33
-const DerivedArrayType = 34
-const ProxyObjectType = 52
</del><ins>+const ObjectType = 23
+const FinalObjectType = 24
+const JSFunctionType = 26
+const ArrayType = 34
+const DerivedArrayType = 35
+const ProxyObjectType = 53
</ins><span class="cx"> 
</span><span class="cx"> # The typed array types need to be numbered in a particular order because of the manually written
</span><span class="cx"> # switch statement in get_by_val and put_by_val.
</span><del>-const Int8ArrayType = 35
-const Int16ArrayType = 36
-const Int32ArrayType = 37
-const Uint8ArrayType = 38
-const Uint8ClampedArrayType = 39
-const Uint16ArrayType = 40
-const Uint32ArrayType = 41
-const Float32ArrayType = 42
-const Float64ArrayType = 43
</del><ins>+const Int8ArrayType = 36
+const Int16ArrayType = 37
+const Int32ArrayType = 38
+const Uint8ArrayType = 39
+const Uint8ClampedArrayType = 40
+const Uint16ArrayType = 41
+const Uint32ArrayType = 42
+const Float32ArrayType = 43
+const Float64ArrayType = 44
</ins><span class="cx"> 
</span><span class="cx"> const FirstArrayType = Int8ArrayType
</span><span class="cx"> const LastArrayType = Float64ArrayType
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/Completion.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -161,26 +161,26 @@
</span><span class="cx">     return deferred-&gt;promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&amp;, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue initiator)
</del><ins>+static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&amp;, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><del>-    return globalObject-&gt;moduleLoader()-&gt;loadAndEvaluateModule(exec, moduleName, referrer, initiator);
</del><ins>+    return globalObject-&gt;moduleLoader()-&gt;loadAndEvaluateModule(exec, moduleName, referrer, scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&amp; lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier&amp; moduleName, JSValue initiator)
</del><ins>+static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&amp; lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier&amp; moduleName, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><del>-    return loadAndEvaluateModule(lock, exec, globalObject, identifierToJSValue(exec-&gt;vm(), moduleName), jsUndefined(), initiator);
</del><ins>+    return loadAndEvaluateModule(lock, exec, globalObject, identifierToJSValue(exec-&gt;vm(), moduleName), jsUndefined(), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const String&amp; moduleName, JSValue initiator)
</del><ins>+JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const String&amp; moduleName, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(exec);
</span><span class="cx">     RELEASE_ASSERT(exec-&gt;vm().atomicStringTable() == wtfThreadData().atomicStringTable());
</span><span class="cx">     RELEASE_ASSERT(!exec-&gt;vm().isCollectorBusyOnCurrentThread());
</span><span class="cx"> 
</span><del>-    return loadAndEvaluateModule(lock, exec, exec-&gt;vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), initiator);
</del><ins>+    return loadAndEvaluateModule(lock, exec, exec-&gt;vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode&amp; source, JSValue initiator)
</del><ins>+JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode&amp; source, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     VM&amp; vm = exec-&gt;vm();
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -196,29 +196,29 @@
</span><span class="cx">     globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
</span><span class="cx"> 
</span><del>-    return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined(), initiator);
</del><ins>+    return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined(), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static JSInternalPromise* loadModule(const JSLockHolder&amp;, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue initiator)
</del><ins>+static JSInternalPromise* loadModule(const JSLockHolder&amp;, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><del>-    return globalObject-&gt;moduleLoader()-&gt;loadModule(exec, moduleName, referrer, initiator);
</del><ins>+    return globalObject-&gt;moduleLoader()-&gt;loadModule(exec, moduleName, referrer, scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static JSInternalPromise* loadModule(const JSLockHolder&amp; lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier&amp; moduleName, JSValue initiator)
</del><ins>+static JSInternalPromise* loadModule(const JSLockHolder&amp; lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier&amp; moduleName, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><del>-    return loadModule(lock, exec, globalObject, identifierToJSValue(exec-&gt;vm(), moduleName), jsUndefined(), initiator);
</del><ins>+    return loadModule(lock, exec, globalObject, identifierToJSValue(exec-&gt;vm(), moduleName), jsUndefined(), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* loadModule(ExecState* exec, const String&amp; moduleName, JSValue initiator)
</del><ins>+JSInternalPromise* loadModule(ExecState* exec, const String&amp; moduleName, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(exec);
</span><span class="cx">     RELEASE_ASSERT(exec-&gt;vm().atomicStringTable() == wtfThreadData().atomicStringTable());
</span><span class="cx">     RELEASE_ASSERT(!exec-&gt;vm().isCollectorBusyOnCurrentThread());
</span><span class="cx"> 
</span><del>-    return loadModule(lock, exec, exec-&gt;vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), initiator);
</del><ins>+    return loadModule(lock, exec, exec-&gt;vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* loadModule(ExecState* exec, const SourceCode&amp; source, JSValue initiator)
</del><ins>+JSInternalPromise* loadModule(ExecState* exec, const SourceCode&amp; source, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     VM&amp; vm = exec-&gt;vm();
</span><span class="cx">     JSLockHolder lock(vm);
</span><span class="lines">@@ -235,10 +235,10 @@
</span><span class="cx">     globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
</span><span class="cx"> 
</span><del>-    return loadModule(lock, exec, globalObject, key, jsUndefined(), initiator);
</del><ins>+    return loadModule(lock, exec, globalObject, key, jsUndefined(), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue linkAndEvaluateModule(ExecState* exec, const Identifier&amp; moduleKey, JSValue initiator)
</del><ins>+JSValue linkAndEvaluateModule(ExecState* exec, const Identifier&amp; moduleKey, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(exec);
</span><span class="cx">     RELEASE_ASSERT(exec-&gt;vm().atomicStringTable() == wtfThreadData().atomicStringTable());
</span><span class="lines">@@ -245,7 +245,7 @@
</span><span class="cx">     RELEASE_ASSERT(!exec-&gt;vm().isCollectorBusyOnCurrentThread());
</span><span class="cx"> 
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;vmEntryGlobalObject();
</span><del>-    return globalObject-&gt;moduleLoader()-&gt;linkAndEvaluateModule(exec, identifierToJSValue(exec-&gt;vm(), moduleKey), initiator);
</del><ins>+    return globalObject-&gt;moduleLoader()-&gt;linkAndEvaluateModule(exec, identifierToJSValue(exec-&gt;vm(), moduleKey), scriptFetcher);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/Completion.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -57,14 +57,14 @@
</span><span class="cx"> JS_EXPORT_PRIVATE JSValue evaluateWithScopeExtension(ExecState*, const SourceCode&amp;, JSObject* scopeExtension, NakedPtr&lt;Exception&gt;&amp; returnedException);
</span><span class="cx"> 
</span><span class="cx"> // Load the module source and evaluate it.
</span><del>-JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const String&amp; moduleName, JSValue initiator = jsUndefined());
-JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&amp;, JSValue initiator = jsUndefined());
</del><ins>+JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const String&amp; moduleName, JSValue scriptFetcher = jsUndefined());
+JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&amp;, JSValue scriptFetcher = jsUndefined());
</ins><span class="cx"> 
</span><span class="cx"> // Fetch the module source, and instantiate the module record.
</span><del>-JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String&amp; moduleName, JSValue initiator = jsUndefined());
-JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&amp;, JSValue initiator = jsUndefined());
</del><ins>+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String&amp; moduleName, JSValue scriptFetcher = jsUndefined());
+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&amp;, JSValue scriptFetcher = jsUndefined());
</ins><span class="cx"> 
</span><span class="cx"> // Link and evaluate the already linked module. This function is called in a sync manner.
</span><del>-JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier&amp; moduleKey, JSValue initiator = jsUndefined());
</del><ins>+JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier&amp; moduleKey, JSValue scriptFetcher = jsUndefined());
</ins><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">     return call(exec, function, callType, callData, this, arguments);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
</del><ins>+JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSObject* function = jsCast&lt;JSObject*&gt;(get(exec, exec-&gt;propertyNames().builtinNames().loadAndEvaluateModulePublicName()));
</span><span class="cx">     CallData callData;
</span><span class="lines">@@ -103,12 +103,12 @@
</span><span class="cx">     MarkedArgumentBuffer arguments;
</span><span class="cx">     arguments.append(moduleName);
</span><span class="cx">     arguments.append(referrer);
</span><del>-    arguments.append(initiator);
</del><ins>+    arguments.append(scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     return jsCast&lt;JSInternalPromise*&gt;(call(exec, function, callType, callData, this, arguments));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
</del><ins>+JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSObject* function = jsCast&lt;JSObject*&gt;(get(exec, exec-&gt;propertyNames().builtinNames().loadModulePublicName()));
</span><span class="cx">     CallData callData;
</span><span class="lines">@@ -118,12 +118,12 @@
</span><span class="cx">     MarkedArgumentBuffer arguments;
</span><span class="cx">     arguments.append(moduleName);
</span><span class="cx">     arguments.append(referrer);
</span><del>-    arguments.append(initiator);
</del><ins>+    arguments.append(scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     return jsCast&lt;JSInternalPromise*&gt;(call(exec, function, callType, callData, this, arguments));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey, JSValue initiator)
</del><ins>+JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSObject* function = jsCast&lt;JSObject*&gt;(get(exec, exec-&gt;propertyNames().builtinNames().linkAndEvaluateModulePublicName()));
</span><span class="cx">     CallData callData;
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx"> 
</span><span class="cx">     MarkedArgumentBuffer arguments;
</span><span class="cx">     arguments.append(moduleKey);
</span><del>-    arguments.append(initiator);
</del><ins>+    arguments.append(scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     return call(exec, function, callType, callData, this, arguments);
</span><span class="cx"> }
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx">     return deferred-&gt;promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue initiator)
</del><ins>+JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     if (Options::dumpModuleLoadingState())
</span><span class="cx">         dataLog(&quot;Loader [resolve] &quot;, printableModuleKey(exec, name), &quot;\n&quot;);
</span><span class="lines">@@ -168,13 +168,13 @@
</span><span class="cx"> 
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
</span><span class="cx">     if (globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderResolve)
</span><del>-        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderResolve(globalObject, exec, this, name, referrer, initiator);
</del><ins>+        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderResolve(globalObject, exec, this, name, referrer, scriptFetcher);
</ins><span class="cx">     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
</span><span class="cx">     deferred-&gt;resolve(exec, name);
</span><span class="cx">     return deferred-&gt;promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key, JSValue initiator)
</del><ins>+JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     if (Options::dumpModuleLoadingState())
</span><span class="cx">         dataLog(&quot;Loader [fetch] &quot;, printableModuleKey(exec, key), &quot;\n&quot;);
</span><span class="lines">@@ -183,7 +183,7 @@
</span><span class="cx">     VM&amp; vm = globalObject-&gt;vm();
</span><span class="cx">     auto scope = DECLARE_CATCH_SCOPE(vm);
</span><span class="cx">     if (globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderFetch)
</span><del>-        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderFetch(globalObject, exec, this, key, initiator);
</del><ins>+        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderFetch(globalObject, exec, this, key, scriptFetcher);
</ins><span class="cx">     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
</span><span class="cx">     String moduleKey = key.toWTFString(exec);
</span><span class="cx">     if (UNLIKELY(scope.exception())) {
</span><span class="lines">@@ -196,7 +196,7 @@
</span><span class="cx">     return deferred-&gt;promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source, JSValue initiator)
</del><ins>+JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     if (Options::dumpModuleLoadingState())
</span><span class="cx">         dataLog(&quot;Loader [instantiate] &quot;, printableModuleKey(exec, key), &quot;\n&quot;);
</span><span class="lines">@@ -203,13 +203,13 @@
</span><span class="cx"> 
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
</span><span class="cx">     if (globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderInstantiate)
</span><del>-        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderInstantiate(globalObject, exec, this, key, source, initiator);
</del><ins>+        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderInstantiate(globalObject, exec, this, key, source, scriptFetcher);
</ins><span class="cx">     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
</span><span class="cx">     deferred-&gt;resolve(exec, jsUndefined());
</span><span class="cx">     return deferred-&gt;promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue, JSValue initiator)
</del><ins>+JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     if (Options::dumpModuleLoadingState())
</span><span class="cx">         dataLog(&quot;Loader [evaluate] &quot;, printableModuleKey(exec, key), &quot;\n&quot;);
</span><span class="lines">@@ -216,7 +216,7 @@
</span><span class="cx"> 
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
</span><span class="cx">     if (globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderEvaluate)
</span><del>-        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue, initiator);
</del><ins>+        return globalObject-&gt;globalObjectMethodTable()-&gt;moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue, scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     JSModuleRecord* moduleRecord = jsDynamicCast&lt;JSModuleRecord*&gt;(moduleRecordValue);
</span><span class="cx">     if (!moduleRecord)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -64,18 +64,18 @@
</span><span class="cx"> 
</span><span class="cx">     // APIs to control the module loader.
</span><span class="cx">     JSValue provide(ExecState*, JSValue key, Status, const SourceCode&amp;);
</span><del>-    JSInternalPromise* loadAndEvaluateModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
-    JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
-    JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue initiator);
</del><ins>+    JSInternalPromise* loadAndEvaluateModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue scriptFetcher);
+    JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue scriptFetcher);
+    JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     // Platform dependent hooked APIs.
</span><span class="cx">     JSInternalPromise* importModule(ExecState*, JSString* moduleName, const SourceOrigin&amp; referrer);
</span><del>-    JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer, JSValue initiator);
-    JSInternalPromise* fetch(ExecState*, JSValue key, JSValue initiator);
-    JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source, JSValue initiator);
</del><ins>+    JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer, JSValue scriptFetcher);
+    JSInternalPromise* fetch(ExecState*, JSValue key, JSValue scriptFetcher);
+    JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source, JSValue scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     // Additional platform dependent hooked APIs.
</span><del>-    JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord, JSValue initiator);
</del><ins>+    JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord, JSValue scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     // Utility functions.
</span><span class="cx">     JSModuleNamespaceObject* getModuleNamespaceObject(ExecState*, JSValue moduleRecord);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSScriptFetchercppfromrev210584trunkSourceWebCoredomLoadableScriptcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.cpp (from rev 210584, trunk/Source/WebCore/dom/LoadableScript.cpp) (0 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2017 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * 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;JSScriptFetcher.h&quot;
+
+#include &quot;JSCInlines.h&quot;
+
+namespace JSC {
+
+const ClassInfo JSScriptFetcher::s_info = { &quot;JSScriptFetcher&quot;, nullptr, nullptr, CREATE_METHOD_TABLE(JSScriptFetcher) };
+
+void JSScriptFetcher::destroy(JSCell* cell)
+{
+    static_cast&lt;JSScriptFetcher*&gt;(cell)-&gt;~JSScriptFetcher();
+}
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSScriptFetcherh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.h (0 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/JSScriptFetcher.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * Copyright (C) 2017 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * 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;JSGlobalObject.h&quot;
+#include &quot;JSObject.h&quot;
+#include &quot;ScriptFetcher.h&quot;
+
+namespace JSC {
+
+class JSScriptFetcher : public JSCell {
+public:
+    using Base = JSCell;
+
+    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
+    static const bool needsDestruction = true;
+
+    DECLARE_EXPORT_INFO;
+
+    static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(vm, globalObject, prototype, TypeInfo(JSScriptFetcherType, StructureFlags), info());
+    }
+
+    static JSScriptFetcher* create(VM&amp; vm, Structure* structure, RefPtr&lt;ScriptFetcher&gt;&amp;&amp; scriptFetcher)
+    {
+        auto* result = new (NotNull, allocateCell&lt;JSScriptFetcher&gt;(vm.heap)) JSScriptFetcher(vm, structure, WTFMove(scriptFetcher));
+        result-&gt;finishCreation(vm);
+        return result;
+    }
+
+    static JSScriptFetcher* create(VM&amp; vm, RefPtr&lt;ScriptFetcher&gt;&amp;&amp; scriptFetcher)
+    {
+        return create(vm, vm.scriptFetcherStructure.get(), WTFMove(scriptFetcher));
+    }
+
+    ScriptFetcher* fetcher() const
+    {
+        return m_fetcher.get();
+    }
+
+    static void destroy(JSCell*);
+
+private:
+    JSScriptFetcher(VM&amp; vm, Structure* structure, RefPtr&lt;ScriptFetcher&gt;&amp;&amp; scriptFetcher)
+        : Base(vm, structure)
+        , m_fetcher(WTFMove(scriptFetcher))
+    {
+    }
+
+    RefPtr&lt;ScriptFetcher&gt; m_fetcher;
+};
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSType.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSType.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/JSType.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     JSFixedArrayType,
</span><span class="cx">     JSSourceCodeType,
</span><ins>+    JSScriptFetcherType,
</ins><span class="cx"> 
</span><span class="cx">     // The ObjectType value must come before any JSType that is a subclass of JSObject.
</span><span class="cx">     ObjectType,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeScriptFetcherhfromrev210584trunkSourceWebCoredomLoadableScriptcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/runtime/ScriptFetcher.h (from rev 210584, trunk/Source/WebCore/dom/LoadableScript.cpp) (0 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ScriptFetcher.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/ScriptFetcher.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * Copyright (C) 2017 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * 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;wtf/RefCounted.h&gt;
+
+namespace JSC {
+
+class ScriptFetcher : public RefCounted&lt;ScriptFetcher&gt; {
+public:
+    virtual ~ScriptFetcher() { }
+};
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> #include &quot;JSMap.h&quot;
</span><span class="cx"> #include &quot;JSPromiseDeferred.h&quot;
</span><span class="cx"> #include &quot;JSPropertyNameEnumerator.h&quot;
</span><ins>+#include &quot;JSScriptFetcher.h&quot;
</ins><span class="cx"> #include &quot;JSSourceCode.h&quot;
</span><span class="cx"> #include &quot;JSTemplateRegistryKey.h&quot;
</span><span class="cx"> #include &quot;JSWebAssembly.h&quot;
</span><span class="lines">@@ -240,6 +241,7 @@
</span><span class="cx">     symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull()));
</span><span class="cx">     fixedArrayStructure.set(*this, JSFixedArray::createStructure(*this, 0, jsNull()));
</span><span class="cx">     sourceCodeStructure.set(*this, JSSourceCode::createStructure(*this, 0, jsNull()));
</span><ins>+    scriptFetcherStructure.set(*this, JSScriptFetcher::createStructure(*this, 0, jsNull()));
</ins><span class="cx">     structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
</span><span class="cx">     sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull()));
</span><span class="cx">     templateRegistryKeyStructure.set(*this, JSTemplateRegistryKey::createStructure(*this, 0, jsNull()));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -327,6 +327,7 @@
</span><span class="cx">     Strong&lt;Structure&gt; symbolTableStructure;
</span><span class="cx">     Strong&lt;Structure&gt; fixedArrayStructure;
</span><span class="cx">     Strong&lt;Structure&gt; sourceCodeStructure;
</span><ins>+    Strong&lt;Structure&gt; scriptFetcherStructure;
</ins><span class="cx">     Strong&lt;Structure&gt; structureChainStructure;
</span><span class="cx">     Strong&lt;Structure&gt; sparseArrayValueMapStructure;
</span><span class="cx">     Strong&lt;Structure&gt; templateRegistryKeyStructure;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/ChangeLog        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -1,3 +1,80 @@
</span><ins>+2017-01-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Decouple module loading initiator from ScriptElement
+        https://bugs.webkit.org/show_bug.cgi?id=166888
+
+        Reviewed by Saam Barati and Ryosuke Niwa.
+
+        Previously, we use ScriptElement (JSElement for ScriptElement) as the module loading initiator.
+        This element is used to transfer the metadata like charset throughout the module pipeline.
+        As a result, our module loader in the browser side is tightly coupled with ScriptElement.
+        It is not good since it prevent us from using the module loader in the non-DOM environment like
+        Web Workers.
+
+        So we decouple the necessary informations from ScriptElement. We move these information to
+        LoadableScript. And we use JSScriptFetcher to transfer LoadableScript through the JS implemented
+        module loader pipeline. We select LoadableScript instead of LoadableModuleScript since this initiator
+        information will be leveraged even in classic scripts once we implement the dynamic import.
+
+        No behavior change.
+
+        * ForwardingHeaders/runtime/JSScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
+        * ForwardingHeaders/runtime/ScriptFetcher.h: Copied from Source/WebCore/dom/LoadableScript.cpp.
+        * bindings/js/CachedModuleScript.cpp:
+        (WebCore::CachedModuleScript::create):
+        (WebCore::CachedModuleScript::load):
+        (WebCore::CachedModuleScript::CachedModuleScript): Deleted.
+        * bindings/js/CachedModuleScript.h:
+        Now we can merge CachedModuleScript to LoadableScript. But we do not do this in this patch since
+        we focus on decoupling the initiator information from ScriptElement.
+
+        (WebCore::CachedModuleScript::nonce): Deleted.
+        (WebCore::CachedModuleScript::crossOriginMode): Deleted.
+        * bindings/js/CachedModuleScriptLoader.cpp:
+        (WebCore::CachedModuleScriptLoader::load):
+        * bindings/js/CachedModuleScriptLoader.h:
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::moduleLoaderResolve):
+        (WebCore::JSDOMWindowBase::moduleLoaderFetch):
+        (WebCore::JSDOMWindowBase::moduleLoaderEvaluate):
+        * bindings/js/JSMainThreadExecState.h:
+        (WebCore::JSMainThreadExecState::loadModule):
+        (WebCore::JSMainThreadExecState::linkAndEvaluateModule):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::loadModuleScriptInWorld):
+        (WebCore::ScriptController::loadModuleScript):
+        (WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
+        (WebCore::ScriptController::linkAndEvaluateModuleScript):
+        * bindings/js/ScriptController.h:
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::fetch):
+        * bindings/js/ScriptModuleLoader.h:
+        * dom/LoadableClassicScript.cpp:
+        (WebCore::LoadableClassicScript::create):
+        (WebCore::LoadableClassicScript::~LoadableClassicScript):
+        (WebCore::LoadableClassicScript::isLoaded):
+        (WebCore::LoadableClassicScript::error):
+        (WebCore::LoadableClassicScript::wasCanceled):
+        (WebCore::LoadableClassicScript::notifyFinished):
+        (WebCore::LoadableClassicScript::load):
+        * dom/LoadableClassicScript.h:
+        * dom/LoadableModuleScript.cpp:
+        (WebCore::LoadableModuleScript::create):
+        (WebCore::LoadableModuleScript::LoadableModuleScript):
+        (WebCore::LoadableModuleScript::load):
+        * dom/LoadableModuleScript.h:
+        * dom/LoadableScript.cpp:
+        (WebCore::LoadableScript::requestScriptWithCache):
+        * dom/LoadableScript.h:
+        (WebCore::LoadableScript::LoadableScript):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::requestClassicScript):
+        (WebCore::ScriptElement::requestModuleScript):
+        (WebCore::ScriptElement::executeModuleScript):
+        (WebCore::ScriptElement::requestScriptWithCacheForModuleScript): Deleted.
+        (WebCore::ScriptElement::requestScriptWithCache): Deleted.
+        * dom/ScriptElement.h:
+
</ins><span class="cx"> 2017-01-11  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] Use smart pointers and modernize code in WebKitWebAudioSourceGStreamer
</span></span></pre></div>
<a id="trunkSourceWebCoreForwardingHeadersruntimeJSScriptFetcherhfromrev210584trunkSourceWebCoredomLoadableScriptcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/ForwardingHeaders/runtime/JSScriptFetcher.h (from rev 210584, trunk/Source/WebCore/dom/LoadableScript.cpp) (0 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ForwardingHeaders/runtime/JSScriptFetcher.h                                (rev 0)
+++ trunk/Source/WebCore/ForwardingHeaders/runtime/JSScriptFetcher.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+/*
+ * Copyright (C) 2017 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * 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;JavaScriptCore/JSScriptFetcher.h&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreForwardingHeadersruntimeScriptFetcherhfromrev210584trunkSourceWebCoredomLoadableScriptcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/ForwardingHeaders/runtime/ScriptFetcher.h (from rev 210584, trunk/Source/WebCore/dom/LoadableScript.cpp) (0 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ForwardingHeaders/runtime/ScriptFetcher.h                                (rev 0)
+++ trunk/Source/WebCore/ForwardingHeaders/runtime/ScriptFetcher.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+/*
+ * Copyright (C) 2017 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * 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;JavaScriptCore/ScriptFetcher.h&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsCachedModuleScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -29,11 +29,9 @@
</span><span class="cx"> #include &quot;CachedModuleScriptClient.h&quot;
</span><span class="cx"> #include &quot;DOMWrapperWorld.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><del>-#include &quot;Element.h&quot;
</del><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><del>-#include &quot;ScriptElement.h&quot;
</del><span class="cx"> #include &quot;ScriptModuleLoader.h&quot;
</span><span class="cx"> #include &quot;ScriptRunner.h&quot;
</span><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="lines">@@ -40,29 +38,23 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-Ref&lt;CachedModuleScript&gt; CachedModuleScript::create(const String&amp; nonce, const String&amp; crossOriginMode)
</del><ins>+Ref&lt;CachedModuleScript&gt; CachedModuleScript::create()
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new CachedModuleScript(nonce, crossOriginMode));
</del><ins>+    return adoptRef(*new CachedModuleScript());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-CachedModuleScript::CachedModuleScript(const String&amp; nonce, const String&amp; crossOriginMode)
-    : m_nonce(nonce)
-    , m_crossOriginMode(crossOriginMode)
</del><ins>+void CachedModuleScript::load(Document&amp; document, const URL&amp; rootURL, LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><ins>+    if (auto* frame = document.frame())
+        frame-&gt;script().loadModuleScript(*this, rootURL.string(), loadableScript);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CachedModuleScript::load(Element&amp; initiator, const URL&amp; rootURL)
</del><ins>+void CachedModuleScript::load(Document&amp; document, const ScriptSourceCode&amp; sourceCode, LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><del>-    if (auto* frame = initiator.document().frame())
-        frame-&gt;script().loadModuleScript(*this, rootURL.string(), initiator);
</del><ins>+    if (auto* frame = document.frame())
+        frame-&gt;script().loadModuleScript(*this, sourceCode, loadableScript);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CachedModuleScript::load(Element&amp; initiator, const ScriptSourceCode&amp; sourceCode)
-{
-    if (auto* frame = initiator.document().frame())
-        frame-&gt;script().loadModuleScript(*this, sourceCode, initiator);
-}
-
</del><span class="cx"> void CachedModuleScript::notifyLoadCompleted(UniquedStringImpl&amp; moduleKey)
</span><span class="cx"> {
</span><span class="cx">     m_moduleKey = &amp;moduleKey;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsCachedModuleScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/CachedModuleScript.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/CachedModuleScript.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScript.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class CachedModuleScriptClient;
</span><del>-class Element;
</del><ins>+class Document;
</ins><span class="cx"> class ScriptSourceCode;
</span><span class="cx"> 
</span><span class="cx"> class CachedModuleScript : public RefCounted&lt;CachedModuleScript&gt; {
</span><span class="lines">@@ -39,8 +39,6 @@
</span><span class="cx"> public:
</span><span class="cx">     UniquedStringImpl* moduleKey() { return m_moduleKey.get(); }
</span><span class="cx"> 
</span><del>-    void evaluate(Element&amp;);
-
</del><span class="cx">     void notifyLoadCompleted(UniquedStringImpl&amp; moduleKey);
</span><span class="cx">     void notifyLoadFailed(LoadableScript::Error&amp;&amp;);
</span><span class="cx">     void notifyLoadWasCanceled();
</span><span class="lines">@@ -52,23 +50,16 @@
</span><span class="cx">     void addClient(CachedModuleScriptClient&amp;);
</span><span class="cx">     void removeClient(CachedModuleScriptClient&amp;);
</span><span class="cx"> 
</span><del>-    static Ref&lt;CachedModuleScript&gt; create(const String&amp; nonce, const String&amp; crossOriginMode);
</del><ins>+    static Ref&lt;CachedModuleScript&gt; create();
</ins><span class="cx"> 
</span><del>-    void load(Element&amp; initiator, const URL&amp; rootURL);
-    void load(Element&amp; initiator, const ScriptSourceCode&amp;);
</del><ins>+    void load(Document&amp;, const URL&amp; rootURL, LoadableScript&amp;);
+    void load(Document&amp;, const ScriptSourceCode&amp;, LoadableScript&amp;);
</ins><span class="cx"> 
</span><del>-    const String&amp; nonce() const { return m_nonce; }
-    const String&amp; crossOriginMode() const { return m_crossOriginMode; }
-
</del><span class="cx"> private:
</span><del>-    CachedModuleScript(const String&amp; nonce, const String&amp; crossOriginMode);
-
</del><span class="cx">     void notifyClientFinished();
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;UniquedStringImpl&gt; m_moduleKey;
</span><span class="cx">     HashCountedSet&lt;CachedModuleScriptClient*&gt; m_clients;
</span><del>-    String m_nonce;
-    String m_crossOriginMode;
</del><span class="cx">     std::optional&lt;LoadableScript::Error&gt; m_error;
</span><span class="cx">     bool m_wasCanceled { false };
</span><span class="cx">     bool m_isLoaded { false };
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsCachedModuleScriptLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -26,14 +26,13 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;CachedModuleScriptLoader.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;CachedResourceLoader.h&quot;
</del><span class="cx"> #include &quot;CachedScript.h&quot;
</span><span class="cx"> #include &quot;DOMWrapperWorld.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;JSDOMBinding.h&quot;
</span><ins>+#include &quot;LoadableScript.h&quot;
</ins><span class="cx"> #include &quot;ResourceLoaderOptions.h&quot;
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><del>-#include &quot;ScriptElement.h&quot;
</del><span class="cx"> #include &quot;ScriptModuleLoader.h&quot;
</span><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -58,10 +57,10 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CachedModuleScriptLoader::load(ScriptElement&amp; scriptElement, const URL&amp; sourceURL)
</del><ins>+bool CachedModuleScriptLoader::load(Document&amp; document, LoadableScript&amp; loadableScript, const URL&amp; sourceURL)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_cachedScript);
</span><del>-    m_cachedScript = scriptElement.requestScriptWithCacheForModuleScript(sourceURL);
</del><ins>+    m_cachedScript = loadableScript.requestScriptWithCache(document, sourceURL);
</ins><span class="cx">     if (!m_cachedScript)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsCachedModuleScriptLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -36,8 +36,9 @@
</span><span class="cx"> class CachedModuleScriptLoaderClient;
</span><span class="cx"> class CachedScript;
</span><span class="cx"> class DeferredPromise;
</span><ins>+class Document;
</ins><span class="cx"> class JSDOMGlobalObject;
</span><del>-class ScriptElement;
</del><ins>+class LoadableScript;
</ins><span class="cx"> class URL;
</span><span class="cx"> 
</span><span class="cx"> class CachedModuleScriptLoader final : public RefCounted&lt;CachedModuleScriptLoader&gt;, private CachedResourceClient {
</span><span class="lines">@@ -46,7 +47,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual ~CachedModuleScriptLoader();
</span><span class="cx"> 
</span><del>-    bool load(ScriptElement&amp;, const URL&amp; sourceURL);
</del><ins>+    bool load(Document&amp;, LoadableScript&amp;, const URL&amp; sourceURL);
</ins><span class="cx"> 
</span><span class="cx">     CachedScript* cachedScript() { return m_cachedScript.get(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -305,29 +305,29 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue initiator)
</del><ins>+JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSDOMWindowBase* thisObject = JSC::jsCast&lt;JSDOMWindowBase*&gt;(globalObject);
</span><span class="cx">     if (RefPtr&lt;Document&gt; document = thisObject-&gt;wrapped().document())
</span><del>-        return document-&gt;moduleLoader()-&gt;resolve(globalObject, exec, moduleLoader, moduleName, importerModuleKey, initiator);
</del><ins>+        return document-&gt;moduleLoader()-&gt;resolve(globalObject, exec, moduleLoader, moduleName, importerModuleKey, scriptFetcher);
</ins><span class="cx">     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
</span><span class="cx">     return deferred-&gt;reject(exec, jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue initiator)
</del><ins>+JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSDOMWindowBase* thisObject = JSC::jsCast&lt;JSDOMWindowBase*&gt;(globalObject);
</span><span class="cx">     if (RefPtr&lt;Document&gt; document = thisObject-&gt;wrapped().document())
</span><del>-        return document-&gt;moduleLoader()-&gt;fetch(globalObject, exec, moduleLoader, moduleKey, initiator);
</del><ins>+        return document-&gt;moduleLoader()-&gt;fetch(globalObject, exec, moduleLoader, moduleKey, scriptFetcher);
</ins><span class="cx">     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
</span><span class="cx">     return deferred-&gt;reject(exec, jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue initiator)
</del><ins>+JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher)
</ins><span class="cx"> {
</span><span class="cx">     JSDOMWindowBase* thisObject = JSC::jsCast&lt;JSDOMWindowBase*&gt;(globalObject);
</span><span class="cx">     if (RefPtr&lt;Document&gt; document = thisObject-&gt;wrapped().document())
</span><del>-        return document-&gt;moduleLoader()-&gt;evaluate(globalObject, exec, moduleLoader, moduleKey, moduleRecord, initiator);
</del><ins>+        return document-&gt;moduleLoader()-&gt;evaluate(globalObject, exec, moduleLoader, moduleKey, moduleRecord, scriptFetcher);
</ins><span class="cx">     return JSC::jsUndefined();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSMainThreadExecStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -93,25 +93,25 @@
</span><span class="cx">         task.run(exec);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static JSC::JSInternalPromise&amp; loadModule(JSC::ExecState&amp; state, const String&amp; moduleName, JSC::JSValue initiator)
</del><ins>+    static JSC::JSInternalPromise&amp; loadModule(JSC::ExecState&amp; state, const String&amp; moduleName, JSC::JSValue scriptFetcher)
</ins><span class="cx">     {
</span><span class="cx">         JSMainThreadExecState currentState(&amp;state);
</span><del>-        return *JSC::loadModule(&amp;state, moduleName, initiator);
</del><ins>+        return *JSC::loadModule(&amp;state, moduleName, scriptFetcher);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static JSC::JSInternalPromise&amp; loadModule(JSC::ExecState&amp; state, const JSC::SourceCode&amp; sourceCode, JSC::JSValue initiator)
</del><ins>+    static JSC::JSInternalPromise&amp; loadModule(JSC::ExecState&amp; state, const JSC::SourceCode&amp; sourceCode, JSC::JSValue scriptFetcher)
</ins><span class="cx">     {
</span><span class="cx">         JSMainThreadExecState currentState(&amp;state);
</span><del>-        return *JSC::loadModule(&amp;state, sourceCode, initiator);
</del><ins>+        return *JSC::loadModule(&amp;state, sourceCode, scriptFetcher);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static JSC::JSValue linkAndEvaluateModule(JSC::ExecState&amp; state, const JSC::Identifier&amp; moduleKey, JSC::JSValue initiator, NakedPtr&lt;JSC::Exception&gt;&amp; returnedException)
</del><ins>+    static JSC::JSValue linkAndEvaluateModule(JSC::ExecState&amp; state, const JSC::Identifier&amp; moduleKey, JSC::JSValue scriptFetcher, NakedPtr&lt;JSC::Exception&gt;&amp; returnedException)
</ins><span class="cx">     {
</span><span class="cx">         JSC::VM&amp; vm = state.vm();
</span><span class="cx">         auto scope = DECLARE_CATCH_SCOPE(vm);
</span><span class="cx">     
</span><span class="cx">         JSMainThreadExecState currentState(&amp;state);
</span><del>-        auto returnValue = JSC::linkAndEvaluateModule(&amp;state, moduleKey, initiator);
</del><ins>+        auto returnValue = JSC::linkAndEvaluateModule(&amp;state, moduleKey, scriptFetcher);
</ins><span class="cx">         if (UNLIKELY(scope.exception())) {
</span><span class="cx">             returnedException = scope.exception();
</span><span class="cx">             scope.clearException();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptController.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -43,7 +43,6 @@
</span><span class="cx"> #include &quot;PageConsoleClient.h&quot;
</span><span class="cx"> #include &quot;PageGroup.h&quot;
</span><span class="cx"> #include &quot;PluginViewBase.h&quot;
</span><del>-#include &quot;ScriptElement.h&quot;
</del><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="cx"> #include &quot;ScriptableDocumentParser.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="lines">@@ -60,6 +59,7 @@
</span><span class="cx"> #include &lt;runtime/JSLock.h&gt;
</span><span class="cx"> #include &lt;runtime/JSModuleRecord.h&gt;
</span><span class="cx"> #include &lt;runtime/JSNativeStdFunction.h&gt;
</span><ins>+#include &lt;runtime/JSScriptFetcher.h&gt;
</ins><span class="cx"> #include &lt;wtf/SetForScope.h&gt;
</span><span class="cx"> #include &lt;wtf/Threading.h&gt;
</span><span class="cx"> #include &lt;wtf/text/TextPosition.h&gt;
</span><span class="lines">@@ -186,7 +186,7 @@
</span><span class="cx">     return evaluateInWorld(sourceCode, mainThreadNormalWorld(), exceptionDetails);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptController::loadModuleScriptInWorld(CachedModuleScript&amp; moduleScript, const String&amp; moduleName, DOMWrapperWorld&amp; world, Element&amp; element)
</del><ins>+void ScriptController::loadModuleScriptInWorld(CachedModuleScript&amp; moduleScript, const String&amp; moduleName, LoadableScript&amp; loadableScript, DOMWrapperWorld&amp; world)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(world.vm());
</span><span class="cx"> 
</span><span class="lines">@@ -193,16 +193,16 @@
</span><span class="cx">     auto&amp; shell = *windowShell(world);
</span><span class="cx">     auto&amp; state = *shell.window()-&gt;globalExec();
</span><span class="cx"> 
</span><del>-    auto&amp; promise = JSMainThreadExecState::loadModule(state, moduleName, toJS(&amp;state, shell.window(), &amp;element));
</del><ins>+    auto&amp; promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetcher::create(state.vm(), { &amp;loadableScript }));
</ins><span class="cx">     setupModuleScriptHandlers(moduleScript, promise, world);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptController::loadModuleScript(CachedModuleScript&amp; moduleScript, const String&amp; moduleName, Element&amp; element)
</del><ins>+void ScriptController::loadModuleScript(CachedModuleScript&amp; moduleScript, const String&amp; moduleName, LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><del>-    loadModuleScriptInWorld(moduleScript, moduleName, mainThreadNormalWorld(), element);
</del><ins>+    loadModuleScriptInWorld(moduleScript, moduleName, loadableScript, mainThreadNormalWorld());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptController::loadModuleScriptInWorld(CachedModuleScript&amp; moduleScript, const ScriptSourceCode&amp; sourceCode, DOMWrapperWorld&amp; world, Element&amp; element)
</del><ins>+void ScriptController::loadModuleScriptInWorld(CachedModuleScript&amp; moduleScript, const ScriptSourceCode&amp; sourceCode, LoadableScript&amp; loadableScript, DOMWrapperWorld&amp; world)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(world.vm());
</span><span class="cx"> 
</span><span class="lines">@@ -209,16 +209,16 @@
</span><span class="cx">     auto&amp; shell = *windowShell(world);
</span><span class="cx">     auto&amp; state = *shell.window()-&gt;globalExec();
</span><span class="cx"> 
</span><del>-    auto&amp; promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), toJS(&amp;state, shell.window(), &amp;element));
</del><ins>+    auto&amp; promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &amp;loadableScript }));
</ins><span class="cx">     setupModuleScriptHandlers(moduleScript, promise, world);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ScriptController::loadModuleScript(CachedModuleScript&amp; moduleScript, const ScriptSourceCode&amp; sourceCode, Element&amp; element)
</del><ins>+void ScriptController::loadModuleScript(CachedModuleScript&amp; moduleScript, const ScriptSourceCode&amp; sourceCode, LoadableScript&amp; loadableScript)
</ins><span class="cx"> {
</span><del>-    loadModuleScriptInWorld(moduleScript, sourceCode, mainThreadNormalWorld(), element);
</del><ins>+    loadModuleScriptInWorld(moduleScript, sourceCode, loadableScript, mainThreadNormalWorld());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSValue ScriptController::linkAndEvaluateModuleScriptInWorld(CachedModuleScript&amp; moduleScript, DOMWrapperWorld&amp; world, Element&amp; element)
</del><ins>+JSC::JSValue ScriptController::linkAndEvaluateModuleScriptInWorld(CachedModuleScript&amp; moduleScript, DOMWrapperWorld&amp; world)
</ins><span class="cx"> {
</span><span class="cx">     JSLockHolder lock(world.vm());
</span><span class="cx"> 
</span><span class="lines">@@ -230,7 +230,7 @@
</span><span class="cx">     Ref&lt;Frame&gt; protector(m_frame);
</span><span class="cx"> 
</span><span class="cx">     NakedPtr&lt;JSC::Exception&gt; evaluationException;
</span><del>-    auto returnValue = JSMainThreadExecState::linkAndEvaluateModule(state, Identifier::fromUid(&amp;state.vm(), moduleScript.moduleKey()), toJS(&amp;state, shell.window(), &amp;element), evaluationException);
</del><ins>+    auto returnValue = JSMainThreadExecState::linkAndEvaluateModule(state, Identifier::fromUid(&amp;state.vm(), moduleScript.moduleKey()), jsUndefined(), evaluationException);
</ins><span class="cx">     if (evaluationException) {
</span><span class="cx">         // FIXME: Give a chance to dump the stack trace if the &quot;crossorigin&quot; attribute allows.
</span><span class="cx">         // https://bugs.webkit.org/show_bug.cgi?id=164539
</span><span class="lines">@@ -240,9 +240,9 @@
</span><span class="cx">     return returnValue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSValue ScriptController::linkAndEvaluateModuleScript(CachedModuleScript&amp; moduleScript, Element&amp; element)
</del><ins>+JSC::JSValue ScriptController::linkAndEvaluateModuleScript(CachedModuleScript&amp; moduleScript)
</ins><span class="cx"> {
</span><del>-    return linkAndEvaluateModuleScriptInWorld(moduleScript, mainThreadNormalWorld(), element);
</del><ins>+    return linkAndEvaluateModuleScriptInWorld(moduleScript, mainThreadNormalWorld());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSC::JSValue ScriptController::evaluateModule(const URL&amp; sourceURL, JSModuleRecord&amp; moduleRecord, DOMWrapperWorld&amp; world)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptController.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> class Frame;
</span><span class="cx"> class HTMLDocument;
</span><span class="cx"> class HTMLPlugInElement;
</span><ins>+class LoadableScript;
</ins><span class="cx"> class SecurityOrigin;
</span><span class="cx"> class ScriptSourceCode;
</span><span class="cx"> class Widget;
</span><span class="lines">@@ -113,13 +114,13 @@
</span><span class="cx">     JSC::JSValue evaluate(const ScriptSourceCode&amp;, ExceptionDetails* = nullptr);
</span><span class="cx">     JSC::JSValue evaluateInWorld(const ScriptSourceCode&amp;, DOMWrapperWorld&amp;, ExceptionDetails* = nullptr);
</span><span class="cx"> 
</span><del>-    void loadModuleScriptInWorld(CachedModuleScript&amp;, const String&amp; moduleName, DOMWrapperWorld&amp;, Element&amp;);
-    void loadModuleScript(CachedModuleScript&amp;, const String&amp; moduleName, Element&amp;);
-    void loadModuleScriptInWorld(CachedModuleScript&amp;, const ScriptSourceCode&amp;, DOMWrapperWorld&amp;, Element&amp;);
-    void loadModuleScript(CachedModuleScript&amp;, const ScriptSourceCode&amp;, Element&amp;);
</del><ins>+    void loadModuleScriptInWorld(CachedModuleScript&amp;, const String&amp; moduleName, LoadableScript&amp;, DOMWrapperWorld&amp;);
+    void loadModuleScript(CachedModuleScript&amp;, const String&amp; moduleName, LoadableScript&amp;);
+    void loadModuleScriptInWorld(CachedModuleScript&amp;, const ScriptSourceCode&amp;, LoadableScript&amp;, DOMWrapperWorld&amp;);
+    void loadModuleScript(CachedModuleScript&amp;, const ScriptSourceCode&amp;, LoadableScript&amp;);
</ins><span class="cx"> 
</span><del>-    JSC::JSValue linkAndEvaluateModuleScriptInWorld(CachedModuleScript&amp; , DOMWrapperWorld&amp;, Element&amp;);
-    JSC::JSValue linkAndEvaluateModuleScript(CachedModuleScript&amp;, Element&amp;);
</del><ins>+    JSC::JSValue linkAndEvaluateModuleScriptInWorld(CachedModuleScript&amp; , DOMWrapperWorld&amp;);
+    JSC::JSValue linkAndEvaluateModuleScript(CachedModuleScript&amp;);
</ins><span class="cx"> 
</span><span class="cx">     JSC::JSValue evaluateModule(const URL&amp;, JSC::JSModuleRecord&amp;, DOMWrapperWorld&amp;);
</span><span class="cx">     JSC::JSValue evaluateModule(const URL&amp;, JSC::JSModuleRecord&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptModuleLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -31,15 +31,14 @@
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;JSDOMBinding.h&quot;
</span><del>-#include &quot;JSElement.h&quot;
</del><span class="cx"> #include &quot;LoadableModuleScript.h&quot;
</span><span class="cx"> #include &quot;MIMETypeRegistry.h&quot;
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><del>-#include &quot;ScriptElement.h&quot;
</del><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="cx"> #include &lt;runtime/JSInternalPromise.h&gt;
</span><span class="cx"> #include &lt;runtime/JSInternalPromiseDeferred.h&gt;
</span><span class="cx"> #include &lt;runtime/JSModuleRecord.h&gt;
</span><ins>+#include &lt;runtime/JSScriptFetcher.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSSourceCode.h&gt;
</span><span class="cx"> #include &lt;runtime/JSString.h&gt;
</span><span class="cx"> #include &lt;runtime/Symbol.h&gt;
</span><span class="lines">@@ -134,11 +133,9 @@
</span><span class="cx">     return jsPromise.promise();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue initiator)
</del><ins>+JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue scriptFetcher)
</ins><span class="cx"> {
</span><del>-    // FIXME: What guarantees these are true? Why don't we need to check?
-    ASSERT(JSC::jsDynamicCast&lt;JSElement*&gt;(initiator));
-    ASSERT(isScriptElement(JSC::jsDynamicCast&lt;JSElement*&gt;(initiator)-&gt;wrapped()));
</del><ins>+    ASSERT(JSC::jsDynamicCast&lt;JSC::JSScriptFetcher*&gt;(scriptFetcher));
</ins><span class="cx"> 
</span><span class="cx">     auto&amp; globalObject = *JSC::jsCast&lt;JSDOMGlobalObject*&gt;(jsGlobalObject);
</span><span class="cx">     auto&amp; jsPromise = *JSC::JSInternalPromiseDeferred::create(exec, &amp;globalObject);
</span><span class="lines">@@ -164,7 +161,7 @@
</span><span class="cx">     if (auto* frame = m_document.frame()) {
</span><span class="cx">         auto loader = CachedModuleScriptLoader::create(*this, deferred.get());
</span><span class="cx">         m_loaders.add(loader.copyRef());
</span><del>-        if (!loader-&gt;load(downcastScriptElement(JSC::jsCast&lt;JSElement*&gt;(initiator)-&gt;wrapped()), completedURL)) {
</del><ins>+        if (!loader-&gt;load(m_document, *static_cast&lt;LoadableScript*&gt;(JSC::jsCast&lt;JSC::JSScriptFetcher*&gt;(scriptFetcher)-&gt;fetcher()), completedURL)) {
</ins><span class="cx">             loader-&gt;clearClient();
</span><span class="cx">             m_loaders.remove(WTFMove(loader));
</span><span class="cx">             deferred-&gt;reject(frame-&gt;script().moduleLoaderAlreadyReportedErrorSymbol());
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptModuleLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -54,9 +54,9 @@
</span><span class="cx"> 
</span><span class="cx">     Document&amp; document() { return m_document; }
</span><span class="cx"> 
</span><del>-    JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue initiator);
-    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue initiator);
-    JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue initiator);
</del><ins>+    JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher);
+    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue scriptFetcher);
+    JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void notifyFinished(CachedModuleScriptLoader&amp;, RefPtr&lt;DeferredPromise&gt;) final;
</span></span></pre></div>
<a id="trunkSourceWebCoredomLoadableClassicScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableClassicScript.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableClassicScript.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableClassicScript.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -33,26 +33,26 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-Ref&lt;LoadableClassicScript&gt; LoadableClassicScript::create(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp; cachedScript)
</del><ins>+Ref&lt;LoadableClassicScript&gt; LoadableClassicScript::create(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree)
</ins><span class="cx"> {
</span><del>-    ASSERT(cachedScript);
-    auto script = adoptRef(*new LoadableClassicScript(WTFMove(cachedScript)));
-    cachedScript-&gt;addClient(script.get());
-    return script;
</del><ins>+    return adoptRef(*new LoadableClassicScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LoadableClassicScript::~LoadableClassicScript()
</span><span class="cx"> {
</span><del>-    m_cachedScript-&gt;removeClient(*this);
</del><ins>+    if (m_cachedScript)
+        m_cachedScript-&gt;removeClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool LoadableClassicScript::isLoaded() const
</span><span class="cx"> {
</span><ins>+    ASSERT(m_cachedScript);
</ins><span class="cx">     return m_cachedScript-&gt;isLoaded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::optional&lt;LoadableScript::Error&gt; LoadableClassicScript::error() const
</span><span class="cx"> {
</span><ins>+    ASSERT(m_cachedScript);
</ins><span class="cx">     if (m_error)
</span><span class="cx">         return m_error;
</span><span class="cx"> 
</span><span class="lines">@@ -64,11 +64,13 @@
</span><span class="cx"> 
</span><span class="cx"> bool LoadableClassicScript::wasCanceled() const
</span><span class="cx"> {
</span><ins>+    ASSERT(m_cachedScript);
</ins><span class="cx">     return m_cachedScript-&gt;wasCanceled();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LoadableClassicScript::notifyFinished(CachedResource&amp; resource)
</span><span class="cx"> {
</span><ins>+    ASSERT(m_cachedScript);
</ins><span class="cx">     if (resource.resourceError().isAccessControl()) {
</span><span class="cx">         static NeverDestroyed&lt;String&gt; consoleMessage(ASCIILiteral(&quot;Cross-origin script load denied by Cross-Origin Resource Sharing policy.&quot;));
</span><span class="cx">         m_error = Error {
</span><span class="lines">@@ -105,4 +107,14 @@
</span><span class="cx">     scriptElement.executeClassicScript(ScriptSourceCode(m_cachedScript.get(), JSC::SourceProviderSourceType::Program));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool LoadableClassicScript::load(Document&amp; document, const URL&amp; sourceURL)
+{
+    ASSERT(!m_cachedScript);
+    m_cachedScript = requestScriptWithCache(document, sourceURL);
+    if (!m_cachedScript)
+        return false;
+    m_cachedScript-&gt;addClient(*this);
+    return true;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableClassicScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableClassicScript.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableClassicScript.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableClassicScript.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual ~LoadableClassicScript();
</span><span class="cx"> 
</span><del>-    static Ref&lt;LoadableClassicScript&gt; create(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp;);
</del><ins>+    static Ref&lt;LoadableClassicScript&gt; create(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree);
</ins><span class="cx">     bool isLoaded() const final;
</span><span class="cx">     std::optional&lt;Error&gt; error() const final;
</span><span class="cx">     bool wasCanceled() const final;
</span><span class="lines">@@ -52,12 +52,17 @@
</span><span class="cx"> 
</span><span class="cx">     void execute(ScriptElement&amp;) final;
</span><span class="cx"> 
</span><ins>+    bool load(Document&amp;, const URL&amp;);
+
</ins><span class="cx"> private:
</span><del>-    LoadableClassicScript(CachedResourceHandle&lt;CachedScript&gt;&amp;&amp; cachedScript) : m_cachedScript(WTFMove(cachedScript)) { }
</del><ins>+    LoadableClassicScript(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree)
+        : LoadableScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
+    {
+    }
</ins><span class="cx"> 
</span><span class="cx">     void notifyFinished(CachedResource&amp;) final;
</span><span class="cx"> 
</span><del>-    CachedResourceHandle&lt;CachedScript&gt; m_cachedScript;
</del><ins>+    CachedResourceHandle&lt;CachedScript&gt; m_cachedScript { };
</ins><span class="cx">     std::optional&lt;Error&gt; m_error { std::nullopt };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomLoadableModuleScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableModuleScript.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableModuleScript.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableModuleScript.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -30,16 +30,16 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-Ref&lt;LoadableModuleScript&gt; LoadableModuleScript::create(CachedModuleScript&amp; moduleScript)
</del><ins>+Ref&lt;LoadableModuleScript&gt; LoadableModuleScript::create(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree)
</ins><span class="cx"> {
</span><del>-    auto script = adoptRef(*new LoadableModuleScript(moduleScript));
-    moduleScript.addClient(script.get());
-    return script;
</del><ins>+    return adoptRef(*new LoadableModuleScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree, CachedModuleScript::create()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-LoadableModuleScript::LoadableModuleScript(CachedModuleScript&amp; moduleScript)
-    : m_moduleScript(moduleScript)
</del><ins>+LoadableModuleScript::LoadableModuleScript(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree, Ref&lt;CachedModuleScript&gt;&amp;&amp; moduleScript)
+    : LoadableScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
+    , m_moduleScript(WTFMove(moduleScript))
</ins><span class="cx"> {
</span><ins>+    m_moduleScript-&gt;addClient(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LoadableModuleScript::~LoadableModuleScript()
</span><span class="lines">@@ -72,4 +72,14 @@
</span><span class="cx">     scriptElement.executeModuleScript(m_moduleScript.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void LoadableModuleScript::load(Document&amp; document, const URL&amp; rootURL)
+{
+    m_moduleScript-&gt;load(document, rootURL, *this);
</ins><span class="cx"> }
</span><ins>+
+void LoadableModuleScript::load(Document&amp; document, const ScriptSourceCode&amp; sourceCode)
+{
+    m_moduleScript-&gt;load(document, sourceCode, *this);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableModuleScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableModuleScript.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableModuleScript.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableModuleScript.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual ~LoadableModuleScript();
</span><span class="cx"> 
</span><del>-    static Ref&lt;LoadableModuleScript&gt; create(CachedModuleScript&amp;);
</del><ins>+    static Ref&lt;LoadableModuleScript&gt; create(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree);
</ins><span class="cx"> 
</span><span class="cx">     bool isLoaded() const final;
</span><span class="cx">     std::optional&lt;Error&gt; error() const final;
</span><span class="lines">@@ -49,8 +49,11 @@
</span><span class="cx"> 
</span><span class="cx">     void setError(Error&amp;&amp;);
</span><span class="cx"> 
</span><ins>+    void load(Document&amp;, const URL&amp; rootURL);
+    void load(Document&amp;, const ScriptSourceCode&amp;);
+
</ins><span class="cx"> private:
</span><del>-    LoadableModuleScript(CachedModuleScript&amp;);
</del><ins>+    LoadableModuleScript(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree, Ref&lt;CachedModuleScript&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void notifyFinished(CachedModuleScript&amp;) final;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomLoadableScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableScript.cpp (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableScript.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableScript.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -26,7 +26,12 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;LoadableScript.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CachedResourceLoader.h&quot;
+#include &quot;CachedScript.h&quot;
+#include &quot;ContentSecurityPolicy.h&quot;
+#include &quot;Document.h&quot;
</ins><span class="cx"> #include &quot;LoadableScriptClient.h&quot;
</span><ins>+#include &quot;Settings.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -55,4 +60,25 @@
</span><span class="cx">         client-&gt;notifyFinished(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+CachedResourceHandle&lt;CachedScript&gt; LoadableScript::requestScriptWithCache(Document&amp; document, const URL&amp; sourceURL) const
+{
+    auto* settings = document.settings();
+    if (settings &amp;&amp; !settings-&gt;isScriptEnabled())
+        return nullptr;
+
+    ASSERT(document.contentSecurityPolicy());
+    bool hasKnownNonce = document.contentSecurityPolicy()-&gt;allowScriptWithNonce(m_nonce, m_isInUserAgentShadowTree);
+    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+    options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
+
+    CachedResourceRequest request(ResourceRequest(sourceURL), options);
+    request.setAsPotentiallyCrossOrigin(m_crossOriginMode, document);
+    request.upgradeInsecureRequestIfNeeded(document);
+
+    request.setCharset(m_charset);
+    request.setInitiator(m_initiatorName);
+
+    return document.cachedResourceLoader().requestScript(WTFMove(request));
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomLoadableScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LoadableScript.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LoadableScript.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/LoadableScript.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -25,7 +25,9 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include &quot;CachedResourceHandle.h&quot;
</ins><span class="cx"> #include &lt;runtime/ConsoleTypes.h&gt;
</span><ins>+#include &lt;runtime/JSScriptFetcher.h&gt;
</ins><span class="cx"> #include &lt;wtf/HashCountedSet.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -32,10 +34,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class CachedScript;
+class Document;
</ins><span class="cx"> class LoadableScriptClient;
</span><span class="cx"> class ScriptElement;
</span><ins>+class URL;
</ins><span class="cx"> 
</span><del>-class LoadableScript : public RefCounted&lt;LoadableScript&gt; {
</del><ins>+class LoadableScript : public JSC::ScriptFetcher {
</ins><span class="cx"> public:
</span><span class="cx">     enum class ErrorType {
</span><span class="cx">         CachedScript,
</span><span class="lines">@@ -68,10 +73,27 @@
</span><span class="cx">     virtual bool isClassicScript() const { return false; }
</span><span class="cx">     virtual bool isModuleScript() const { return false; }
</span><span class="cx"> 
</span><ins>+    CachedResourceHandle&lt;CachedScript&gt; requestScriptWithCache(Document&amp;, const URL&amp; sourceURL) const;
+
</ins><span class="cx"> protected:
</span><ins>+    LoadableScript(const String&amp; nonce, const String&amp; crossOriginMode, const String&amp; charset, const AtomicString&amp; initiatorName, bool isInUserAgentShadowTree)
+        : m_nonce(nonce)
+        , m_crossOriginMode(crossOriginMode)
+        , m_charset(charset)
+        , m_initiatorName(initiatorName)
+        , m_isInUserAgentShadowTree(isInUserAgentShadowTree)
+    {
+    }
+
</ins><span class="cx">     void notifyClientFinished();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    String m_nonce;
+    String m_crossOriginMode;
+    String m_charset;
+    AtomicString m_initiatorName;
+    bool m_isInUserAgentShadowTree { false };
+
</ins><span class="cx">     HashCountedSet&lt;LoadableScriptClient*&gt; m_clients;
</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 (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.cpp        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -292,11 +292,14 @@
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_loadableScript);
</span><span class="cx">     if (!stripLeadingAndTrailingHTMLSpaces(sourceURL).isEmpty()) {
</span><del>-        String nonceAttribute = m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr);
-        String crossOriginMode = m_element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr);
-        auto request = requestScriptWithCache(m_element.document().completeURL(sourceURL), nonceAttribute, crossOriginMode);
-        if (request) {
-            m_loadableScript = LoadableClassicScript::create(WTFMove(request));
</del><ins>+        auto script = LoadableClassicScript::create(
+            m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr),
+            m_element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr),
+            scriptCharset(),
+            m_element.localName(),
+            m_element.isInUserAgentShadowTree());
+        if (script-&gt;load(m_element.document(), m_element.document().completeURL(sourceURL))) {
+            m_loadableScript = WTFMove(script);
</ins><span class="cx">             m_isExternalScript = true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -339,9 +342,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         m_isExternalScript = true;
</span><del>-        auto moduleScript = CachedModuleScript::create(nonce, crossOriginMode);
-        m_loadableScript = LoadableModuleScript::create(moduleScript.get());
-        moduleScript-&gt;load(m_element, moduleScriptRootURL);
</del><ins>+        auto script = LoadableModuleScript::create(nonce, crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree());
+        script-&gt;load(m_element.document(), moduleScriptRootURL);
+        m_loadableScript = WTFMove(script);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -354,42 +357,12 @@
</span><span class="cx">     if (!contentSecurityPolicy.allowInlineScript(m_element.document().url(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    auto moduleScript = CachedModuleScript::create(nonce, crossOriginMode);
-    m_loadableScript = LoadableModuleScript::create(moduleScript.get());
-    moduleScript-&gt;load(m_element, sourceCode);
</del><ins>+    auto script = LoadableModuleScript::create(nonce, crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree());
+    script-&gt;load(m_element.document(), sourceCode);
+    m_loadableScript = WTFMove(script);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CachedResourceHandle&lt;CachedScript&gt; ScriptElement::requestScriptWithCacheForModuleScript(const URL&amp; sourceURL)
-{
-    ASSERT(m_loadableScript);
-    ASSERT(is&lt;LoadableModuleScript&gt;(*m_loadableScript));
-    auto&amp; moduleScript = downcast&lt;LoadableModuleScript&gt;(*m_loadableScript);
-    return requestScriptWithCache(sourceURL, moduleScript.moduleScript().nonce(), moduleScript.moduleScript().crossOriginMode());
-}
-
-CachedResourceHandle&lt;CachedScript&gt; ScriptElement::requestScriptWithCache(const URL&amp; sourceURL, const String&amp; nonceAttribute, const String&amp; crossOriginMode)
-{
-    Document&amp; document = m_element.document();
-    auto* settings = document.settings();
-    if (settings &amp;&amp; !settings-&gt;isScriptEnabled())
-        return nullptr;
-
-    ASSERT(document.contentSecurityPolicy());
-    bool hasKnownNonce = document.contentSecurityPolicy()-&gt;allowScriptWithNonce(nonceAttribute, m_element.isInUserAgentShadowTree());
-    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
-
-    CachedResourceRequest request(ResourceRequest(sourceURL), options);
-    request.setAsPotentiallyCrossOrigin(crossOriginMode, document);
-    request.upgradeInsecureRequestIfNeeded(document);
-
-    request.setCharset(scriptCharset());
-    request.setInitiator(&amp;element());
-
-    return document.cachedResourceLoader().requestScript(WTFMove(request));
-}
-
</del><span class="cx"> void ScriptElement::executeClassicScript(const ScriptSourceCode&amp; sourceCode)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_alreadyStarted);
</span><span class="lines">@@ -430,7 +403,7 @@
</span><span class="cx">     IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(&amp;document);
</span><span class="cx">     CurrentScriptIncrementer currentScriptIncrementer(document, m_element);
</span><span class="cx"> 
</span><del>-    frame-&gt;script().linkAndEvaluateModuleScript(moduleScript, element());
</del><ins>+    frame-&gt;script().linkAndEvaluateModuleScript(moduleScript);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScriptElement::executeScriptAndDispatchEvent(LoadableScript&amp; loadableScript)
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptElement.h (210584 => 210585)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptElement.h        2017-01-11 11:27:38 UTC (rev 210584)
+++ trunk/Source/WebCore/dom/ScriptElement.h        2017-01-11 12:12:37 UTC (rev 210585)
</span><span class="lines">@@ -66,8 +66,6 @@
</span><span class="cx">     bool willExecuteInOrder() const { return m_willExecuteInOrder; }
</span><span class="cx">     LoadableScript* loadableScript() { return m_loadableScript.get(); }
</span><span class="cx"> 
</span><del>-    CachedResourceHandle&lt;CachedScript&gt; requestScriptWithCacheForModuleScript(const URL&amp;);
-
</del><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">     ScriptType scriptType() const { return m_isModuleScript ? ScriptType::Module : ScriptType::Classic; }
</span></span></pre>
</div>
</div>

</body>
</html>