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("...")`, we need the caller's context to resolve
the module specifier correctly. For example, if `import("./cocoa.js")` is
evaluated in the script "drinks/hot.js", this module name is resolved to
"drinks/cocoa.js". If the same import operator is evaluated in the script
"menu/all.js", the module specifier becomes "menu/cocoa.js".
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("...")` 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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211777
268f45cc-cd09-0410-ab3c-
d52691b4dbfc