Title: [211818] trunk
Revision
211818
Author
utatane....@gmail.com
Date
2017-02-07 10:24:49 -0800 (Tue, 07 Feb 2017)

Log Message

Unreviewed, manual roll out of r211777
https://bugs.webkit.org/show_bug.cgi?id=167457

Source/_javascript_Core:

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

Source/WebCore:

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

LayoutTests:

Later, I'll reland it with the deterministic tests.

* inspector/controller/resources/cappuccino.js: Removed.
* inspector/controller/resources/cocoa.js: Removed.
* inspector/controller/resources/drink.js: Removed.
* inspector/controller/runtime-controller-expected.txt:
* inspector/controller/runtime-controller.html:

Modified Paths

Removed Paths

  • trunk/LayoutTests/inspector/controller/resources/

Diff

Modified: trunk/LayoutTests/ChangeLog (211817 => 211818)


--- trunk/LayoutTests/ChangeLog	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/LayoutTests/ChangeLog	2017-02-07 18:24:49 UTC (rev 211818)
@@ -1,3 +1,16 @@
+2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
+
+        Unreviewed, manual roll out of r211777
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        Later, I'll reland it with the deterministic tests.
+
+        * inspector/controller/resources/cappuccino.js: Removed.
+        * inspector/controller/resources/cocoa.js: Removed.
+        * inspector/controller/resources/drink.js: Removed.
+        * inspector/controller/runtime-controller-expected.txt:
+        * inspector/controller/runtime-controller.html:
+
 2017-02-07  Antoine Quint  <grao...@apple.com>
 
         [Modern Media Controls] Handle media durations of an hour or more gracefully

Modified: trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt (211817 => 211818)


--- trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt	2017-02-07 18:24:49 UTC (rev 211818)
@@ -7,12 +7,6 @@
 CONSOLE MESSAGE: line 9: Rejection
 CONSOLE MESSAGE: line 7: %o
 CONSOLE MESSAGE: line 7: %o
-CONSOLE MESSAGE: line 9: TypeError: Module specifier does not start with "/", "./", or "../".
-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
 Tests for RuntimeManager operations.
 
 
@@ -64,13 +58,3 @@
 Source: x = y = await 10
 PASS: Exception. Should not get transformed and produce a SyntaxError.
 
--- 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) => console.log(`${cocoa.name} is ${cocoa.taste}.`))
-PASS: Transformed. Should log the value or an exception.
-Source: await import('./resources/drink.js').then((ns) => 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.
-

Modified: trunk/LayoutTests/inspector/controller/runtime-controller.html (211817 => 211818)


--- trunk/LayoutTests/inspector/controller/runtime-controller.html	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/LayoutTests/inspector/controller/runtime-controller.html	2017-02-07 18:24:49 UTC (rev 211818)
@@ -124,26 +124,6 @@
         }
     });
 
-    suite.addTestCase({
-        name: "RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole",
-        description: "Test evaluating an import _expression_ from console.",
-        test(resolve, reject) {
-            function testSource(_expression_) {
-                WebInspector.runtimeManager.evaluateInInspectedWindow(_expression_, {objectGroup: "test"}, (result, wasThrown) => {
-                    InspectorTest.log("Source: " + _expression_);
-                    InspectorTest.expectThat(result.isUndefined(), "Transformed. Should log the value or an exception.");
-                });
-            }
-
-            testSource("await import('')");
-            testSource("await import('./not-found.js')");
-            testSource("await import('./resources/cocoa.js').then((cocoa) => console.log(`${cocoa.name} is ${cocoa.taste}.`))");
-            testSource("await import('./resources/drink.js').then((ns) => console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`))");
-
-            InspectorBackend.runAfterPendingDispatches(resolve);
-        }
-    });
-
     suite.runTestCasesAndFinish();
 }
 </script>

Modified: trunk/Source/_javascript_Core/ChangeLog (211817 => 211818)


--- trunk/Source/_javascript_Core/ChangeLog	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-02-07 18:24:49 UTC (rev 211818)
@@ -1,5 +1,15 @@
 2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
 
+        Unreviewed, manual roll out of r211777
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        * jsc.cpp:
+        (GlobalObject::moduleLoaderImportModule):
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::globalFuncImportModule):
+
+2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
+
         Web Inspector: allow import() inside the inspector
         https://bugs.webkit.org/show_bug.cgi?id=167457
 

Modified: trunk/Source/_javascript_Core/jsc.cpp (211817 => 211818)


--- trunk/Source/_javascript_Core/jsc.cpp	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/Source/_javascript_Core/jsc.cpp	2017-02-07 18:24:49 UTC (rev 211818)
@@ -1551,9 +1551,6 @@
         return JSInternalPromiseDeferred::create(exec, globalObject)->reject(exec, error);
     };
 
-    if (sourceOrigin.isNull())
-        return rejectPromise(createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
-
     auto referrer = sourceOrigin.string();
     auto moduleName = moduleNameValue->value(exec);
     if (UNLIKELY(scope.exception())) {

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (211817 => 211818)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2017-02-07 18:24:49 UTC (rev 211818)
@@ -944,6 +944,11 @@
     RETURN_IF_EXCEPTION(catchScope, { });
 
     auto sourceOrigin = exec->callerSourceOrigin();
+    if (sourceOrigin.isNull()) {
+        promise->reject(exec, createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
+        return JSValue::encode(promise->promise());
+    }
+
     RELEASE_ASSERT(exec->argumentCount() == 1);
     auto* specifier = exec->uncheckedArgument(0).toString(exec);
     if (Exception* exception = catchScope.exception()) {

Modified: trunk/Source/WebCore/ChangeLog (211817 => 211818)


--- trunk/Source/WebCore/ChangeLog	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/Source/WebCore/ChangeLog	2017-02-07 18:24:49 UTC (rev 211818)
@@ -1,3 +1,11 @@
+2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
+
+        Unreviewed, manual roll out of r211777
+        https://bugs.webkit.org/show_bug.cgi?id=167457
+
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::importModule):
+
 2017-02-07  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GStreamer] Deadlock when media player is destroyed

Modified: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (211817 => 211818)


--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp	2017-02-07 18:24:02 UTC (rev 211817)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp	2017-02-07 18:24:49 UTC (rev 211818)
@@ -218,30 +218,15 @@
     JSC::VM& vm = exec->vm();
     auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
 
-    // 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<JSC::ScriptFetcher> 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("Importer module key is not a Symbol or a String."));
+    // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin.
+    // https://webkit.org/b/167097
+    ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked.");
+    if (!sourceOrigin.fetcher())
+        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context."));
 
-        if (sourceOrigin.fetcher())
-            scriptFetcher = sourceOrigin.fetcher();
-        else
-            scriptFetcher = CachedScriptFetcher::create(m_document.charset());
-    }
-    ASSERT(baseURL.isValid());
-    ASSERT(scriptFetcher);
+    URL baseURL(URL(), sourceOrigin.string());
+    if (!baseURL.isValid())
+        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
 
     auto specifier = moduleName->value(exec);
     auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
@@ -248,7 +233,7 @@
     if (!result)
         return rejectPromise(state, globalObject, TypeError, result.error());
 
-    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, WTFMove(scriptFetcher) ));
+    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
 }
 
 void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to