Changeset 212438 in webkit
- Timestamp:
- Feb 16, 2017 9:32:12 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r212433 r212438 1 2017-02-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Web Inspector: allow import() inside the inspector 4 https://bugs.webkit.org/show_bug.cgi?id=167457 5 6 Reviewed by Ryosuke Niwa. 7 8 Extract the test to single file. And make it deterministic. 9 10 * inspector/controller/resources/cappuccino.js: Added. 11 * inspector/controller/resources/cocoa.js: Added. 12 * inspector/controller/resources/drink.js: Added. 13 * inspector/controller/runtime-controller-import-expected.txt: Added. 14 * inspector/controller/runtime-controller-import.html: Added. 15 1 16 2017-02-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 17 -
trunk/Source/JavaScriptCore/ChangeLog
r212430 r212438 1 2017-02-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Web Inspector: allow import() inside the inspector 4 https://bugs.webkit.org/show_bug.cgi?id=167457 5 6 Reviewed by Ryosuke Niwa. 7 8 We relax import module hook to accept null SourceOrigin. 9 Such a script can be evaluated from the inspector console. 10 11 * jsc.cpp: 12 (GlobalObject::moduleLoaderImportModule): 13 * runtime/JSGlobalObjectFunctions.cpp: 14 (JSC::globalFuncImportModule): 15 1 16 2017-02-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 17 -
trunk/Source/JavaScriptCore/jsc.cpp
r211818 r212438 1552 1552 }; 1553 1553 1554 if (sourceOrigin.isNull()) 1555 return rejectPromise(createError(exec, ASCIILiteral("Could not resolve the module specifier."))); 1556 1554 1557 auto referrer = sourceOrigin.string(); 1555 1558 auto moduleName = moduleNameValue->value(exec); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r211818 r212438 945 945 946 946 auto sourceOrigin = exec->callerSourceOrigin(); 947 if (sourceOrigin.isNull()) {948 promise->reject(exec, createError(exec, ASCIILiteral("Could not resolve the module specifier.")));949 return JSValue::encode(promise->promise());950 }951 952 947 RELEASE_ASSERT(exec->argumentCount() == 1); 953 948 auto* specifier = exec->uncheckedArgument(0).toString(exec); -
trunk/Source/WebCore/ChangeLog
r212431 r212438 1 2017-02-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Web Inspector: allow import() inside the inspector 4 https://bugs.webkit.org/show_bug.cgi?id=167457 5 6 Reviewed by Ryosuke Niwa. 7 8 When evaluating `import("...")`, we need the caller's context to resolve 9 the module specifier correctly. For example, if `import("./cocoa.js")` is 10 evaluated in the script "drinks/hot.js", this module name is resolved to 11 "drinks/cocoa.js". If the same import operator is evaluated in the script 12 "menu/all.js", the module specifier becomes "menu/cocoa.js". 13 14 Previously we reject the import operator if the caller does not have such 15 a context. These context is SourceOrigin and its ScriptFetcher. While they 16 are offered in the script tag and other code evaluations, the inspector 17 console does not offer that. These class are offered in the WebCore side 18 and we should not touch these classes in the JSC's inspector code. 19 20 Now we relax the above restriction. If the above caller information is not 21 offered, we fallback to the default one. In the web page, we use the page's 22 URL as the caller's source origin. This allows us to evaluate the import 23 operator in the inspector console. 24 25 And as of r167698, the console recognizes `await import("...")` form. We use 26 this to test this `import()` in the console functionality. 27 28 Test: inspector/controller/runtime-controller-import.html 29 30 * bindings/js/ScriptModuleLoader.cpp: 31 (WebCore::ScriptModuleLoader::importModule): 32 1 33 2017-02-16 Miguel Gomez <magomez@igalia.com> 2 34 -
trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp
r211818 r212438 219 219 auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject); 220 220 221 // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin. 222 // https://webkit.org/b/167097 223 ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked."); 224 if (!sourceOrigin.fetcher()) 225 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context.")); 226 227 URL baseURL(URL(), sourceOrigin.string()); 228 if (!baseURL.isValid()) 229 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String.")); 221 // If SourceOrigin and/or CachedScriptFetcher is null, we import the module with the default fetcher. 222 // SourceOrigin can be null if the source code is not coupled with the script file. 223 // The examples, 224 // 1. The code evaluated by the inspector. 225 // 2. The other unusual code execution like the evaluation through the NPAPI. 226 // 3. The code from injected bundle's script. 227 // 4. The code from extension script. 228 URL baseURL; 229 RefPtr<JSC::ScriptFetcher> scriptFetcher; 230 if (sourceOrigin.isNull()) { 231 baseURL = m_document.baseURL(); 232 scriptFetcher = CachedScriptFetcher::create(m_document.charset()); 233 } else { 234 baseURL = URL(URL(), sourceOrigin.string()); 235 if (!baseURL.isValid()) 236 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not a Symbol or a String.")); 237 238 if (sourceOrigin.fetcher()) 239 scriptFetcher = sourceOrigin.fetcher(); 240 else 241 scriptFetcher = CachedScriptFetcher::create(m_document.charset()); 242 } 243 ASSERT(baseURL.isValid()); 244 ASSERT(scriptFetcher); 230 245 231 246 auto specifier = moduleName->value(exec); … … 234 249 return rejectPromise(state, globalObject, TypeError, result.error()); 235 250 236 return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));251 return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, WTFMove(scriptFetcher) )); 237 252 } 238 253
Note: See TracChangeset
for help on using the changeset viewer.