| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +12 lines
Lines 1-5 a/Source/JavaScriptCore/ChangeLog_sec1
1
2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
1
2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
2
2
3
        Web Inspector: allow import() inside the inspector
4
        https://bugs.webkit.org/show_bug.cgi?id=167457
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * jsc.cpp:
9
        (GlobalObject::moduleLoaderImportModule):
10
        * runtime/JSGlobalObjectFunctions.cpp:
11
        (JSC::globalFuncImportModule):
12
13
2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
14
3
        ArityFixup should adjust SP first
15
        ArityFixup should adjust SP first
4
        https://bugs.webkit.org/show_bug.cgi?id=167239
16
        https://bugs.webkit.org/show_bug.cgi?id=167239
5
17
- a/Source/WebCore/ChangeLog +12 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2017-02-01  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 NOBODY (OOPS!).
7
8
        No new tests (OOPS!).
9
10
        * bindings/js/ScriptModuleLoader.cpp:
11
        (WebCore::ScriptModuleLoader::importModule):
12
1
2017-02-01  Enrique Ocaña González  <eocanha@igalia.com>
13
2017-02-01  Enrique Ocaña González  <eocanha@igalia.com>
2
14
3
        [GStreamer][MSE] qtdemux: Update the tfdt patch to the version finally accepted upstream
15
        [GStreamer][MSE] qtdemux: Update the tfdt patch to the version finally accepted upstream
- a/Source/JavaScriptCore/jsc.cpp +3 lines
Lines 1551-1556 JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* global a/Source/JavaScriptCore/jsc.cpp_sec1
1551
        return JSInternalPromiseDeferred::create(exec, globalObject)->reject(exec, error);
1551
        return JSInternalPromiseDeferred::create(exec, globalObject)->reject(exec, error);
1552
    };
1552
    };
1553
1553
1554
    if (sourceOrigin.isNull())
1555
        return rejectPromise(createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
1556
1554
    auto referrer = sourceOrigin.string();
1557
    auto referrer = sourceOrigin.string();
1555
    auto moduleName = moduleNameValue->value(exec);
1558
    auto moduleName = moduleNameValue->value(exec);
1556
    if (UNLIKELY(scope.exception())) {
1559
    if (UNLIKELY(scope.exception())) {
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp -5 lines
Lines 944-954 EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState* exec) a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec1
944
    RETURN_IF_EXCEPTION(catchScope, { });
944
    RETURN_IF_EXCEPTION(catchScope, { });
945
945
946
    auto sourceOrigin = exec->callerSourceOrigin();
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
    RELEASE_ASSERT(exec->argumentCount() == 1);
947
    RELEASE_ASSERT(exec->argumentCount() == 1);
953
    auto* specifier = exec->uncheckedArgument(0).toString(exec);
948
    auto* specifier = exec->uncheckedArgument(0).toString(exec);
954
    if (Exception* exception = catchScope.exception()) {
949
    if (Exception* exception = catchScope.exception()) {
- a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp -10 / +23 lines
Lines 218-239 JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* js a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec1
218
    JSC::VM& vm = exec->vm();
218
    JSC::VM& vm = exec->vm();
219
    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
219
    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
220
220
221
    // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin.
221
    // If SourceOrigin and/or CachedScriptFetcher is null, we import the module with the default fetcher.
222
    // https://webkit.org/b/167097
222
    // SourceOrigin can be null if the source code is not coupled with the script file.
223
    ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked.");
223
    // The examples,
224
    if (!sourceOrigin.fetcher())
224
    //     1. The code evaluated by the inspector.
225
        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context."));
225
    //     2. The other unusual code execution like the evaluation through the NPAPI.
226
226
    URL baseURL;
227
    URL baseURL(URL(), sourceOrigin.string());
227
    RefPtr<JSC::ScriptFetcher> scriptFetcher;
228
    if (!baseURL.isValid())
228
    if (sourceOrigin.isNull()) {
229
        return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String."));
229
        baseURL = m_document.baseURL();
230
        scriptFetcher = CachedScriptFetcher::create(m_document.charset());
231
    } else {
232
        baseURL = URL(URL(), sourceOrigin.string());
233
        if (!baseURL.isValid())
234
            return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not a Symbol or a String."));
235
236
        if (sourceOrigin.fetcher())
237
            scriptFetcher = sourceOrigin.fetcher();
238
        else
239
            scriptFetcher = CachedScriptFetcher::create(m_document.charset());
240
    }
241
    ASSERT(baseURL.isValid());
242
    ASSERT(scriptFetcher);
230
243
231
    auto specifier = moduleName->value(exec);
244
    auto specifier = moduleName->value(exec);
232
    auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
245
    auto result = resolveModuleSpecifier(m_document, specifier, baseURL);
233
    if (!result)
246
    if (!result)
234
        return rejectPromise(state, globalObject, TypeError, result.error());
247
        return rejectPromise(state, globalObject, TypeError, result.error());
235
248
236
    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() ));
249
    return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, WTFMove(scriptFetcher) ));
237
}
250
}
238
251
239
void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)
252
void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)

Return to Bug 167457