Resource Load Statistics: Make it possible exclude localhost from classification
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 17:01:27 +0000 (17:01 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 17:01:27 +0000 (17:01 +0000)
commit3434c15afca4a2188227bb4b1945b30405c52c24
treef0cbf085c29c7a654db61e7ca127111feea3d07b
parent0ec9db876539ab1d0a28b1b511b0693718784254
Resource Load Statistics: Make it possible exclude localhost from classification
https://bugs.webkit.org/show_bug.cgi?id=195474
<rdar://problem/47520577>

Reviewed by Brent Fulgham.

Source/WebKit:

This patch allows for localhost to be excluded from classification and
treatment as a prevalent resource.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
(WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
(WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
(WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource):
    Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
    Now takes a ShouldIncludeLocalhost parameter.
(WebKit::ResourceLoadStatisticsStore::shouldSkip const):
    Convenience function, currently supporting the localhost exclusion.
(WebKit::ResourceLoadStatisticsStore::setIsRunningTest):
    Test infrastructure.
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::setIsRunningTest):
    Test infrastructure.
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
    Now takes a ShouldIncludeLocalhost parameter.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
    Defines the new ShouldIncludeLocalhost boolean enum.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest):
    Test infrastructure.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
    Forwards the localhost setting to the create function.
* NetworkProcess/NetworkSession.h:
* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
    New parameter called shouldIncludeLocalhostInResourceLoadStatistics.
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
    Picks up the localhost setting from the parameters.
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreSetStatisticsIsRunningTest):
    Test infrastructure.
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::setIsRunningResourceLoadStatisticsTest):
    Test infrastructure.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
    Picks up the localhost setting from the WebsiteDataStore parameters.
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::parameters):
    Makes sure Safari does not exclude localhost.
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest):
    Test infrastructure.
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

This patch allows for localhost to be excluded from classification and
treatment as a prevalent resource.

The WebKit Tools change adds a new function called
testRunner.setStatisticsIsRunningTest() which can be used to control this
behavior.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsIsRunningTest):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsIsRunningTest):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

This patch makes sure that all test cases that need to, call the enableFeature()
function in http/tests/resourceLoadStatistics/resources/util.js.

The enableFeature() now calls the new function testRunner.setStatisticsIsRunningTest().

* http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html:
* http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
* http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
* http/tests/resourceLoadStatistics/resources/set-cookie-on-redirect.php:
* http/tests/resourceLoadStatistics/resources/util.js:
(setEnableFeature):
* http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html:
* http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction.html:
* http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html:
* http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe.html:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html:
* http/tests/storageAccess/request-storage-access-same-origin-iframe.html:
* http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe.html:
* http/tests/storageAccess/request-storage-access-top-frame.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
LayoutTests/http/tests/resourceLoadStatistics/resources/set-cookie-on-redirect.php
LayoutTests/http/tests/resourceLoadStatistics/resources/util.js
LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction.html
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe.html
LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html
LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html
LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe.html
LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp