Web Inspector: Doesn't show size of compressed content correctly
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Apr 2017 01:30:24 +0000 (01:30 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Apr 2017 01:30:24 +0000 (01:30 +0000)
commit07c9a8a3c57a8c8e22bdae57453604a18b004754
tree2c1f89893b69f0a3349e297c2d0e13193faeee12
parentb2103ee307426136751cf35b83e970902be256bc
Web Inspector: Doesn't show size of compressed content correctly
https://bugs.webkit.org/show_bug.cgi?id=155112
<rdar://problem/25006728>

Reviewed by Alex Christensen and Timothy Hatcher.

Source/JavaScriptCore:

* inspector/protocol/Network.json:
New, exact size metrics, available after the load completes.

Source/WebCore:

Tests: http/tests/inspector/network/resource-sizes-disk-cache.html
       http/tests/inspector/network/resource-sizes-memory-cache.html
       http/tests/inspector/network/resource-sizes-network.html

* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildObjectForMetrics):
* platform/network/NetworkLoadMetrics.h:
(WebCore::NetworkLoadMetrics::isolatedCopy):
(WebCore::NetworkLoadMetrics::reset):
(WebCore::NetworkLoadMetrics::clearNonTimingData):
(WebCore::NetworkLoadMetrics::operator==):
(WebCore::NetworkLoadMetrics::encode):
(WebCore::NetworkLoadMetrics::decode):
* platform/spi/cf/CFNetworkSPI.h:

Source/WebInspectorUI:

* UserInterface/Controllers/FrameResourceManager.js:
(WebInspector.FrameResourceManager.prototype.resourceRequestWasServedFromMemoryCache):
Set an exact size.

* UserInterface/Models/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.get requestHeadersTransferSize):
(WebInspector.Resource.prototype.get requestBodyTransferSize):
(WebInspector.Resource.prototype.get responseHeadersTransferSize):
(WebInspector.Resource.prototype.get responseBodyTransferSize):
(WebInspector.Resource.prototype.get cachedResponseBodySize):
(WebInspector.Resource.prototype.get size):
(WebInspector.Resource.prototype.get networkEncodedSize):
(WebInspector.Resource.prototype.get networkDecodedSize):
(WebInspector.Resource.prototype.get networkTotalTransferSize):
(WebInspector.Resource.prototype.get estimatedNetworkEncodedSize):
(WebInspector.Resource.prototype.get estimatedTotalTransferSize):
(WebInspector.Resource.prototype.get compressed):
(WebInspector.Resource.prototype.updateForResponse):
(WebInspector.Resource.prototype.updateWithMetrics):
(WebInspector.Resource.prototype.setCachedResponseBodySize):
(WebInspector.Resource.prototype.increaseSize):
(WebInspector.Resource.prototype.increaseTransferSize):
(WebInspector.Resource.prototype.get encodedSize): Deleted.
(WebInspector.Resource.prototype.get transferSize): Deleted.
Be more explicit with size getters.

(WebInspector.Resource.prototype.updateWithMetrics):
If we receive the size metrics, update the specific metric values.

* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshCompressed):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshDecodedSize):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshTransferSize):
* UserInterface/Views/ResourceTimelineDataGridNode.js:
(WebInspector.ResourceTimelineDataGridNode.prototype.get data):
Show exact values if we have them, otherwise fall back to the calculated
values during loading.

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::sendResultForCacheEntry):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
Include size information in network load metrics.

LayoutTests:

* http/tests/inspector/network/resource-sizes-disk-cache-expected.txt: Added.
* http/tests/inspector/network/resource-sizes-disk-cache.html: Added.
* http/tests/inspector/network/resource-sizes-memory-cache-expected.txt: Added.
* http/tests/inspector/network/resource-sizes-memory-cache.html: Added.
* http/tests/inspector/network/resource-sizes-network-expected.txt: Added.
* http/tests/inspector/network/resource-sizes-network.html: Added.
Test resource sizes under different load conditions.

* platform/mac/http/tests/inspector/network/resource-sizes-memory-cache-expected.txt: Added.
* platform/mac/http/tests/inspector/network/resource-sizes-network-expected.txt: Added.
Older versions of macOS will not have the new metrics, but test their output anyways.

* http/tests/inspector/network/resources/404.php: Added.
* http/tests/inspector/network/resources/gzipped-lorem-no-content-length.php: Added.
* http/tests/inspector/network/resources/gzipped-lorem.php: Added.
* http/tests/inspector/network/resources/lorem.txt: Added.
Different resources with fixed sizes (text, gzipped, 404 with fixed response).

* http/tests/inspector/network/resources/resource-size-test.js: Added.
(TestPage.registerInitializer.InspectorTest.gracefulExpectEquals):
(TestPage.registerInitializer.window.addResourceSizeTest):
(TestPage.registerInitializer):
Shared test code for resource sizes.

* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/resource-sizes-disk-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resource-sizes-disk-cache.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resource-sizes-memory-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resource-sizes-memory-cache.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resource-sizes-network-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resource-sizes-network.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/404.php [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/gzipped-lorem-no-content-length.php [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/gzipped-lorem.php [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/lorem.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/resources/resource-size-test.js [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/http/tests/inspector/network/resource-sizes-memory-cache-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/http/tests/inspector/network/resource-sizes-network-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Network.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/platform/network/NetworkLoadMetrics.h
Source/WebCore/platform/spi/cf/CFNetworkSPI.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm