WebKit Bugzilla
Attachment 371703 Details for
Bug 198694
: Add mechanism and test case to check if ITP is active
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198694-20190608225045.patch (text/plain), 13.63 KB, created by
Brent Fulgham
on 2019-06-08 22:50:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brent Fulgham
Created:
2019-06-08 22:50:46 PDT
Size:
13.63 KB
patch
obsolete
>Subversion Revision: 246235 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 254cfbe48c0643843db167c4c50691ab0e06a0d1..306f70f58d3fbda5acd3ee45cc79e94e3d60803c 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2019-06-08 Brent Fulgham <bfulgham@apple.com> >+ >+ Add mechanism and test case to check if ITP is active >+ https://bugs.webkit.org/show_bug.cgi?id=198694 >+ <rdar://problem/51557704> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a new private SPI call on the WebsiteDataStore object that reports >+ the current state of ResourceLoadStatistics (ITP) in the Network process. >+ >+ Note: The new API test will fail until Bug 198692 is landed. >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::resourceLoadStatisticsEnabled): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkProcess.messages.in: >+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: >+ (-[WKWebsiteDataStore _resourceLoadStatisticsEnabled:]): >+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: >+ * UIProcess/Network/NetworkProcessProxy.cpp: >+ (WebKit::NetworkProcessProxy::resourceLoadStatisticsEnabled): >+ * UIProcess/Network/NetworkProcessProxy.h: >+ * UIProcess/WebsiteData/WebsiteDataStore.cpp: >+ (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled): >+ * UIProcess/WebsiteData/WebsiteDataStore.h: >+ > 2019-06-08 Andy Estes <aestes@apple.com> > > [Apple Pay] If we have a bound interface identifier, set it on new PKPaymentRequests >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index dd9a1e3a8c5d76d2dd435303b7b8365ccae092e2..8a34e361a5127526fb37216387bbc5486c58ffd1 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -653,6 +653,16 @@ void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const Reg > } > } > >+void NetworkProcess::resourceLoadStatisticsEnabled(PAL::SessionID sessionID, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ bool enabled = false; >+ if (auto* networkSession = this->networkSession(sessionID)) >+ enabled = !!networkSession->resourceLoadStatistics(); >+ else >+ ASSERT_NOT_REACHED(); >+ completionHandler(enabled); >+} >+ > void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler) > { > if (auto* networkStorageSession = storageSession(sessionID)) >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index 0e1dabd00ee4ca94e22b2d25e0c32fbbc4054fdd..d993cf125ea6aa4f7870edd187b6c835bb7eacc5 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -222,6 +222,7 @@ public: > void isRegisteredAsRedirectingTo(PAL::SessionID, const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void(bool)>&&); > void isRegisteredAsSubFrameUnder(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); > void isRegisteredAsSubresourceUnder(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); >+ void resourceLoadStatisticsEnabled(PAL::SessionID, CompletionHandler<void(bool)>&&); > void setGrandfathered(PAL::SessionID, const RegistrableDomain&, bool isGrandfathered, CompletionHandler<void()>&&); > void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&&); > void setPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >index 6d0624083f75f332726ab3fb21dc1d2cff90c21c..f025e34b627ec2bde2160cfacf30f6cbfc8a39d4 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >@@ -107,6 +107,7 @@ messages -> NetworkProcess LegacyReceiver { > LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain) -> () Async > RemovePrevalentDomains(PAL::SessionID sessionID, Vector<WebCore::RegistrableDomain> domainsWithInteraction) > ResetParametersToDefaultValues(PAL::SessionID sessionID) -> () Async >+ ResourceLoadStatisticsEnabled(PAL::SessionID sessionID) -> (bool enabled) Async > ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, enum:bool WebKit::ShouldGrandfatherStatistics shouldGrandfather) -> () Async > ScheduleCookieBlockingUpdate(PAL::SessionID sessionID) -> () Async > ScheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID) -> () Async >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >index 3db26c1d988828d6212befbba485090d70147861..87abb2bbfeef127d11f437f9a1b0cdea45d791de 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >@@ -480,6 +480,17 @@ - (void)_getAllStorageAccessEntriesFor:(WKWebView *)webView completionHandler:(v > #endif > } > >+- (void)_resourceLoadStatisticsEnabled:(void (^)(BOOL))completionHandler >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ _websiteDataStore->websiteDataStore().resourceLoadStatisticsEnabled([completionHandler = makeBlockPtr(completionHandler)](bool enabled) { >+ completionHandler(enabled); >+ }); >+#else >+ completionHandler(NO); >+#endif >+} >+ > - (bool)_hasRegisteredServiceWorker > { > return WebKit::ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(_websiteDataStore->websiteDataStore().serviceWorkerRegistrationDirectory()); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >index 2f8f4628068c67bf560170c5f873809347352c3b..3fe7a67478fd622513a04e9acea7465ef8e6cfc3 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >@@ -69,6 +69,8 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) { > > @property (nullable, nonatomic, weak) id <_WKWebsiteDataStoreDelegate> _delegate WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > >+- (void)_resourceLoadStatisticsEnabled:(void (^)(BOOL))completionHandler; >+ > @end > > NS_ASSUME_NONNULL_END >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >index 346ac6720a65881fd098b5c34f1bd8add9cce09e..304264e1512a067a23e2ce89bd40eee2ba45f3e5 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >@@ -747,6 +747,16 @@ void NetworkProcessProxy::requestStorageAccessConfirm(PageIdentifier pageID, uin > page->requestStorageAccessConfirm(subFrameDomain, topFrameDomain, frameID, WTFMove(completionHandler)); > } > >+void NetworkProcessProxy::resourceLoadStatisticsEnabled(PAL::SessionID sessionID, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ sendWithAsyncReply(Messages::NetworkProcess::ResourceLoadStatisticsEnabled(sessionID), WTFMove(completionHandler)); >+} >+ > void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String> domains)>&& completionHandler) > { > if (!canSendMessage()) { >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >index 97088e9a4eedc90745987f77c34383485405b990..9c948d3e8c72871173c803e45a12265e2fe27ff6 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >@@ -111,6 +111,7 @@ public: > void isRegisteredAsSubresourceUnder(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); > void isVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); > void logUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); >+ void resourceLoadStatisticsEnabled(PAL::SessionID, CompletionHandler<void(bool)>&&); > void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); > void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); > void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >index 3ba29b31e0f3e89ba154587c1521a8aea7869a4f..f4d978c1643d608cc2aeca01e86d02715a8905fc 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >@@ -1880,6 +1880,14 @@ void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled) > #endif > } > >+void WebsiteDataStore::resourceLoadStatisticsEnabled(CompletionHandler<void(bool)>&& completionHandler) >+{ >+ for (auto& processPool : processPools()) { >+ processPool->ensureNetworkProcess().resourceLoadStatisticsEnabled(m_sessionID, WTFMove(completionHandler)); >+ break; >+ } >+} >+ > void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) > { > setResourceLoadStatisticsDebugMode(enabled, []() { }); >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >index 822c3fc7637d7c5eb003c69ce94745bd382593f2..3636a9371c05a118e3a3e4a3dfee7b467a7f424a 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >@@ -110,6 +110,8 @@ public: > void setResourceLoadStatisticsDebugMode(bool); > void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); > >+ void resourceLoadStatisticsEnabled(CompletionHandler<void(bool)>&&); // Checks state at the network process level >+ > uint64_t perOriginStorageQuota() const { return m_resolvedConfiguration->perOriginStorageQuota(); } > uint64_t perThirdPartyOriginStorageQuota() const; > void setPerOriginStorageQuota(uint64_t quota) { m_resolvedConfiguration->setPerOriginStorageQuota(quota); } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 50e088fe0e62281d98247eb7d1455fd20ad0ae3a..c7f352b70d477dfd9c40a9970fa78f8c4c7d1476 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2019-06-08 Brent Fulgham <bfulgham@apple.com> >+ >+ Add mechanism and test case to check if ITP is active >+ https://bugs.webkit.org/show_bug.cgi?id=198694 >+ <rdar://problem/51557704> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm: >+ (TEST): >+ > 2019-06-08 Zalan Bujtas <zalan@apple.com> > > [LFC] Unreviewed test gardening. >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm >index 83b28196a2fb9aba02f18f13d58d614d81a3cfa5..6c31f9a109ec8fd72e96b3ab2b0ddc4c1dfc15ed 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm >@@ -26,6 +26,7 @@ > #include "config.h" > > #import "PlatformUtilities.h" >+#import "TestNavigationDelegate.h" > #import <WebKit/WKFoundation.h> > #import <WebKit/WKProcessPoolPrivate.h> > #import <WebKit/WKWebViewConfigurationPrivate.h> >@@ -204,3 +205,59 @@ TEST(ResourceLoadStatistics, IPCAfterStoreDestruction) > > TestWebKitAPI::Util::run(&finishedNavigation); > } >+ >+TEST(ResourceLoadStatistics, EnableDisableITP) >+{ >+ // Ensure the shared process pool exists so the data store operations we're about to do work with it. >+ WKProcessPool *sharedProcessPool = [WKProcessPool _sharedProcessPool]; >+ auto *dataStore = [WKWebsiteDataStore defaultDataStore]; >+ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [configuration setProcessPool: sharedProcessPool]; >+ configuration.get().websiteDataStore = dataStore; >+ >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ >+ [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; >+ [webView _test_waitForDidFinishNavigation]; >+ >+ // ITP should be off: >+ static bool doneFlag; >+ [dataStore _resourceLoadStatisticsEnabled:^(BOOL enabled) { >+ EXPECT_FALSE(enabled); >+ doneFlag = true; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneFlag); >+ >+ // Turn it on >+ [dataStore _setResourceLoadStatisticsEnabled:YES]; >+ >+ [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; >+ [webView _test_waitForDidFinishNavigation]; >+ >+ // ITP should be on: >+ doneFlag = false; >+ [dataStore _resourceLoadStatisticsEnabled:^(BOOL enabled) { >+ EXPECT_TRUE(enabled); >+ doneFlag = true; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneFlag); >+ >+ // Turn it off >+ [dataStore _setResourceLoadStatisticsEnabled:NO]; >+ >+ [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; >+ [webView _test_waitForDidFinishNavigation]; >+ >+ // ITP should be off: >+ doneFlag = false; >+ [dataStore _resourceLoadStatisticsEnabled:^(BOOL enabled) { >+ EXPECT_FALSE(enabled); >+ doneFlag = true; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneFlag); >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198694
:
371703
|
371884
|
371886