Web Inspector: Should be able to see where Resources came from (Memory Cache, Disk Cache)
https://bugs.webkit.org/show_bug.cgi?id=164892
<rdar://problem/29320562>
Reviewed by Brian Burg.
Source/JavaScriptCore:
* inspector/protocol/Network.json:
Replace "fromDiskCache" property with "source" property which includes
more complete information about the source of this response (network,
memory cache, disk cache, or unknown).
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(_generate_class_for_object_declaration):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
* inspector/scripts/codegen/generator.py:
(Generator):
(Generator.open_fields):
To avoid conflicts between the Inspector::Protocol::Network::Response::Source
enum and open accessor string symbol that would have the same name, only generate
a specific list of open accessor strings. This reduces the list of exported
symbols from all properties to just the ones that are needed. This can be
cleaned up later if needed.
* inspector/scripts/tests/generic/expected/type-with-open-parameters.json-result: Added.
* inspector/scripts/tests/generic/type-with-open-parameters.json: Added.
Test for open accessors generation.
Source/WebCore:
Test: http/tests/inspector/network/resource-response-source-disk-cache.html
http/tests/inspector/network/resource-response-source-memory-cache.html
http/tests/inspector/network/resource-response-source-network.html
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::setSource): Deleted.
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::setSource):
Make Source mutable to allow it to be set in const methods.
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveResponse):
Set the Response source after a successful memory cache validation
as early as possible so that future copies have up to date info.
* inspector/InspectorNetworkAgent.cpp:
(WebCore::responseSource):
(WebCore::InspectorNetworkAgent::buildObjectForResourceResponse):
(WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache):
(WebCore::InspectorNetworkAgent::markResourceAsCached): Deleted.
Eliminate this "markResourceAsCached" path.
Update Response to include required source parameter instead of
optional fromDiskCache parameter.
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::markResourceAsCachedImpl): Deleted.
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::markResourceAsCached): Deleted.
* inspector/InspectorNetworkAgent.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadedResourceFromMemoryCache):
Eliminate this "markResourceAsCached" call because the later delegate
messages will include this information.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js:
New localized strings for memory/disk cache information.
* UserInterface/Controllers/FrameResourceManager.js:
(WebInspector.FrameResourceManager.prototype.markResourceRequestAsServedFromMemoryCache):
Make this legacy path more explicit.
(WebInspector.FrameResourceManager.prototype.resourceRequestWasServedFromMemoryCache):
Make this memory cache path more explicit.
(WebInspector.FrameResourceManager.prototype.resourceRequestDidReceiveResponse):
Pass the resource's response source onward.
* UserInterface/Models/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.responseSourceFromPayload):
(WebInspector.Resource.prototype.get responseSource):
(WebInspector.Resource.prototype.hasResponse):
(WebInspector.Resource.prototype.updateForResponse):
(WebInspector.Resource.prototype.markAsCached):
(WebInspector.Resource.prototype.legacyMarkServedFromMemoryCache):
(WebInspector.Resource.prototype.legacyMarkServedFromDiskCache):
Include a WebInspector.ResponseSource enum.
Update a Resource's responseSource state where appropriate.
* UserInterface/Protocol/NetworkObserver.js:
(WebInspector.NetworkObserver.prototype.requestServedFromCache):
Mark legacy path.
* UserInterface/Views/NetworkGridContentView.js:
(WebInspector.NetworkGridContentView):
* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView):
Tweak default column sizes to make Cached and graph columns a little larger.
* UserInterface/Views/ResourceTimelineDataGridNode.js:
(WebInspector.ResourceTimelineDataGridNode.prototype.createCellContent):
(WebInspector.ResourceTimelineDataGridNode.prototype._cachedCellContent):
Update "Cached" column data with more information if available.
* UserInterface/Views/NetworkGridContentView.css:
(.content-view.network-grid > .data-grid .cache-type):
(.content-view.network-grid > .data-grid:matches(:focus, .force-focus) tr.selected .cache-type):
Style the cache type a secondary color.
LayoutTests:
* http/tests/inspector/network/resource-response-source-disk-cache-expected.txt: Added.
* http/tests/inspector/network/resource-response-source-disk-cache.html: Added.
* http/tests/inspector/network/resource-response-source-memory-cache-expected.txt: Added.
* http/tests/inspector/network/resource-response-source-memory-cache.html: Added.
* http/tests/inspector/network/resource-response-source-network-expected.txt: Added.
* http/tests/inspector/network/resource-response-source-network.html: Added.
* http/tests/inspector/network/resources/cached-script.js: Added.
Test for Network, MemoryCache, and DiskCache loads.
* http/tests/inspector/network/resource-timing-expected.txt:
* http/tests/inspector/network/resource-timing.html:
Fix a typo.
* http/tests/cache/disk-cache/resources/cache-test.js:
(loadResourcesWithOptions):
(loadResources):
Fix typos and style.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
Skip disk cache tests where the disk cache is not enabled.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@213621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations
index ac02ea0..210f55f 100644
--- a/LayoutTests/platform/mac-wk1/TestExpectations
+++ b/LayoutTests/platform/mac-wk1/TestExpectations
@@ -146,6 +146,7 @@
# Disk cache is WK2 only
http/tests/cache/disk-cache
+http/tests/inspector/network/resource-response-source-disk-cache.html
[ Yosemite+ ] fast/ruby/ruby-expansion-cjk-2.html [ ImageOnlyFailure ]