[Fetch API] Improve resource loading console logging
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Dec 2016 11:51:16 +0000 (11:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Dec 2016 11:51:16 +0000 (11:51 +0000)
commit0bc6e493371162c2230b870e18287aa6c8ed4017
tree50c781e7a48ff554af565be765ce29f0b435d1d5
parentb19d30438c3b86c22c38d19630ec0ec56e803d6f
[Fetch API] Improve resource loading console logging
https://bugs.webkit.org/show_bug.cgi?id=160546

Patch by Youenn Fablet <youenn@apple.com> on 2016-12-16
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebasing since error logging is happening for fetch API.

* web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-about-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-others-expected.txt:
* web-platform-tests/fetch/api/cors/cors-basic-expected.txt:
* web-platform-tests/fetch/api/cors/cors-cookies-expected.txt:
* web-platform-tests/fetch/api/cors/cors-multiple-origins-expected.txt:
* web-platform-tests/fetch/api/cors/cors-origin-expected.txt:
* web-platform-tests/fetch/api/cors/cors-preflight.html:
* web-platform-tests/fetch/api/cors/cors-redirect-credentials-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-location-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-schemes-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-to-dataurl-expected.txt:

Source/WebCore:

Covered by rebased tests.

Adding support for logging of resource loading failures in ThreadableLoader.
This will allow doing consistent logging for clients such as fetch, XHR, event source...

Doing logging for Fetch API only at the moment in ThreadableLoader.
Future patches should migrate XHR to this logging system.

Logging routine is implemented in ThreadableLoader.
It is used directly by DocumentThreadableLoader before calling didFail client callback.
DocumentThreadableLoader has a new option to not log errors, in the case the client is WorkerThreadableLoader::MainBridge.
In that case, the logging is done in the worker context within WorkerThreadableLoader::MainBridge::didFail

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadResourceSynchronously): Enable logging.
(WebCore::DocumentThreadableLoader::create): Passing logging parameter to constructor.
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Adding initialization of logging parameter.
(WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest): Making use of the new logErrorAndFail helper routine.
(WebCore::DocumentThreadableLoader::cancel): No need to log error if it is being cancelled.
(WebCore::DocumentThreadableLoader::redirectReceived): Made the reportXX routines methods of DocumentThreadableLoaders and using logErrorAndFail internally.
(WebCore::DocumentThreadableLoader::didFail): Wrapper around logErrorAndFail since cancel is not calling it anymore.
(WebCore::DocumentThreadableLoader::preflightFailure):
(WebCore::DocumentThreadableLoader::loadRequest):
(WebCore::DocumentThreadableLoader::reportRedirectionWithBadScheme):
(WebCore::DocumentThreadableLoader::reportContentSecurityPolicyError):
(WebCore::DocumentThreadableLoader::reportCrossOriginResourceSharingError):
(WebCore::DocumentThreadableLoader::logErrorAndFail):
(WebCore::reportContentSecurityPolicyError): Deleted.
(WebCore::reportCrossOriginResourceSharingError): Deleted.
(WebCore::reportRedirectionWithBadScheme): Deleted.
* loader/DocumentThreadableLoader.h:
* loader/ThreadableLoader.cpp:
(WebCore::ThreadableLoader::logError):
* loader/ThreadableLoader.h:
* loader/ThreadableLoaderClientWrapper.h:
(WebCore::ThreadableLoaderClientWrapper::create):
(WebCore::ThreadableLoaderClientWrapper::initiator):
(WebCore::ThreadableLoaderClientWrapper::ThreadableLoaderClientWrapper):
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::WorkerThreadableLoader):
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):

LayoutTests:

Rebasing since error logging is happening for fetch API.
Some tests are flaky due to always changing console logs, in which case DumpJSConsoleLogInStdErr is used.

* TestExpectations:
* http/tests/fetch/fetching-same-resource-with-diffferent-options-expected.txt:
* http/tests/inspector/network/fetch-network-data-expected.txt:
* platform/ios-simulator-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-basic-expected.txt:
* platform/ios-simulator-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-origin-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-basic-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-origin-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/fetch/fetching-same-resource-with-diffferent-options-expected.txt
LayoutTests/http/tests/inspector/network/fetch-network-data-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-basic-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-multiple-origins-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-origin-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight.html
LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-redirect-credentials-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-schemes-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-to-dataurl-expected.txt
LayoutTests/platform/ios-simulator-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-basic-expected.txt
LayoutTests/platform/ios-simulator-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-origin-expected.txt
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-basic-expected.txt
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/fetch/api/cors/cors-origin-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.h
Source/WebCore/loader/ThreadableLoader.cpp
Source/WebCore/loader/ThreadableLoader.h
Source/WebCore/loader/ThreadableLoaderClientWrapper.h
Source/WebCore/loader/WorkerThreadableLoader.cpp