WebKit Bugzilla
Attachment 371886 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 v3
itp_test.patch (text/plain), 7.36 KB, created by
Brent Fulgham
on 2019-06-11 15:36:12 PDT
(
hide
)
Description:
patch v3
Filename:
MIME Type:
Creator:
Brent Fulgham
Created:
2019-06-11 15:36:12 PDT
Size:
7.36 KB
patch
obsolete
>diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index cadb9675658..160cac21d44 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2019-06-11 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 allows test code >+ to mark a domain as prevalent, and check the prevalance of a resource. This >+ is then used to build a test to confirm ITP is active and working. >+ >+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: >+ (-[WKWebsiteDataStore _setPrevalentDomain:completionHandler:]): >+ (-[WKWebsiteDataStore _getIsPrevalentDomain:completionHandler:]): >+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: >+ > 2019-06-11 Michael Catanzaro <mcatanzaro@igalia.com> > > Unreviewed build warning fixes >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >index 3db26c1d988..6d020972058 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >@@ -480,6 +480,27 @@ - (void)_getAllStorageAccessEntriesFor:(WKWebView *)webView completionHandler:(v > #endif > } > >+- (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ _websiteDataStore->websiteDataStore().setPrevalentResource(URL(domain), [completionHandler = makeBlockPtr(completionHandler)]() { >+ completionHandler(); >+ }); >+#endif >+ completionHandler(); >+} >+ >+- (void)_getIsPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(BOOL))completionHandler >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ _websiteDataStore->websiteDataStore().isPrevalentResource(URL(domain), [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 2f8f4628068..237a3704ece 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h >@@ -67,6 +67,9 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) { > + (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); > - (bool)_hasRegisteredServiceWorker WK_API_AVAILABLE(macos(10.14), ios(12.0)); > >+- (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); >+- (void)_getIsPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ > @property (nullable, nonatomic, weak) id <_WKWebsiteDataStoreDelegate> _delegate WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > @end >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 07732108afe..e873363616b 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+22019-06-11 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-11 Keith Rollin <krollin@apple.com> > > Open up xcfilelist processing to more platforms >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm >index 83b28196a2f..e1509585ce8 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,79 @@ 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, no URLs are prevalent. >+ static bool doneFlag; >+ [dataStore _getIsPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL prevalent) { >+ EXPECT_FALSE(prevalent); >+ 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, but nothing was registered as prevalent yet. >+ doneFlag = false; >+ [dataStore _getIsPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL prevalent) { >+ EXPECT_FALSE(prevalent); >+ doneFlag = true; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneFlag); >+ >+ // Teach ITP about a bad origin: >+ doneFlag = false; >+ [dataStore _setPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(void) { >+ doneFlag = true; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneFlag); >+ >+ [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; >+ [webView _test_waitForDidFinishNavigation]; >+ >+ // ITP should be on, and know about 'evil.com' >+ doneFlag = false; >+ [dataStore _getIsPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL prevalent) { >+ EXPECT_TRUE(prevalent); >+ 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, no URLs are prevalent. >+ doneFlag = false; >+ [dataStore _getIsPrevalentDomain:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL prevalent) { >+ EXPECT_FALSE(prevalent); >+ 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
Flags:
youennf
:
review+
commit-queue
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198694
:
371703
|
371884
| 371886