Changeset 260668 in webkit
- Timestamp:
- Apr 24, 2020 2:08:10 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r260662 r260668 1 2020-04-24 Kate Cheney <katherine_cheney@apple.com> 2 3 Removing website data for a domain should delete corresponding ITP entry 4 https://bugs.webkit.org/show_bug.cgi?id=210864 5 <rdar://problem/59473193> 6 7 Reviewed by John Wilander. 8 9 Inserts values into the ITP database then tests removing the domain's 10 website data will remove all instances of that domain in the ITP 11 database. 12 13 Database store expectations will reflect the result of the new 14 domainIDExistsInDatabase function. Memory store tests will use the 15 dump output which should not include the deleted information. 16 17 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database-expected.txt: Added. 18 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html: Added. 19 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-expected.txt: Added. 20 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html: Added. 21 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database-expected.txt: Added. 22 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html: Added. 23 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-expected.txt: Added. 24 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html: Added. 25 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database-expected.txt: Added. 26 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html: Added. 27 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-expected.txt: Added. 28 * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html: Added. 29 1 30 2020-04-24 Antoine Quint <graouts@apple.com> 2 31 -
trunk/Source/WebKit/ChangeLog
r260667 r260668 1 2020-04-24 Kate Cheney <katherine_cheney@apple.com> 2 3 Removing website data for a domain should delete corresponding ITP entry 4 https://bugs.webkit.org/show_bug.cgi?id=210864 5 <rdar://problem/59473193> 6 7 Reviewed by John Wilander. 8 9 Tests: http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html 10 http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html 11 http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html 12 http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html 13 http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html 14 http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html 15 16 In the database store: deletes domain from the ObservedDomains table 17 when website data is deleted for that domain. This deletes every 18 instance of the domainID in the database due to cascading deletions. 19 20 In the memory store: deletes every instance of the domain in the 21 statistics map, which will update the plist. 22 23 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: 24 (WebKit::ResourceLoadStatisticsDatabaseStore::removeDataForDomain): 25 (WebKit::ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase): 26 Needed a new function to check for the existence of domainID in any 27 table. Existing queries rely on the ObservedDomains entry, which means 28 testing using those could result in a false positive if the domainID 29 was deleted from ObservedDomains but is floating around in another 30 table. 31 32 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: 33 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 34 (WebKit::ResourceLoadStatisticsMemoryStore::removeDataForDomain): 35 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: 36 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: 37 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 38 (WebKit::WebResourceLoadStatisticsStore::domainIDExistsInDatabase): 39 (WebKit::WebResourceLoadStatisticsStore::removeDataForDomain): 40 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 41 * NetworkProcess/NetworkProcess.cpp: 42 (WebKit::NetworkProcess::domainIDExistsInDatabase): 43 (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): 44 Pass RegistrableDomains vector to deleteWebsiteDataForOrigins, 45 captured based on the WebsiteData display name. 46 47 * NetworkProcess/NetworkProcess.h: 48 * NetworkProcess/NetworkProcess.messages.in: 49 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 50 (WKWebsiteDataStoreRemoveITPDataForDomain): 51 (WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase): 52 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 53 * UIProcess/Network/NetworkProcessProxy.cpp: 54 (WebKit::NetworkProcessProxy::deleteWebsiteDataForOrigins): 55 (WebKit::NetworkProcessProxy::domainIDExistsInDatabase): 56 * UIProcess/Network/NetworkProcessProxy.h: 57 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 58 (WebKit::WebsiteDataStore::removeData): 59 (WebKit::WebsiteDataStore::domainIDExistsInDatabase): 60 * UIProcess/WebsiteData/WebsiteDataStore.h: 61 1 62 2020-04-24 David Kilzer <ddkilzer@apple.com> 2 63 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
r260594 r260668 135 135 "UNION ALL SELECT topFrameDomainID FROM SubresourceUnderTopFrameDomains WHERE subresourceDomainID = ?" 136 136 "UNION ALL SELECT toDomainID FROM SubresourceUniqueRedirectsTo WHERE subresourceDomainID = ?"_s; 137 138 // EXISTS for testing queries 139 constexpr auto linkDecorationExistsQuery = "SELECT EXISTS (SELECT * FROM TopFrameLinkDecorationsFrom WHERE toDomainID = ? OR fromDomainID = ?)"_s; 140 constexpr auto scriptLoadExistsQuery = "SELECT EXISTS (SELECT * FROM TopFrameLoadedThirdPartyScripts WHERE topFrameDomainID = ? OR subresourceDomainID = ?)"_s; 141 constexpr auto subFrameExistsQuery = "SELECT EXISTS (SELECT * FROM SubframeUnderTopFrameDomains WHERE subFrameDomainID = ? OR topFrameDomainID = ?)"_s; 142 constexpr auto subResourceExistsQuery = "SELECT EXISTS (SELECT * FROM SubresourceUnderTopFrameDomains WHERE subresourceDomainID = ? OR topFrameDomainID = ?)"_s; 143 constexpr auto uniqueRedirectExistsQuery = "SELECT EXISTS (SELECT * FROM SubresourceUniqueRedirectsTo WHERE subresourceDomainID = ? OR toDomainID = ?)"_s; 144 constexpr auto observedDomainsExistsQuery = "SELECT EXISTS (SELECT * FROM ObservedDomains WHERE domainID = ?)"_s; 145 146 // DELETE Queries 147 constexpr auto removeAllDataQuery = "DELETE FROM ObservedDomains WHERE domainID = ?"_s; 137 148 138 149 const char* tables[] = { … … 291 302 , m_storageAccessExistsStatement(m_database, storageAccessExistsQuery) 292 303 , m_getMostRecentlyUpdatedTimestampStatement(m_database, getMostRecentlyUpdatedTimestampQuery) 304 , m_linkDecorationExistsStatement(m_database, linkDecorationExistsQuery) 305 , m_scriptLoadExistsStatement(m_database, scriptLoadExistsQuery) 306 , m_subFrameExistsStatement(m_database, subFrameExistsQuery) 307 , m_subResourceExistsStatement(m_database, subResourceExistsQuery) 308 , m_uniqueRedirectExistsStatement(m_database, uniqueRedirectExistsQuery) 309 , m_observedDomainsExistsStatement(m_database, observedDomainsExistsQuery) 310 , m_removeAllDataStatement(m_database, removeAllDataQuery) 293 311 , m_sessionID(sessionID) 294 312 { … … 632 650 || m_storageAccessExistsStatement.prepare() != SQLITE_OK 633 651 || m_getMostRecentlyUpdatedTimestampStatement.prepare() != SQLITE_OK 652 || m_linkDecorationExistsStatement.prepare() != SQLITE_OK 653 || m_scriptLoadExistsStatement.prepare() != SQLITE_OK 654 || m_subFrameExistsStatement.prepare() != SQLITE_OK 655 || m_subResourceExistsStatement.prepare() != SQLITE_OK 656 || m_uniqueRedirectExistsStatement.prepare() != SQLITE_OK 657 || m_observedDomainsExistsStatement.prepare() != SQLITE_OK 658 || m_removeAllDataStatement.prepare() != SQLITE_OK 634 659 ) { 635 660 RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::prepareStatements failed to prepare, error message: %" PUBLIC_LOG_STRING, this, m_database.lastErrorMsg()); … … 2244 2269 } 2245 2270 2271 void ResourceLoadStatisticsDatabaseStore::removeDataForDomain(const RegistrableDomain& domain) 2272 { 2273 auto domainIDToRemove = domainID(domain); 2274 if (!domainIDToRemove) 2275 return; 2276 2277 if (m_removeAllDataStatement.bindInt(1, *domainIDToRemove) != SQLITE_OK 2278 || m_removeAllDataStatement.step() != SQLITE_DONE) { 2279 RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::removeDataForDomain failed, error message: %{private}s", this, m_database.lastErrorMsg()); 2280 ASSERT_NOT_REACHED(); 2281 } 2282 2283 resetStatement(m_removeAllDataStatement); 2284 } 2285 2246 2286 void ResourceLoadStatisticsDatabaseStore::clear(CompletionHandler<void()>&& completionHandler) 2247 2287 { … … 2890 2930 } 2891 2931 2932 bool ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase(int domainID) 2933 { 2934 if (m_linkDecorationExistsStatement.bindInt(1, domainID) != SQLITE_OK 2935 || m_linkDecorationExistsStatement.bindInt(2, domainID) != SQLITE_OK 2936 || m_scriptLoadExistsStatement.bindInt(1, domainID) != SQLITE_OK 2937 || m_scriptLoadExistsStatement.bindInt(2, domainID) != SQLITE_OK 2938 || m_subFrameExistsStatement.bindInt(1, domainID) != SQLITE_OK 2939 || m_subFrameExistsStatement.bindInt(2, domainID) != SQLITE_OK 2940 || m_subResourceExistsStatement.bindInt(1, domainID) != SQLITE_OK 2941 || m_subResourceExistsStatement.bindInt(2, domainID) != SQLITE_OK 2942 || m_uniqueRedirectExistsStatement.bindInt(1, domainID) != SQLITE_OK 2943 || m_uniqueRedirectExistsStatement.bindInt(2, domainID) != SQLITE_OK 2944 || m_observedDomainsExistsStatement.bindInt(1, domainID) != SQLITE_OK) { 2945 RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase failed to bind, error message: %{private}s", this, m_database.lastErrorMsg()); 2946 ASSERT_NOT_REACHED(); 2947 return false; 2948 } 2949 2950 if (m_linkDecorationExistsStatement.step() != SQLITE_ROW 2951 || m_scriptLoadExistsStatement.step() != SQLITE_ROW 2952 || m_subFrameExistsStatement.step() != SQLITE_ROW 2953 || m_subResourceExistsStatement.step() != SQLITE_ROW 2954 || m_uniqueRedirectExistsStatement.step() != SQLITE_ROW 2955 || m_observedDomainsExistsStatement.step() != SQLITE_ROW) { 2956 RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase failed to step, error message: %{private}s", this, m_database.lastErrorMsg()); 2957 ASSERT_NOT_REACHED(); 2958 return false; 2959 } 2960 2961 resetStatement(m_linkDecorationExistsStatement); 2962 resetStatement(m_scriptLoadExistsStatement); 2963 resetStatement(m_subFrameExistsStatement); 2964 resetStatement(m_subResourceExistsStatement); 2965 resetStatement(m_uniqueRedirectExistsStatement); 2966 resetStatement(m_observedDomainsExistsStatement); 2967 2968 return m_linkDecorationExistsStatement.getColumnInt(0) || m_scriptLoadExistsStatement.getColumnInt(0) || m_subFrameExistsStatement.getColumnInt(0) || m_subResourceExistsStatement.getColumnInt(0) || m_uniqueRedirectExistsStatement.getColumnInt(0) || m_observedDomainsExistsStatement.getColumnInt(0); 2969 } 2970 2892 2971 } // namespace WebKit 2893 2972 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
r260594 r260668 139 139 bool isNewResourceLoadStatisticsDatabaseFile() const { return m_isNewResourceLoadStatisticsDatabaseFile; } 140 140 void setIsNewResourceLoadStatisticsDatabaseFile(bool isNewResourceLoadStatisticsDatabaseFile) { m_isNewResourceLoadStatisticsDatabaseFile = isNewResourceLoadStatisticsDatabaseFile; } 141 void removeDataForDomain(const RegistrableDomain&) override; 142 bool domainIDExistsInDatabase(int); 141 143 142 144 private: … … 264 266 mutable WebCore::SQLiteStatement m_storageAccessExistsStatement; 265 267 mutable WebCore::SQLiteStatement m_getMostRecentlyUpdatedTimestampStatement; 268 mutable WebCore::SQLiteStatement m_linkDecorationExistsStatement; 269 mutable WebCore::SQLiteStatement m_scriptLoadExistsStatement; 270 mutable WebCore::SQLiteStatement m_subFrameExistsStatement; 271 mutable WebCore::SQLiteStatement m_subResourceExistsStatement; 272 mutable WebCore::SQLiteStatement m_uniqueRedirectExistsStatement; 273 mutable WebCore::SQLiteStatement m_observedDomainsExistsStatement; 274 mutable WebCore::SQLiteStatement m_removeAllDataStatement; 266 275 PAL::SessionID m_sessionID; 267 276 bool m_isNewResourceLoadStatisticsDatabaseFile { false }; -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r260169 r260668 1043 1043 } 1044 1044 1045 void ResourceLoadStatisticsMemoryStore::removeDataForDomain(const RegistrableDomain& domain) 1046 { 1047 m_resourceStatisticsMap.remove(domain); 1048 1049 for (auto& statistic : m_resourceStatisticsMap) { 1050 statistic.value.topFrameUniqueRedirectsTo.remove(domain); 1051 statistic.value.topFrameUniqueRedirectsToSinceSameSiteStrictEnforcement.remove(domain); 1052 statistic.value.topFrameUniqueRedirectsFrom.remove(domain); 1053 statistic.value.topFrameLinkDecorationsFrom.remove(domain); 1054 statistic.value.topFrameLoadedThirdPartyScripts.remove(domain); 1055 statistic.value.subframeUnderTopFrameDomains.remove(domain); 1056 statistic.value.subresourceUnderTopFrameDomains.remove(domain); 1057 statistic.value.subresourceUniqueRedirectsTo.remove(domain); 1058 statistic.value.subresourceUniqueRedirectsFrom.remove(domain); 1059 } 1060 } 1061 1045 1062 void ResourceLoadStatisticsMemoryStore::setPrevalentResource(const RegistrableDomain& domain) 1046 1063 { -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
r259275 r260668 113 113 114 114 void setLastSeen(const RegistrableDomain&, Seconds) override; 115 void removeDataForDomain(const RegistrableDomain&) override; 115 116 116 117 private: -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
r260169 r260668 185 185 virtual void setLastSeen(const RegistrableDomain& primaryDomain, Seconds) = 0; 186 186 187 virtual void removeDataForDomain(const RegistrableDomain&) = 0; 188 187 189 void didCreateNetworkProcess(); 188 190 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r260169 r260668 1156 1156 } 1157 1157 1158 void WebResourceLoadStatisticsStore::domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&& completionHandler) 1159 { 1160 ASSERT(RunLoop::isMain()); 1161 1162 postTask([this, domainID, completionHandler = WTFMove(completionHandler)]() mutable { 1163 if (!m_statisticsStore || !is<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore)) { 1164 completionHandler(false); 1165 return; 1166 } 1167 auto& databaseStore = downcast<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore); 1168 bool domainIDExists = databaseStore.domainIDExistsInDatabase(domainID); 1169 postTaskReply([domainIDExists, completionHandler = WTFMove(completionHandler)]() mutable { 1170 completionHandler(domainIDExists); 1171 }); 1172 }); 1173 } 1174 1158 1175 void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler) 1159 1176 { … … 1284 1301 } 1285 1302 1303 void WebResourceLoadStatisticsStore::removeDataForDomain(RegistrableDomain domain, CompletionHandler<void()>&& completionHandler) 1304 { 1305 ASSERT(RunLoop::isMain()); 1306 postTask([this, domain = WTFMove(domain), completionHandler = WTFMove(completionHandler)]() mutable { 1307 if (m_statisticsStore) 1308 m_statisticsStore->removeDataForDomain(domain); 1309 1310 postTaskReply(WTFMove(completionHandler)); 1311 }); 1312 } 1313 1286 1314 void WebResourceLoadStatisticsStore::deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&& domainsToDeleteAndRestrictWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler) 1287 1315 { -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r260169 r260668 219 219 void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&, CompletionHandler<void()>&&); 220 220 void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&); 221 void removeDataForDomain(const RegistrableDomain, CompletionHandler<void()>&&); 221 222 void deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&); 222 223 void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&); … … 255 256 void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&); 256 257 void clearInMemoryEphemeral(CompletionHandler<void()>&&); 258 void domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&&); 257 259 258 260 void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r260496 r260668 991 991 } 992 992 993 void NetworkProcess::domainIDExistsInDatabase(PAL::SessionID sessionID, int domainID, CompletionHandler<void(bool)>&& completionHandler) 994 { 995 if (auto* networkSession = this->networkSession(sessionID)) { 996 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 997 resourceLoadStatistics->domainIDExistsInDatabase(domainID, WTFMove(completionHandler)); 998 else 999 completionHandler(false); 1000 } else { 1001 ASSERT_NOT_REACHED(); 1002 completionHandler(false); 1003 } 1004 } 1005 993 1006 void NetworkProcess::mergeStatisticForTesting(PAL::SessionID sessionID, const RegistrableDomain& domain, const RegistrableDomain& topFrameDomain1, const RegistrableDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&& completionHandler) 994 1007 { … … 1605 1618 } 1606 1619 1607 void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& originDatas, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CallbackID callbackID)1620 void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& originDatas, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>& registrableDomains, CallbackID callbackID) 1608 1621 { 1609 1622 if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { … … 1679 1692 WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originDatas); 1680 1693 } 1694 1695 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1696 if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) { 1697 if (auto* networkSession = this->networkSession(sessionID)) { 1698 for (auto& domain : registrableDomains) { 1699 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1700 resourceLoadStatistics->removeDataForDomain(domain, [clearTasksHandler = clearTasksHandler.copyRef()] { }); 1701 } 1702 } 1703 } 1704 #endif 1681 1705 } 1682 1706 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r260496 r260668 242 242 void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 243 243 void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); 244 void domainIDExistsInDatabase(PAL::SessionID, int domainID, CompletionHandler<void(bool)>&&); 244 245 void mergeStatisticForTesting(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain& topFrameDomain1, const TopFrameDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&); 245 246 void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); … … 400 401 void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CallbackID); 401 402 void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CallbackID); 402 void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, CallbackID);403 void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, const Vector<RegistrableDomain>&, CallbackID); 403 404 404 405 void clearCachedCredentials(); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r260496 r260668 46 46 FetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, OptionSet<WebKit::WebsiteDataFetchOption> fetchOptions, WebKit::CallbackID callbackID) 47 47 DeleteWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, WallTime modifiedSince, WebKit::CallbackID callbackID) 48 DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, Vector<String> HSTSCacheHostNames, WebKit::CallbackID callbackID)48 DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, Vector<String> HSTSCacheHostNames, Vector<WebCore::RegistrableDomain> registrableDomains, WebKit::CallbackID callbackID) 49 49 50 50 DownloadRequest(PAL::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request, enum:bool Optional<WebKit::NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, String suggestedFilename) … … 105 105 IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubframeUnder) Async 106 106 IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubresourceUnder) Async 107 DomainIDExistsInDatabase(PAL::SessionID sessionID, int domainID) -> (bool exists) Async 107 108 LogFrameNavigation(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain sourceDomain, bool isRedirect, bool isMainFrame, Seconds delayAfterMainFrameDocumentLoad, bool wasPotentiallyInitiatedByUser) 108 109 LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain) -> () Async -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r259275 r260668 67 67 } 68 68 69 void WKWebsiteDataStoreRemoveITPDataForDomain(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreRemoveITPDataForDomainFunction callback) 70 { 71 WebKit::WebsiteDataRecord dataRecord; 72 dataRecord.types.add(WebKit::WebsiteDataType::ResourceLoadStatistics); 73 dataRecord.displayName = WebKit::toImpl(host)->string(); 74 Vector<WebKit::WebsiteDataRecord> dataRecords = { WTFMove(dataRecord) }; 75 76 OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::ResourceLoadStatistics; 77 WebKit::toImpl(dataStoreRef)->removeData(dataTypes, dataRecords, [context, callback] { 78 callback(context); 79 }); 80 } 81 82 void WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(WKWebsiteDataStoreRef dataStoreRef, int domainID, void* context, WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction callback) 83 { 84 #if ENABLE(RESOURCE_LOAD_STATISTICS) 85 WebKit::toImpl(dataStoreRef)->domainIDExistsInDatabase(domainID, [context, callback](bool exists) { 86 callback(exists, context); 87 }); 88 #else 89 callback(false, context); 90 #endif 91 } 92 69 93 void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable) 70 94 { -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r258884 r260668 137 137 WK_EXPORT void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveFetchCacheRemovalFunction callback); 138 138 139 typedef void (*WKWebsiteDataStoreRemoveITPDataForDomainFunction)(void* functionContext); 140 WK_EXPORT void WKWebsiteDataStoreRemoveITPDataForDomain(WKWebsiteDataStoreRef dataStoreRef, WKStringRef origin, void* context, WKWebsiteDataStoreRemoveITPDataForDomainFunction callback); 141 typedef void (*WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction)(bool domainExistsInDatabase, void* functionContext); 142 WK_EXPORT void WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(WKWebsiteDataStoreRef dataStoreRef, int domainID, void* context, WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction callback); 143 139 144 typedef void (*WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback)(void* functionContext); 140 145 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r260658 r260668 199 199 } 200 200 201 void NetworkProcessProxy::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&& completionHandler)201 void NetworkProcessProxy::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>& registrableDomains, CompletionHandler<void()>&& completionHandler) 202 202 { 203 203 ASSERT(canSendMessage()); … … 215 215 }); 216 216 217 send(Messages::NetworkProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, callbackID), 0);217 send(Messages::NetworkProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, callbackID), 0); 218 218 } 219 219 … … 573 573 574 574 sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen), WTFMove(completionHandler)); 575 } 576 577 void NetworkProcessProxy::domainIDExistsInDatabase(PAL::SessionID sessionID, int domainID, CompletionHandler<void(bool)>&& completionHandler) 578 { 579 if (!canSendMessage()) { 580 completionHandler(false); 581 return; 582 } 583 584 sendWithAsyncReply(Messages::NetworkProcess::DomainIDExistsInDatabase(sessionID, domainID), WTFMove(completionHandler)); 575 585 } 576 586 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r260658 r260668 108 108 void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CompletionHandler<void(WebsiteData)>&&); 109 109 void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&& completionHandler); 110 void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&);110 void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 111 111 112 112 void getLocalStorageDetails(PAL::SessionID, CompletionHandler<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&&); … … 131 131 void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); 132 132 void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); 133 void domainIDExistsInDatabase(PAL::SessionID, int domainID, CompletionHandler<void(bool)>&&); 133 134 void mergeStatisticForTesting(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain& topFrameDomain1, const TopFrameDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&); 134 135 void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r259910 r260668 991 991 Vector<String> cookieHostNames; 992 992 Vector<String> HSTSCacheHostNames; 993 Vector<WebCore::RegistrableDomain> registrableDomains; 993 994 for (const auto& dataRecord : dataRecords) { 994 995 for (auto& hostName : dataRecord.cookieHostNames) … … 996 997 for (auto& hostName : dataRecord.HSTSCacheHostNames) 997 998 HSTSCacheHostNames.append(hostName); 999 registrableDomains.append(WebCore::RegistrableDomain::uncheckedCreateFromHost(dataRecord.displayName)); 998 1000 } 999 1001 1000 1002 callbackAggregator->addPendingCallback(); 1001 processPool->networkProcess()->deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, [callbackAggregator, processPool] {1003 processPool->networkProcess()->deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, [callbackAggregator, processPool] { 1002 1004 callbackAggregator->removePendingCallback(); 1003 1005 }); … … 1594 1596 if (auto* process = processPool->networkProcess()) 1595 1597 process->setLastSeen(m_sessionID, WebCore::RegistrableDomain { url }, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1598 } 1599 } 1600 1601 void WebsiteDataStore::domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&& completionHandler) 1602 { 1603 ASSERT(RunLoop::isMain()); 1604 1605 for (auto& processPool : processPools()) { 1606 if (auto* process = processPool->networkProcess()) { 1607 process->domainIDExistsInDatabase(m_sessionID, domainID, WTFMove(completionHandler)); 1608 break; 1609 } 1596 1610 } 1597 1611 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r259520 r260668 168 168 void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&); 169 169 void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); 170 void domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&&); 170 171 void mergeStatisticForTesting(const URL&, const URL& topFrameUrl1, const URL& topFrameUrl2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&); 171 172 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); -
trunk/Tools/ChangeLog
r260662 r260668 1 2020-04-24 Kate Cheney <katherine_cheney@apple.com> 2 3 Removing website data for a domain should delete corresponding ITP entry 4 https://bugs.webkit.org/show_bug.cgi?id=210864 5 <rdar://problem/59473193> 6 7 Reviewed by John Wilander. 8 9 Created 2 new APIs for testing. One to mimic clearing website data 10 for a domain, and one to check if the domain exists in the database 11 after a deletion was requested. 12 13 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 14 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 15 (WTR::TestRunner::doesStatisticsDomainIDExistInDatabase): 16 (WTR::TestRunner::domainIDExistsInDatabase): Deleted. 17 * WebKitTestRunner/InjectedBundle/TestRunner.h: 18 * WebKitTestRunner/TestController.cpp: 19 (WTR::TestController::doesStatisticsDomainIDExistInDatabase): 20 (WTR::TestController::domainIDExistsInDatabase): Deleted. 21 * WebKitTestRunner/TestController.h: 22 * WebKitTestRunner/TestInvocation.cpp: 23 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 24 1 25 2020-04-24 Antoine Quint <graouts@apple.com> 2 26 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r258884 r260668 293 293 294 294 // Resource Load Statistics 295 void clearStatisticsDataForDomain(DOMString domain); 296 boolean doesStatisticsDomainIDExistInDatabase(unsigned long domainID); 295 297 void setStatisticsEnabled(boolean value); 296 298 boolean isStatisticsEphemeral(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r258884 r260668 1416 1416 } 1417 1417 1418 void TestRunner::clearStatisticsDataForDomain(JSStringRef domain) 1419 { 1420 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ClearStatisticsDataForDomain")); 1421 WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithJSString(domain)); 1422 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1423 } 1424 1425 bool TestRunner::doesStatisticsDomainIDExistInDatabase(unsigned domainID) 1426 { 1427 Vector<WKRetainPtr<WKStringRef>> keys; 1428 Vector<WKRetainPtr<WKTypeRef>> values; 1429 1430 keys.append(adoptWK(WKStringCreateWithUTF8CString("DomainID"))); 1431 values.append(adoptWK(WKUInt64Create(domainID))); 1432 1433 Vector<WKStringRef> rawKeys(keys.size()); 1434 Vector<WKTypeRef> rawValues(values.size()); 1435 1436 for (size_t i = 0; i < keys.size(); ++i) { 1437 rawKeys[i] = keys[i].get(); 1438 rawValues[i] = values[i].get(); 1439 } 1440 1441 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("DoesStatisticsDomainIDExistInDatabase")); 1442 WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1443 WKTypeRef returnData = nullptr; 1444 WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData); 1445 ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID()); 1446 return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get()); 1447 } 1448 1418 1449 void TestRunner::setStatisticsEnabled(bool value) 1419 1450 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r258884 r260668 381 381 382 382 // Resource Load Statistics 383 void clearStatisticsDataForDomain(JSStringRef domain); 384 bool doesStatisticsDomainIDExistInDatabase(unsigned domainID); 383 385 void setStatisticsEnabled(bool value); 384 386 bool isStatisticsEphemeral(); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r260356 r260668 3418 3418 } 3419 3419 3420 void TestController::clearStatisticsDataForDomain(WKStringRef domain) 3421 { 3422 ResourceStatisticsCallbackContext context(*this); 3423 3424 WKWebsiteDataStoreRemoveITPDataForDomain(TestController::defaultWebsiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback); 3425 runUntil(context.done, noTimeout); 3426 } 3427 3428 bool TestController::doesStatisticsDomainIDExistInDatabase(unsigned domainID) 3429 { 3430 ResourceStatisticsCallbackContext context(*this); 3431 WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(websiteDataStore(), domainID, &context, resourceStatisticsBooleanResultCallback); 3432 runUntil(context.done, noTimeout); 3433 return context.result; 3434 } 3435 3420 3436 void TestController::setStatisticsEnabled(bool value) 3421 3437 { -
trunk/Tools/WebKitTestRunner/TestController.h
r260169 r260668 215 215 void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; } 216 216 217 void clearStatisticsDataForDomain(WKStringRef domain); 218 bool doesStatisticsDomainIDExistInDatabase(unsigned domainID); 217 219 void setStatisticsEnabled(bool value); 218 220 bool isStatisticsEphemeral(); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r259843 r260668 1289 1289 return result; 1290 1290 } 1291 1292 if (WKStringIsEqualToUTF8CString(messageName, "ClearStatisticsDataForDomain")) { 1293 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 1294 WKStringRef domain = static_cast<WKStringRef>(messageBody); 1295 1296 TestController::singleton().clearStatisticsDataForDomain(domain); 1297 return nullptr; 1298 } 1299 1300 if (WKStringIsEqualToUTF8CString(messageName, "DoesStatisticsDomainIDExistInDatabase")) { 1301 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 1302 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 1303 WKRetainPtr<WKStringRef> domainIDKey = adoptWK(WKStringCreateWithUTF8CString("DomainID")); 1304 WKUInt64Ref domainID = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, domainIDKey.get())); 1305 bool domainIDExists = TestController::singleton().doesStatisticsDomainIDExistInDatabase(WKUInt64GetValue(domainID)); 1306 WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(domainIDExists)); 1307 return result; 1308 } 1291 1309 1292 1310 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
Note: See TracChangeset
for help on using the changeset viewer.