Ignore:
Timestamp:
Oct 20, 2017, 12:19:02 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] ScriptFetcher should be notified directly from module pipeline
https://bugs.webkit.org/show_bug.cgi?id=178340

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Previously, we use JSStdFunction to let WebCore inform the module pipeline results.
We setup JSStdFunction to the resulted promise of the module pipeline. It is super
ad-hoc since JSStdFunction's lambda need extra-careful to make it non-cyclic-referenced.
JSStdFunction's lambda can capture variables, but they are not able to be marked by GC.

But now, we have ScriptFetcher. It is introduced after we implemented the module pipeline
notification mechanism by using JSStdFunction. But it is appropriate one to receive notification
from the module pipeline by observer style.

This patch removes the above ad-hoc JSStdFunction use. And now ScriptFetcher receives
completion/failure notifications from the module pipeline.

  • builtins/ModuleLoaderPrototype.js:

(loadModule):
(loadAndEvaluateModule):

  • runtime/Completion.cpp:

(JSC::loadModule):

  • runtime/Completion.h:
  • runtime/JSModuleLoader.cpp:

(JSC::jsValueToModuleKey):
(JSC::JSModuleLoader::notifyCompleted):
(JSC::JSModuleLoader::notifyFailed):

  • runtime/JSModuleLoader.h:
  • runtime/ModuleLoaderPrototype.cpp:

(JSC::moduleLoaderPrototypeNotifyCompleted):
(JSC::moduleLoaderPrototypeNotifyFailed):

  • runtime/ScriptFetcher.h:

(JSC::ScriptFetcher::notifyLoadCompleted):
(JSC::ScriptFetcher::notifyLoadFailed):

Source/WebCore:

No behavior change.

  • bindings/js/JSMainThreadExecState.h:

(WebCore::JSMainThreadExecState::loadModule):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::jsValueToModuleKey): Deleted.
(WebCore::ScriptController::setupModuleScriptHandlers): Deleted.

  • bindings/js/ScriptController.h:
  • dom/LoadableModuleScript.cpp:

(WebCore::LoadableModuleScript::notifyLoadFailed):

  • dom/LoadableModuleScript.h:

LayoutTests:

  • http/tests/security/contentSecurityPolicy/1.1/module-scriptnonce-redirect-expected.txt:
  • http/tests/security/module-no-mime-type-expected.txt:
  • js/dom/modules/module-execution-error-should-be-propagated-to-onerror-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r223237 r223744  
    184184}
    185185
    186 JSInternalPromise* loadModule(ExecState* exec, const String& moduleName, JSValue parameters, JSValue scriptFetcher)
    187 {
    188     VM& vm = exec->vm();
    189     JSLockHolder lock(vm);
    190     RELEASE_ASSERT(vm.atomicStringTable() == Thread::current().atomicStringTable());
    191     RELEASE_ASSERT(!vm.isCollectorBusyOnCurrentThread());
    192 
    193     return exec->vmEntryGlobalObject()->moduleLoader()->loadModule(exec, identifierToJSValue(vm, Identifier::fromString(exec, moduleName)), parameters, scriptFetcher);
    194 }
    195 
    196 JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source, JSValue scriptFetcher)
     186void loadModule(ExecState* exec, const String& moduleName, JSValue parameters, JSValue scriptFetcher)
     187{
     188    VM& vm = exec->vm();
     189    JSLockHolder lock(vm);
     190    RELEASE_ASSERT(vm.atomicStringTable() == Thread::current().atomicStringTable());
     191    RELEASE_ASSERT(!vm.isCollectorBusyOnCurrentThread());
     192
     193    exec->vmEntryGlobalObject()->moduleLoader()->loadModule(exec, identifierToJSValue(vm, Identifier::fromString(exec, moduleName)), parameters, scriptFetcher);
     194}
     195
     196void loadModule(ExecState* exec, const SourceCode& source, JSValue scriptFetcher)
    197197{
    198198    VM& vm = exec->vm();
     
    209209    // FIXME: Introduce JSSourceCode object to wrap around this source.
    210210    globalObject->moduleLoader()->provideFetch(exec, key, source);
    211     RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
    212 
    213     return globalObject->moduleLoader()->loadModule(exec, key, jsUndefined(), scriptFetcher);
     211    RETURN_IF_EXCEPTION(scope, void());
     212
     213    globalObject->moduleLoader()->loadModule(exec, key, jsUndefined(), scriptFetcher);
    214214}
    215215
Note: See TracChangeset for help on using the changeset viewer.