[JSC] ScriptFetcher should be notified directly from module pipeline
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2017 07:19:02 +0000 (07:19 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2017 07:19:02 +0000 (07:19 +0000)
commit1985aa23e935d7fdabb5755208827d4e3f02c6e3
treee5fb72ae0aad7343668760e8c617678499d4228b
parentb6bb92d65a77b5bf8743277ebdb59bff10962587
[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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/security/contentSecurityPolicy/1.1/module-scriptnonce-redirect-expected.txt
LayoutTests/http/tests/security/module-no-mime-type-expected.txt
LayoutTests/js/dom/modules/module-execution-error-should-be-propagated-to-onerror-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js
Source/JavaScriptCore/runtime/Completion.cpp
Source/JavaScriptCore/runtime/Completion.h
Source/JavaScriptCore/runtime/JSModuleLoader.cpp
Source/JavaScriptCore/runtime/JSModuleLoader.h
Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
Source/JavaScriptCore/runtime/ScriptFetcher.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSMainThreadExecState.h
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/ScriptController.h
Source/WebCore/dom/LoadableModuleScript.cpp
Source/WebCore/dom/LoadableModuleScript.h