Title: [246360] trunk
- Revision
- 246360
- Author
- bfulg...@apple.com
- Date
- 2019-06-12 10:18:24 -0700 (Wed, 12 Jun 2019)
Log Message
Add mechanism and test case to check if ITP is active
https://bugs.webkit.org/show_bug.cgi?id=198694
<rdar://problem/51557704>
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (246359 => 246360)
--- trunk/Source/WebKit/ChangeLog 2019-06-12 16:58:12 UTC (rev 246359)
+++ trunk/Source/WebKit/ChangeLog 2019-06-12 17:18:24 UTC (rev 246360)
@@ -1,3 +1,20 @@
+2019-06-12 Brent Fulgham <bfulg...@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 Youenn Fablet.
+
+ 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-12 Wenson Hsieh <wenson_hs...@apple.com>
Many layout tests are failing on iPad simulator due to unexpected viewport dimensions
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (246359 => 246360)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-06-12 16:58:12 UTC (rev 246359)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-06-12 17:18:24 UTC (rev 246360)
@@ -480,6 +480,27 @@
#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());
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (246359 => 246360)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-06-12 16:58:12 UTC (rev 246359)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-06-12 17:18:24 UTC (rev 246360)
@@ -67,6 +67,9 @@
+ (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
Modified: trunk/Tools/ChangeLog (246359 => 246360)
--- trunk/Tools/ChangeLog 2019-06-12 16:58:12 UTC (rev 246359)
+++ trunk/Tools/ChangeLog 2019-06-12 17:18:24 UTC (rev 246360)
@@ -1,3 +1,14 @@
+22019-06-11 Brent Fulgham <bfulg...@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 Youenn Fablet.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
2019-06-12 Michael Catanzaro <mcatanz...@igalia.com>
[WPE][GTK] Deprecate WebSQL APIs
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (246359 => 246360)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-06-12 16:58:12 UTC (rev 246359)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-06-12 17:18:24 UTC (rev 246360)
@@ -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 @@
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);
+}
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes