- Revision
- 258357
- Author
- katherine_che...@apple.com
- Date
- 2020-03-12 14:22:49 -0700 (Thu, 12 Mar 2020)
Log Message
Resource load statistics data summary should return all third party data
https://bugs.webkit.org/show_bug.cgi?id=209000
<rdar://problem/60348306>
Reviewed by John Wilander.
Source/WebKit:
No new tests, this patch adjusts old tests to test this new behavior
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _setThirdPartyCookieBlockingMode:onlyOnSitesWithoutUserInteraction:completionHandler:]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
Added new function _setThirdPartyCookieBlockingMode so API tests can
set this parameter.
Tools:
Marked only 2 of 3 domains prevalent in data summary tests to ensure
the call returns all third parties, not just prevalent ones.
Added a more aggressive check for the size of the array at the
beginning of the test to ensure the array is still returning 3 values.
Also removed the ASSERT statements as they seem to cause timeouts (not
clear crashes) when they are not true, which is hard to debug.
If these values are nil, the test will fail in the EXPECT_WK_STREQ
checks, we don't need ASSERT statements.
* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (258356 => 258357)
--- trunk/Source/WebKit/ChangeLog 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Source/WebKit/ChangeLog 2020-03-12 21:22:49 UTC (rev 258357)
@@ -1,3 +1,20 @@
+2020-03-12 Kate Cheney <katherine_che...@apple.com>
+
+ Resource load statistics data summary should return all third party data
+ https://bugs.webkit.org/show_bug.cgi?id=209000
+ <rdar://problem/60348306>
+
+ Reviewed by John Wilander.
+
+ No new tests, this patch adjusts old tests to test this new behavior
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _setThirdPartyCookieBlockingMode:onlyOnSitesWithoutUserInteraction:completionHandler:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ Added new function _setThirdPartyCookieBlockingMode so API tests can
+ set this parameter.
+
2020-03-12 Alex Christensen <achristen...@webkit.org>
WKWebView.hasOnlySecureContent should be correct after back/forward navigations
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (258356 => 258357)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2020-03-12 21:22:49 UTC (rev 258357)
@@ -839,9 +839,10 @@
ASSERT(!RunLoop::isMain());
Vector<WebResourceLoadStatisticsStore::ThirdPartyData> thirdPartyDataList;
+ const auto prevalentDomainsBindParameter = thirdPartyCookieBlockingMode() == ThirdPartyCookieBlockingMode::All ? "%" : "1";
SQLiteStatement sortedStatistics(m_database, makeString("SELECT ", joinSubStatisticsForSorting()));
if (sortedStatistics.prepare() != SQLITE_OK
- || sortedStatistics.bindText(1, "1")
+ || sortedStatistics.bindText(1, prevalentDomainsBindParameter)
|| sortedStatistics.bindText(2, "%") != SQLITE_OK) {
RELEASE_LOG_ERROR(Network, "ResourceLoadStatisticsDatabaseStore::aggregatedThirdPartyData, error message: %" PUBLIC_LOG_STRING, m_database.lastErrorMsg());
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (258356 => 258357)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2020-03-12 21:22:49 UTC (rev 258357)
@@ -575,6 +575,17 @@
#endif
}
+- (void)_setThirdPartyCookieBlockingMode:(BOOL)enabled onlyOnSitesWithoutUserInteraction:(BOOL)onlyOnSitesWithoutUserInteraction completionHandler:(void (^)(void))completionHandler
+{
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ _websiteDataStore->setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(enabled, onlyOnSitesWithoutUserInteraction, [completionHandler = makeBlockPtr(completionHandler)]() {
+ completionHandler();
+ });
+#else
+ completionHandler();
+#endif
+}
+
- (bool)_hasRegisteredServiceWorker
{
#if ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (258356 => 258357)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2020-03-12 21:22:49 UTC (rev 258357)
@@ -76,6 +76,7 @@
- (void)_clearPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_clearResourceLoadStatistics:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_isRegisteredAsSubresourceUnderFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_setThirdPartyCookieBlockingMode:(BOOL)enabled onlyOnSitesWithoutUserInteraction:(BOOL)onlyOnSitesWithoutUserInteraction completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_processStatisticsAndDataRecords:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(10.15), ios(13.0));
- (void)_appBoundDomains:(void (^)(NSArray<NSString *> *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Tools/ChangeLog (258356 => 258357)
--- trunk/Tools/ChangeLog 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Tools/ChangeLog 2020-03-12 21:22:49 UTC (rev 258357)
@@ -1,3 +1,23 @@
+2020-03-12 Kate Cheney <katherine_che...@apple.com>
+
+ Resource load statistics data summary should return all third party data
+ https://bugs.webkit.org/show_bug.cgi?id=209000
+ <rdar://problem/60348306>
+
+ Reviewed by John Wilander.
+
+ Marked only 2 of 3 domains prevalent in data summary tests to ensure
+ the call returns all third parties, not just prevalent ones.
+ Added a more aggressive check for the size of the array at the
+ beginning of the test to ensure the array is still returning 3 values.
+ Also removed the ASSERT statements as they seem to cause timeouts (not
+ clear crashes) when they are not true, which is hard to debug.
+ If these values are nil, the test will fail in the EXPECT_WK_STREQ
+ checks, we don't need ASSERT statements.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
2020-03-12 Jonathan Bedard <jbed...@apple.com>
resultsdpy: Add script to run local instance
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (258356 => 258357)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2020-03-12 21:12:13 UTC (rev 258356)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2020-03-12 21:22:49 UTC (rev 258357)
@@ -982,11 +982,16 @@
}];
TestWebKitAPI::Util::run(&doneFlag);
-
- // set third parties to be prevalent
- [dataStore _setPrevalentDomain:[NSURL URLWithString:@"http://evil1.com"] completionHandler: ^(void) {
+
+ doneFlag = false;
+ [dataStore _setThirdPartyCookieBlockingMode:true onlyOnSitesWithoutUserInteraction:false completionHandler: ^(void) {
doneFlag = true;
}];
+
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ // Set two third parties to be prevalent, leave evil1.com as non-prevalent to ensure
+ // this call returns all third parties.
doneFlag = false;
[dataStore _setPrevalentDomain:[NSURL URLWithString:@"http://evil2.com"] completionHandler: ^(void) {
doneFlag = true;
@@ -1096,6 +1101,7 @@
doneFlag = false;
[dataStore _getResourceLoadStatisticsDataSummary:^void(NSArray<_WKResourceLoadStatisticsThirdParty *> *thirdPartyData)
{
+ EXPECT_EQ(static_cast<int>([thirdPartyData count]), 3);
NSEnumerator *thirdPartyDomains = [thirdPartyData objectEnumerator];
// evil3
@@ -1107,10 +1113,6 @@
_WKResourceLoadStatisticsFirstParty *evil3FirstParty2 = [evil3Enumerator nextObject];
_WKResourceLoadStatisticsFirstParty *evil3FirstParty3 = [evil3Enumerator nextObject];
- ASSERT_TRUE(evil3FirstParty1 != nil);
- ASSERT_TRUE(evil3FirstParty2 != nil);
- ASSERT_TRUE(evil3FirstParty3 != nil);
-
EXPECT_WK_STREQ(evil3FirstParty1.firstPartyDomain, @"webkit2.org");
EXPECT_WK_STREQ(evil3FirstParty2.firstPartyDomain, @"webkit3.org");
EXPECT_WK_STREQ(evil3FirstParty3.firstPartyDomain, @"webkit.org");
@@ -1127,9 +1129,6 @@
_WKResourceLoadStatisticsFirstParty *evil1FirstParty1= [evil1Enumerator nextObject];
_WKResourceLoadStatisticsFirstParty *evil1FirstParty2 = [evil1Enumerator nextObject];
- ASSERT_TRUE(evil1FirstParty1 != nil);
- ASSERT_TRUE(evil1FirstParty2 != nil);
-
EXPECT_WK_STREQ(evil1FirstParty1.firstPartyDomain, @"webkit2.org");
EXPECT_WK_STREQ(evil1FirstParty2.firstPartyDomain, @"webkit.org");
@@ -1143,8 +1142,6 @@
NSEnumerator *evil2Enumerator = [evil2ThirdParty.underFirstParties objectEnumerator];
_WKResourceLoadStatisticsFirstParty *evil2FirstParty1 = [evil2Enumerator nextObject];
- ASSERT_TRUE(evil2FirstParty1 != nil);
-
EXPECT_WK_STREQ(evil2FirstParty1.firstPartyDomain, @"webkit.org");
EXPECT_FALSE(evil2FirstParty1.thirdPartyStorageAccessGranted);
doneFlag = true;
@@ -1181,7 +1178,14 @@
}];
TestWebKitAPI::Util::run(&doneFlag);
+
+ doneFlag = false;
+ [dataStore _setThirdPartyCookieBlockingMode:true onlyOnSitesWithoutUserInteraction:false completionHandler: ^(void) {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
doneFlag = false;
[dataStore _clearResourceLoadStatistics:^(void) {
doneFlag = true;
@@ -1196,15 +1200,9 @@
TestWebKitAPI::Util::run(&doneFlag);
- // Teach ITP about bad origins.
+ // Set two third parties to be prevalent, leave evil1.com as non-prevalent to ensure
+ // this call returns all third parties.
doneFlag = false;
- [dataStore _setPrevalentDomain:[NSURL URLWithString:@"http://evil1.com"] completionHandler: ^(void) {
- doneFlag = true;
- }];
-
- TestWebKitAPI::Util::run(&doneFlag);
-
- doneFlag = false;
[dataStore _setPrevalentDomain:[NSURL URLWithString:@"http://evil2.com"] completionHandler: ^(void) {
doneFlag = true;
}];
@@ -1316,6 +1314,7 @@
doneFlag = false;
[dataStore _getResourceLoadStatisticsDataSummary:^void(NSArray<_WKResourceLoadStatisticsThirdParty *> *thirdPartyData)
{
+ EXPECT_EQ(static_cast<int>([thirdPartyData count]), 3);
NSEnumerator *thirdPartyDomains = [thirdPartyData objectEnumerator];
// evil3
@@ -1327,10 +1326,6 @@
_WKResourceLoadStatisticsFirstParty *evil3FirstParty2 = [evil3Enumerator nextObject];
_WKResourceLoadStatisticsFirstParty *evil3FirstParty3 = [evil3Enumerator nextObject];
- ASSERT_TRUE(evil3FirstParty1 != nil);
- ASSERT_TRUE(evil3FirstParty2 != nil);
- ASSERT_TRUE(evil3FirstParty3 != nil);
-
EXPECT_WK_STREQ(evil3FirstParty1.firstPartyDomain, @"webkit2.org");
EXPECT_WK_STREQ(evil3FirstParty2.firstPartyDomain, @"webkit3.org");
EXPECT_WK_STREQ(evil3FirstParty3.firstPartyDomain, @"webkit.org");
@@ -1366,9 +1361,6 @@
_WKResourceLoadStatisticsFirstParty *evil1FirstParty1= [evil1Enumerator nextObject];
_WKResourceLoadStatisticsFirstParty *evil1FirstParty2 = [evil1Enumerator nextObject];
- ASSERT_TRUE(evil1FirstParty1 != nil);
- ASSERT_TRUE(evil1FirstParty2 != nil);
-
EXPECT_WK_STREQ(evil1FirstParty1.firstPartyDomain, @"webkit2.org");
EXPECT_WK_STREQ(evil1FirstParty2.firstPartyDomain, @"webkit.org");
@@ -1395,8 +1387,6 @@
NSEnumerator *evil2Enumerator = [evil2ThirdParty.underFirstParties objectEnumerator];
_WKResourceLoadStatisticsFirstParty *evil2FirstParty1 = [evil2Enumerator nextObject];
- ASSERT_TRUE(evil2FirstParty1 != nil);
-
EXPECT_WK_STREQ(evil2FirstParty1.firstPartyDomain, @"webkit.org");
EXPECT_FALSE(evil2FirstParty1.thirdPartyStorageAccessGranted);