Unreviewed, manual roll out of r211777
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 18:24:49 +0000 (18:24 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 18:24:49 +0000 (18:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167457

Source/JavaScriptCore:

* 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/controller/resources/cappuccino.js [deleted file]
LayoutTests/inspector/controller/resources/cocoa.js [deleted file]
LayoutTests/inspector/controller/resources/drink.js [deleted file]
LayoutTests/inspector/controller/runtime-controller-expected.txt
LayoutTests/inspector/controller/runtime-controller.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptModuleLoader.cpp

index e2c88d7..6ddfe76 100644 (file)
@@ -1,3 +1,16 @@
+2017-02-07  Yusuke Suzuki  <utatane.tea@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  <graouts@apple.com>
 
         [Modern Media Controls] Handle media durations of an hour or more gracefully
diff --git a/LayoutTests/inspector/controller/resources/cappuccino.js b/LayoutTests/inspector/controller/resources/cappuccino.js
deleted file mode 100644 (file)
index 43b9430..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-export let name = "Cappuccino";
-export let taste = "Awesome";
diff --git a/LayoutTests/inspector/controller/resources/cocoa.js b/LayoutTests/inspector/controller/resources/cocoa.js
deleted file mode 100644 (file)
index ee57233..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-export let name = "Cocoa";
-export let taste = "Sweet";
diff --git a/LayoutTests/inspector/controller/resources/drink.js b/LayoutTests/inspector/controller/resources/drink.js
deleted file mode 100644 (file)
index b2d9a89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-import * as Cocoa from './cocoa.js'
-import * as Cappuccino from './cappuccino.js'
-
-export {
-    Cocoa,
-    Cappuccino
-}
index 27ef571..ded82fe 100644 (file)
@@ -7,12 +7,6 @@ CONSOLE MESSAGE: line 9: Promise.reject
 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 @@ PASS: Exception. Should not get transformed and produce a SyntaxError.
 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.
-
index e002bb9..4ca23f3 100644 (file)
@@ -124,26 +124,6 @@ function test()
         }
     });
 
-    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>
index 2ee9c3a..a543956 100644 (file)
@@ -1,5 +1,15 @@
 2017-02-07  Yusuke Suzuki  <utatane.tea@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.tea@gmail.com>
+
         Web Inspector: allow import() inside the inspector
         https://bugs.webkit.org/show_bug.cgi?id=167457
 
index 16c0428..bda9a09 100644 (file)
@@ -1551,9 +1551,6 @@ JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* global
         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())) {
index e3a4146..f3f76e6 100644 (file)
@@ -944,6 +944,11 @@ EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState* exec)
     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()) {
index 53530d4..8256d9c 100644 (file)
@@ -1,3 +1,11 @@
+2017-02-07  Yusuke Suzuki  <utatane.tea@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  <cgarcia@igalia.com>
 
         [GStreamer] Deadlock when media player is destroyed
index b67ffa3..1ce7253 100644 (file)
@@ -218,37 +218,22 @@ JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* js
     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."));
-
-        if (sourceOrigin.fetcher())
-            scriptFetcher = sourceOrigin.fetcher();
-        else
-            scriptFetcher = CachedScriptFetcher::create(m_document.charset());
-    }
-    ASSERT(baseURL.isValid());
-    ASSERT(scriptFetcher);
+    // 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."));
+
+    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);
     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)