Web Inspector: Include Beacon and Ping requests in Network tab
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Oct 2017 20:24:10 +0000 (20:24 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Oct 2017 20:24:10 +0000 (20:24 +0000)
commitee3646bed56b1b9201fdbabdb94f866e0454af18
tree1466b11297bcfaabc2b2227e20b795de49f493b6
parentbd6b119ea4246e4a32f70ecb48ff096786209888
Web Inspector: Include Beacon and Ping requests in Network tab
https://bugs.webkit.org/show_bug.cgi?id=177641
<rdar://problem/33086839>

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* inspector/protocol/Page.json:
Include new "Beacon" and "Ping" resource types.

Source/WebCore:

Tests: http/tests/inspector/network/beacon-type.html
       http/tests/inspector/network/ping-type.html

* Modules/beacon/NavigatorBeacon.cpp:
(WebCore::NavigatorBeacon::sendBeacon):
Fix a typo.

* loader/PingLoader.cpp:
(WebCore::PingLoader::startPingLoad):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::load):
Include InspectorInstrumentation hooks for ping network loads.

* loader/LoaderStrategy.h:
* platform/network/PingHandle.h:
Include an optional ResourceResponse in the ping load completion callback.
If available this will be enough for Web Inspector to include details such
as the response statusCode.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendRequestOfTypeImpl):
(WebCore::InspectorInstrumentation::continueAfterPingLoaderImpl): Deleted.
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendRequestOfType):
(WebCore::InspectorInstrumentation::continueAfterPingLoader): Deleted.
* inspector/InspectorNetworkAgent.cpp:
(WebCore::resourceTypeForCachedResource):
(WebCore::resourceTypeForLoadType):
(WebCore::InspectorNetworkAgent::willSendRequest):
(WebCore::InspectorNetworkAgent::willSendRequestOfType):
* inspector/InspectorNetworkAgent.h:
Make a general willSendRequestOfType hook when sending a request that does
not go through normal CachedResource loading. The Ping and Beacon requests
go through this process, we may also use this path for Preflight requests.

* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::resourceTypeJson):
(WebCore::InspectorPageAgent::cachedResourceType):
* inspector/InspectorPageAgent.h:
Small refactoring.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
New strings for Beacon/Ping.

* UserInterface/Images/Beacon.svg: Added.
* UserInterface/Views/ResourceIcons.css:
(.resource-icon.resource-type-ping .icon,):
(body:not(.mac-platform, .windows-platform) .resource-icon.resource-type-ping .icon,):
(body:not(.mac-platform, .windows-platform) .large .resource-icon.resource-type-ping .icon,):
New icon for Beacon/Ping. They share an icon since they are similiar in concept:
a request that is sent and the page doesn't expect a response.

* UserInterface/Controllers/FrameResourceManager.js:
(WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget):
When a sub-resource and a main-resource have the same URL we were not
distinguishing them. Use the resource type to distinguish them better.

* UserInterface/Models/SourceCode.js:
(WI.SourceCode.prototype._processContent):
Safer handling if the body was base64 encoded but an empty string.

* UserInterface/Models/Resource.js:
(WI.Resource.displayNameForType):
* UserInterface/Models/ResourceCollection.js:
(WI.ResourceCollection.verifierForType):
* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.shortDisplayNameForResourceType):
* UserInterface/Views/ResourceClusterContentView.js:
(WI.ResourceClusterContentView.prototype.get responseContentView):
New resource types.

* UserInterface/Views/ResourceContentView.js:
(WI.ResourceContentView.prototype.showMessage):
* UserInterface/Views/TextResourceContentView.js:
(WI.TextResourceContentView.prototype._contentDidPopulate):
Nicer display for empty content, which may be common for these requests.

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::loadPing):
(WebKit::NetworkConnectionToWebProcess::didFinishPingLoad):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/PingLoad.cpp:
(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::didFinish):
(WebKit::PingLoad::didReceiveResponseNetworkSession):
* NetworkProcess/PingLoad.h:
* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didFinishPingLoad):
* WebProcess/Network/NetworkProcessConnection.h:
* WebProcess/Network/NetworkProcessConnection.messages.in:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::networkProcessCrashed):
(WebKit::WebLoaderStrategy::startPingLoad):
(WebKit::WebLoaderStrategy::didFinishPingLoad):
* WebProcess/Network/WebLoaderStrategy.h:
Pass an optional ResourceResponse back to the ping completion handler.

LayoutTests:

* http/tests/inspector/network/beacon-type-expected.txt: Added.
* http/tests/inspector/network/beacon-type.html: Added.
* http/tests/inspector/network/ping-type-expected.txt: Added.
* http/tests/inspector/network/ping-type.html: Added.
* http/tests/inspector/network/resources/beacon.php: Added.
* http/tests/inspector/network/resources/ping.php: Added.
Test for Beacon and Ping resource loads.

* platform/mac-wk1/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/win/TestExpectations:
Skip beacon tests where beacon is not supported.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
47 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/beacon-type-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/beacon-type.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/ping-type-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/ping-type.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/beacon.php [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/ping.php [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Page.json
Source/WebCore/ChangeLog
Source/WebCore/Modules/beacon/NavigatorBeacon.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/InspectorNetworkAgent.h
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/loader/LoaderStrategy.h
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/platform/network/PingHandle.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js
Source/WebInspectorUI/UserInterface/Images/Beacon.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js
Source/WebInspectorUI/UserInterface/Models/SourceCode.js
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css
Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/PingLoad.cpp
Source/WebKit/NetworkProcess/PingLoad.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.messages.in
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.h