Web Inspector backend should get headers & cookies from network process separately...
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 21:27:02 +0000 (21:27 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 21:27:02 +0000 (21:27 +0000)
commit9e4602f500acf7b173061b998f796679fb1189dc
tree53df84ac686fe0f95aea5358922818ee453fa004
parentd1f00e0ddd0cfa6a17cc110a46050bfad19603d7
Web Inspector backend should get headers & cookies from network process separately from resource requests
https://bugs.webkit.org/show_bug.cgi?id=184396
<rdar://problem/38877384>

Reviewed by Brian Burg.

Source/WebCore:

Add two new loader strategies to get response and network metrics directly from
NetworkProcess based on resource loader identifier.
Use these methods in InspectorNetworkAgent when response/metrics might be filtered.

Covered by existing tests, in particular http/tests/inspector/network/fetch-network-data.html which would fail
without this since we are now setting the sourceOrigin for NetworkResourceLoader, which is used to sanitize response headers.

* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveResponse):
(WebCore::InspectorNetworkAgent::didFinishLoading):
* loader/LoaderStrategy.cpp:
(WebCore::LoaderStrategy::responseFromResourceLoaIdentifier):
(WebCore::LoaderStrategy::networkMetricsFromResourceLoaIdentifier):
* loader/LoaderStrategy.h:

Source/WebKit:

Add support for storing response and network metrics for every resource load.
This is made conditional on inspector being activated.
NetworkConnectionToWebProcess keeps a response and network metrics for every load.
This is cleared when inspector is going away or when a web process requests
the data.

WebLoaderStrategy gets this data through synchronous IPC.
Synchronous IPC is a temporary implementation until Inspector code gets refactored.

Updated WebLoaderStrategy to pass the sourceOrigin for every NetworkResourceLoader.
This activates additional sanitization based on cross origin status.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::setCaptureExtraNetworkLoadMetricsEnabled):
* NetworkProcess/NetworkConnectionToWebProcess.h:
(WebKit::NetworkConnectionToWebProcess::takeNetworkLoadInformationResponse):
(WebKit::NetworkConnectionToWebProcess::takeNetworkLoadInformationMetrics):
(WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationResponse):
(WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationMetrics):
(WebKit::NetworkConnectionToWebProcess::removeNetworkLoadInformation):
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveResponse):
(WebKit::NetworkResourceLoader::didFinishLoading):
(WebKit::NetworkResourceLoader::didFailLoading):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::responseFromResourceLoadIdentifier):
(WebKit::WebLoaderStrategy::networkMetricsFromResourceLoadIdentifier):
* WebProcess/Network/WebLoaderStrategy.h:
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):

LayoutTests:

* http/wpt/service-workers/header-filtering.https-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/service-workers/header-filtering.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
Source/WebCore/loader/LoaderStrategy.cpp
Source/WebCore/loader/LoaderStrategy.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.h