<!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>[211777] trunk</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>Web Inspector: allow import() inside the inspector
https://bugs.webkit.org/show_bug.cgi?id=167457

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

We relax import module hook to accept null SourceOrigin.
Such a script can be evaluated from the inspector console.

* jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncImportModule):

Source/WebCore:

When evaluating `import(&quot;...&quot;)`, we need the caller's context to resolve
the module specifier correctly. For example, if `import(&quot;./cocoa.js&quot;)` is
evaluated in the script &quot;drinks/hot.js&quot;, this module name is resolved to
&quot;drinks/cocoa.js&quot;. If the same import operator is evaluated in the script
&quot;menu/all.js&quot;, the module specifier becomes &quot;menu/cocoa.js&quot;.

Previously we reject the import operator if the caller does not have such
a context. These context is SourceOrigin and its ScriptFetcher. While they
are offered in the script tag and other code evaluations, the inspector
console does not offer that. These class are offered in the WebCore side
and we should not touch these classes in the JSC's inspector code.

Now we relax the above restriction. If the above caller information is not
offered, we fallback to the default one. In the web page, we use the page's
URL as the caller's source origin. This allows us to evaluate the import
operator in the inspector console.

And as of <a href="http://trac.webkit.org/projects/webkit/changeset/167698">r167698</a>, the console recognizes `await import(&quot;...&quot;)` form. We use
this to test this `import()` in the console functionality.

* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::importModule):

LayoutTests:

