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.h

    r223237 r223744  
    6262
    6363// Fetch the module source, and instantiate the module record.
    64 JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String& moduleName, JSValue parameters, JSValue scriptFetcher);
    65 JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&, JSValue scriptFetcher);
     64JS_EXPORT_PRIVATE void loadModule(ExecState*, const String& moduleName, JSValue parameters, JSValue scriptFetcher);
     65JS_EXPORT_PRIVATE void loadModule(ExecState*, const SourceCode&, JSValue scriptFetcher);
    6666
    6767// Link and evaluate the already linked module. This function is called in a sync manner.
Note: See TracChangeset for help on using the changeset viewer.