Propagate networking errors correctly for import() operator
https://bugs.webkit.org/show_bug.cgi?id=167501
Reviewed by Ryosuke Niwa.
.:
* Source/ModuleFetchFailureKind.h: Added.
Source/WebCore:
We use the promise chain inside the module loader pipeline.
The problem is that,
1. The errors of loading module scripts are propagated through the promise's rejection.
2. Some module related errors like syntax error (when scanning module dependencies) are
reported at loading time (evaluating time). These errors are propagated through the
promise rejections and dumped to the console. LoadableModuleScript set catch handler
for that and print these errors to the console for ScriptElement.
3. Some of errors are already reported to the console. For example, networking errors
are reported by the CachedModuleLoader.
4. But there is no way to distinguish between (2) and (3) at the catch handler.
Previously, we propagate the special symbol for the already reported errors to distinguish
that. This was OK because these errors cannot be catched by the user code. However,
recent `import()` call needs to expose these errors to the user code. So now, accidentally,
the special purpose symbol is exposed.
Instead of propagating the special symbol, this patch just propagates the errors. But these
error objects are annotated with the private symbol. So these errors can be distinguished
from the other ones.
Currently, we do not have the way to expose the error details to the client of the
CachedScript. So we just report the error with the failed / canceled. This should be
more descriptive error messages in the separate patch[1].
[1]: https://bugs.webkit.org/show_bug.cgi?id=167553
Tests: http/tests/security/mixedContent/import-insecure-script-in-iframe.html
js/dom/modules/import-not-found-error.html
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMPromise.h:
(WebCore::DeferredPromise::resolveWithCallback):
(WebCore::DeferredPromise::rejectWithCallback):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::setupModuleScriptHandlers):
* bindings/js/ScriptController.h:
(WebCore::ScriptController::moduleLoaderAlreadyReportedErrorSymbol): Deleted.
(WebCore::ScriptController::moduleLoaderFetchingIsCanceledSymbol): Deleted.
* bindings/js/ScriptModuleLoader.cpp:
(WebCore::rejectToPropagateNetworkError):
(WebCore::ScriptModuleLoader::fetch):
(WebCore::ScriptModuleLoader::notifyFinished):
* bindings/js/WebCoreBuiltinNames.h:
LayoutTests:
* http/tests/security/mixedContent/import-insecure-script-in-iframe-expected.txt: Added.
* http/tests/security/mixedContent/import-insecure-script-in-iframe.html: Added.
* http/tests/security/mixedContent/resources/frame-with-insecure-import.html: Added.
* js/dom/modules/import-not-found-error-expected.txt: Added.
* js/dom/modules/import-not-found-error.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211473
268f45cc-cd09-0410-ab3c-
d52691b4dbfc