* inspector/controller/resources/cappuccino.js: Added.
* inspector/controller/resources/cocoa.js: Added.
* inspector/controller/resources/drink.js: Added.
* inspector/controller/runtime-controller-expected.txt:
* inspector/controller/runtime-controller.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorcontrollerruntimecontrollerexpectedtxt">trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorcontrollerruntimecontrollerhtml">trunk/LayoutTests/inspector/controller/runtime-controller.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectFunctionscpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptModuleLoadercpp">trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/inspector/controller/resources/</li>
<li><a href="#trunkLayoutTestsinspectorcontrollerresourcescappuccinojs">trunk/LayoutTests/inspector/controller/resources/cappuccino.js</a></li>
<li><a href="#trunkLayoutTestsinspectorcontrollerresourcescocoajs">trunk/LayoutTests/inspector/controller/resources/cocoa.js</a></li>
<li><a href="#trunkLayoutTestsinspectorcontrollerresourcesdrinkjs">trunk/LayoutTests/inspector/controller/resources/drink.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/LayoutTests/ChangeLog        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-02-07  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Web Inspector: allow import() inside the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        Reviewed by Ryosuke Niwa.
+
+        * inspector/controller/resources/cappuccino.js: Added.
+        * inspector/controller/resources/cocoa.js: Added.
+        * inspector/controller/resources/drink.js: Added.
+        * inspector/controller/runtime-controller-expected.txt:
+        * inspector/controller/runtime-controller.html:
+
</ins><span class="cx"> 2017-02-06  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Overlay scrolling with iframe-s broken
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcontrollerresourcescappuccinojs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/controller/resources/cappuccino.js (0 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/controller/resources/cappuccino.js                                (rev 0)
+++ trunk/LayoutTests/inspector/controller/resources/cappuccino.js        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+export let name = &quot;Cappuccino&quot;;
+export let taste = &quot;Awesome&quot;;
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcontrollerresourcescocoajs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/controller/resources/cocoa.js (0 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/controller/resources/cocoa.js                                (rev 0)
+++ trunk/LayoutTests/inspector/controller/resources/cocoa.js        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+export let name = &quot;Cocoa&quot;;
+export let taste = &quot;Sweet&quot;;
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcontrollerresourcesdrinkjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/controller/resources/drink.js (0 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/controller/resources/drink.js                                (rev 0)
+++ trunk/LayoutTests/inspector/controller/resources/drink.js        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+import * as Cocoa from './cocoa.js'
+import * as Cappuccino from './cappuccino.js'
+
+export {
+    Cocoa,
+    Cappuccino
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcontrollerruntimecontrollerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -7,6 +7,12 @@
</span><span class="cx"> CONSOLE MESSAGE: line 9: Rejection
</span><span class="cx"> CONSOLE MESSAGE: line 7: %o
</span><span class="cx"> CONSOLE MESSAGE: line 7: %o
</span><ins>+CONSOLE MESSAGE: line 9: TypeError: Module specifier does not start with &quot;/&quot;, &quot;./&quot;, or &quot;../&quot;.
+CONSOLE MESSAGE: line 9: TypeError: Importing a module script failed.
+CONSOLE MESSAGE: line 6: Cocoa is Sweet.
+CONSOLE MESSAGE: line 7: %o
+CONSOLE MESSAGE: line 6: Cocoa is Sweet. Cappuccino is Awesome.
+CONSOLE MESSAGE: line 7: %o
</ins><span class="cx"> Tests for RuntimeManager operations.
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -58,3 +64,13 @@
</span><span class="cx"> Source: x = y = await 10
</span><span class="cx"> PASS: Exception. Should not get transformed and produce a SyntaxError.
</span><span class="cx"> 
</span><ins>+-- Running test case: RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole
+Source: await import('')
+PASS: Transformed. Should log the value or an exception.
+Source: await import('./not-found.js')
+PASS: Transformed. Should log the value or an exception.
+Source: await import('./resources/cocoa.js').then((cocoa) =&gt; console.log(`${cocoa.name} is ${cocoa.taste}.`))
+PASS: Transformed. Should log the value or an exception.
+Source: await import('./resources/drink.js').then((ns) =&gt; console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`))
+PASS: Transformed. Should log the value or an exception.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcontrollerruntimecontrollerhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/controller/runtime-controller.html (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/controller/runtime-controller.html        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/LayoutTests/inspector/controller/runtime-controller.html        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -124,6 +124,26 @@
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><ins>+    suite.addTestCase({
+        name: &quot;RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole&quot;,
+        description: &quot;Test evaluating an import expression from console.&quot;,
+        test(resolve, reject) {
+            function testSource(expression) {
+                WebInspector.runtimeManager.evaluateInInspectedWindow(expression, {objectGroup: &quot;test&quot;}, (result, wasThrown) =&gt; {
+                    InspectorTest.log(&quot;Source: &quot; + expression);
+                    InspectorTest.expectThat(result.isUndefined(), &quot;Transformed. Should log the value or an exception.&quot;);
+                });
+            }
+
+            testSource(&quot;await import('')&quot;);
+            testSource(&quot;await import('./not-found.js')&quot;);
+            testSource(&quot;await import('./resources/cocoa.js').then((cocoa) =&gt; console.log(`${cocoa.name} is ${cocoa.taste}.`))&quot;);
+            testSource(&quot;await import('./resources/drink.js').then((ns) =&gt; console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`))&quot;);
+
+            InspectorBackend.runAfterPendingDispatches(resolve);
+        }
+    });
+
</ins><span class="cx">     suite.runTestCasesAndFinish();
</span><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-02-07  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Web Inspector: allow import() inside the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        Reviewed by Ryosuke Niwa.
+
+        We relax import module hook to accept null SourceOrigin.
+        Such a script can be evaluated from the inspector console.
+
+        * jsc.cpp:
+        (GlobalObject::moduleLoaderImportModule):
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::globalFuncImportModule):
+
</ins><span class="cx"> 2017-02-06  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Do not use RunLoop when dispatching inspector GC event
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -1551,6 +1551,9 @@
</span><span class="cx">         return JSInternalPromiseDeferred::create(exec, globalObject)-&gt;reject(exec, error);
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    if (sourceOrigin.isNull())
+        return rejectPromise(createError(exec, ASCIILiteral(&quot;Could not resolve the module specifier.&quot;)));
+
</ins><span class="cx">     auto referrer = sourceOrigin.string();
</span><span class="cx">     auto moduleName = moduleNameValue-&gt;value(exec);
</span><span class="cx">     if (UNLIKELY(scope.exception())) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectFunctionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -944,11 +944,6 @@
</span><span class="cx">     RETURN_IF_EXCEPTION(catchScope, { });
</span><span class="cx"> 
</span><span class="cx">     auto sourceOrigin = exec-&gt;callerSourceOrigin();
</span><del>-    if (sourceOrigin.isNull()) {
-        promise-&gt;reject(exec, createError(exec, ASCIILiteral(&quot;Could not resolve the module specifier.&quot;)));
-        return JSValue::encode(promise-&gt;promise());
-    }
-
</del><span class="cx">     RELEASE_ASSERT(exec-&gt;argumentCount() == 1);
</span><span class="cx">     auto* specifier = exec-&gt;uncheckedArgument(0).toString(exec);
</span><span class="cx">     if (Exception* exception = catchScope.exception()) {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/Source/WebCore/ChangeLog        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-02-07  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Web Inspector: allow import() inside the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        Reviewed by Ryosuke Niwa.
+
+        When evaluating `import(&quot;...&quot;)`, we need the caller's context to resolve
+        the module specifier correctly. For example, if `import(&quot;./cocoa.js&quot;)` is
+        evaluated in the script &quot;drinks/hot.js&quot;, this module name is resolved to
+        &quot;drinks/cocoa.js&quot;. If the same import operator is evaluated in the script
+        &quot;menu/all.js&quot;, the module specifier becomes &quot;menu/cocoa.js&quot;.
+
+        Previously we reject the import operator if the caller does not have such
+        a context. These context is SourceOrigin and its ScriptFetcher. While they
+        are offered in the script tag and other code evaluations, the inspector
+        console does not offer that. These class are offered in the WebCore side
+        and we should not touch these classes in the JSC's inspector code.
+
+        Now we relax the above restriction. If the above caller information is not
+        offered, we fallback to the default one. In the web page, we use the page's
+        URL as the caller's source origin. This allows us to evaluate the import
+        operator in the inspector console.
+
+        And as of r167698, the console recognizes `await import(&quot;...&quot;)` form. We use
+        this to test this `import()` in the console functionality.
+
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::importModule):
+
</ins><span class="cx"> 2017-02-07  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move platform-independent parts of ComplexTextController out of mac/ subfolder
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptModuleLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (211776 => 211777)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-02-07 08:14:06 UTC (rev 211776)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-02-07 08:17:17 UTC (rev 211777)
</span><span class="lines">@@ -218,15 +218,30 @@
</span><span class="cx">     JSC::VM&amp; vm = exec-&gt;vm();
</span><span class="cx">     auto&amp; globalObject = *JSC::jsCast&lt;JSDOMGlobalObject*&gt;(jsGlobalObject);
</span><span class="cx"> 
</span><del>-    // FIXME: setTimeout and setInterval with &quot;string()&quot; should propagate SourceOrigin.
-    // https://webkit.org/b/167097
-    ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), &quot;If SourceOrigin is null, this function is not invoked.&quot;);
-    if (!sourceOrigin.fetcher())
-        return rejectPromise(state, globalObject, TypeError, ASCIILiteral(&quot;Could not use import operator in this context.&quot;));
</del><ins>+    // If SourceOrigin and/or CachedScriptFetcher is null, we import the module with the default fetcher.
+    // SourceOrigin can be null if the source code is not coupled with the script file.
+    // The examples,
+    //     1. The code evaluated by the inspector.
+    //     2. The other unusual code execution like the evaluation through the NPAPI.
+    //     3. The code from injected bundle's script.
+    //     4. The code from extension script.
+    URL baseURL;
+    RefPtr&lt;JSC::ScriptFetcher&gt; scriptFetcher;
+    if (sourceOrigin.isNull()) {
+        baseURL = m_document.baseURL();
+        scriptFetcher = CachedScriptFetcher::create(m_document.charset());
+    } else {
+        baseURL = URL(URL(), sourceOrigin.string());
+        if (!baseURL.isValid())
+            return rejectPromise(state, globalObject, TypeError, ASCIILiteral(&quot;Importer module key is not a Symbol or a String.&quot;));
</ins><span class="cx"> 
</span><del>-    URL baseURL(URL(), sourceOrigin.string());
-    if (!baseURL.isValid())
-        return rejectPromise(state, globalObject, TypeError, ASCIILiteral(&quot;Importer module key is not Symbol or String.&quot;));
</del><ins>+        if (sourceOrigin.fetcher())
+            scriptFetcher = sourceOrigin.fetcher();
+        else
+            scriptFetcher = CachedScriptFetcher::create(m_document.charset());
+    }
+    ASSERT(baseURL.isValid());
+    ASSERT(scriptFetcher);
</ins><span class="cx"> 
</span><span class="cx">     auto specifier = moduleName-&gt;value(exec);
</span><span class="cx">     auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
</span><span class="lines">@@ -233,7 +248,7 @@
</span><span class="cx">     if (!result)
</span><span class="cx">         return rejectPromise(state, globalObject, TypeError, result.error());
</span><span class="cx"> 
</span><del>-    return JSC::importModule(exec, JSC::Identifier::fromString(&amp;vm, result-&gt;string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
</del><ins>+    return JSC::importModule(exec, JSC::Identifier::fromString(&amp;vm, result-&gt;string()), JSC::JSScriptFetcher::create(vm, WTFMove(scriptFetcher) ));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader&amp; loader, RefPtr&lt;DeferredPromise&gt; promise)
</span></span></pre>
</div>
</div>

</body>
</html>