Changeset 251213 in webkit
- Timestamp:
- Oct 16, 2019 3:38:55 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251189 r251213 1 2019-10-16 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=203017 5 <rdar://problem/56262708> 6 7 Reviewed by Alex Christensen. 8 9 * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database-expected.txt: Added. 10 * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html: Added. 11 * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-expected.txt: Added. 12 * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html: Added. 13 1 14 2019-10-16 Russell Epstein <repstein@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r251211 r251213 1 2019-10-16 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=203017 5 <rdar://problem/56262708> 6 7 Reviewed by Alex Christensen. 8 9 NetworkStorageSession::shouldBlockCookies() now checks if the first-party website has 10 received user interaction and if not, blocks all third-party cookies, regardless of the 11 status of those third-party domains (prevalent or not). 12 13 Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching. 14 15 Tests: http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html 16 http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html 17 18 * page/RuntimeEnabledFeatures.h: 19 (WebCore::RuntimeEnabledFeatures::setIsITPSessionSwitchingEnabled): Deleted. 20 (WebCore::RuntimeEnabledFeatures::isITPSessionSwitchingEnabled const): Deleted. 21 * page/Settings.yaml: 22 * platform/network/NetworkStorageSession.cpp: 23 (WebCore::NetworkStorageSession::hasHadUserInteractionAsFirstParty const): 24 (WebCore::NetworkStorageSession::shouldBlockCookies const): 25 (WebCore::NetworkStorageSession::setDomainsWithUserInteractionAsFirstParty): 26 * platform/network/NetworkStorageSession.h: 27 (WebCore::NetworkStorageSession::setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled): 28 1 29 2019-10-16 Zalan Bujtas <zalan@apple.com> 2 30 -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r250969 r251213 147 147 void setIsITPDatabaseEnabled(bool isEnabled) { m_isITPDatabaseEnabled = isEnabled; } 148 148 bool isITPDatabaseEnabled() const { return m_isITPDatabaseEnabled; } 149 150 void setIsITPSessionSwitchingEnabled(bool isEnabled) { m_isITPSessionSwitchingEnabled = isEnabled; }151 bool isITPSessionSwitchingEnabled() const { return m_isITPSessionSwitchingEnabled; }152 149 153 150 void setRestrictedHTTPResponseAccess(bool isEnabled) { m_isRestrictedHTTPResponseAccess = isEnabled; } … … 421 418 bool m_ariaReflectionEnabled { true }; 422 419 bool m_itpDebugMode { false }; 423 bool m_isITPSessionSwitchingEnabled { true };424 420 bool m_isRestrictedHTTPResponseAccess { true }; 425 421 bool m_crossOriginResourcePolicyEnabled { true }; -
trunk/Source/WebCore/page/Settings.yaml
r251204 r251213 870 870 inspectorOverride: true 871 871 872 is ITPSessionSwitchingEnabled:873 initial: true872 isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled: 873 initial: false 874 874 875 875 isLoggedInAPIEnabled: -
trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp
r250287 r251213 79 79 } 80 80 81 bool NetworkStorageSession::hasHadUserInteractionAsFirstParty(const RegistrableDomain& registrableDomain) const 82 { 83 if (registrableDomain.isEmpty()) 84 return false; 85 86 return m_registrableDomainsWithUserInteractionAsFirstParty.contains(registrableDomain); 87 } 88 81 89 bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const 82 90 { … … 99 107 if (pageID && hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID.value())) 100 108 return false; 109 110 if (m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled && !hasHadUserInteractionAsFirstParty(firstPartyDomain)) 111 return true; 101 112 102 113 return shouldBlockThirdPartyCookies(resourceDomain); … … 126 137 m_registrableDomainsToBlockButKeepCookiesFor.clear(); 127 138 m_registrableDomainsToBlockButKeepCookiesFor.add(domains.begin(), domains.end()); 139 } 140 141 void NetworkStorageSession::setDomainsWithUserInteractionAsFirstParty(const Vector<RegistrableDomain>& domains) 142 { 143 m_registrableDomainsWithUserInteractionAsFirstParty.clear(); 144 m_registrableDomainsWithUserInteractionAsFirstParty.add(domains.begin(), domains.end()); 128 145 } 129 146 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r250589 r251213 148 148 WEBCORE_EXPORT bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const; 149 149 WEBCORE_EXPORT bool shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain&) const; 150 WEBCORE_EXPORT bool hasHadUserInteractionAsFirstParty(const RegistrableDomain&) const; 150 151 WEBCORE_EXPORT void setPrevalentDomainsToBlockAndDeleteCookiesFor(const Vector<RegistrableDomain>&); 151 152 WEBCORE_EXPORT void setPrevalentDomainsToBlockButKeepCookiesFor(const Vector<RegistrableDomain>&); 153 WEBCORE_EXPORT void setDomainsWithUserInteractionAsFirstParty(const Vector<RegistrableDomain>&); 152 154 WEBCORE_EXPORT void setAgeCapForClientSideCookies(Optional<Seconds>); 153 155 WEBCORE_EXPORT void removePrevalentDomains(const Vector<RegistrableDomain>& domains); … … 163 165 WEBCORE_EXPORT void didCommitCrossSiteLoadWithDataTransferFromPrevalentResource(const RegistrableDomain& toDomain, PageIdentifier); 164 166 WEBCORE_EXPORT void resetCrossSiteLoadsWithLinkDecorationForTesting(); 167 void setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(bool enabled) { m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = enabled; } 165 168 #endif 166 169 … … 189 192 HashSet<RegistrableDomain> m_registrableDomainsToBlockAndDeleteCookiesFor; 190 193 HashSet<RegistrableDomain> m_registrableDomainsToBlockButKeepCookiesFor; 194 HashSet<RegistrableDomain> m_registrableDomainsWithUserInteractionAsFirstParty; 191 195 HashMap<PageIdentifier, HashMap<FrameIdentifier, RegistrableDomain>> m_framesGrantedStorageAccess; 192 196 HashMap<PageIdentifier, HashMap<RegistrableDomain, RegistrableDomain>> m_pagesGrantedStorageAccess; … … 196 200 HashMap<WebCore::PageIdentifier, RegistrableDomain> m_navigatedToWithLinkDecorationByPrevalentResource; 197 201 bool m_navigationWithLinkDecorationTestMode = false; 202 bool m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = false; 198 203 #endif 199 204 -
trunk/Source/WebKit/ChangeLog
r251212 r251213 1 2019-10-16 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=203017 5 <rdar://problem/56262708> 6 7 Reviewed by Alex Christensen. 8 9 This enhancement is off by default and controlled by an internal feature flag. 10 11 The functional change is in WebCore::NetworkStorageSession::shouldBlockCookies() which is 12 called from: 13 - NetworkDataTaskCocoa::NetworkDataTaskCocoa() 14 - NetworkDataTaskCocoa::willPerformHTTPRedirection 15 16 shouldBlockCookies() now checks if the first-party website has received user interaction 17 and if not, blocks all third-party cookies, regardless of the status of those third-party 18 domains (prevalent or not). 19 20 The changes to ResourceLoadStatisticsDatabaseStore and ResourceLoadStatisticsMemoryStore 21 are about communicating which domains have received user interaction (prevalent or not) 22 to the network storage session so that it can enforce the new restriction. 23 24 The C API change and piping through the WebsiteDataStore is test infrastructure. 25 26 Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching. 27 28 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: 29 (WebKit::CompletionHandler<void): 30 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: 31 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 32 (WebKit::ResourceLoadStatisticsMemoryStore::clear): 33 (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): 34 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 35 (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler): 36 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 37 (WebKit::RegistrableDomainsToBlockCookiesFor::isolatedCopy const): 38 * NetworkProcess/NetworkProcess.cpp: 39 (WebKit::NetworkProcess::initializeNetworkProcess): 40 (WebKit::NetworkProcess::setShouldBlockThirdPartyCookiesForTesting): 41 * NetworkProcess/NetworkProcess.messages.in: 42 * NetworkProcess/NetworkSession.cpp: 43 (WebKit::NetworkSession::NetworkSession): 44 * NetworkProcess/NetworkSession.h: 45 (WebKit::NetworkSession::setResourceLoadStatisticsLogTestingEvent): 46 (WebKit::NetworkSession::shouldIsolateSessionsForPrevalentTopFrames const): Deleted. 47 * NetworkProcess/NetworkSessionCreationParameters.cpp: 48 (WebKit::NetworkSessionCreationParameters::encode const): 49 (WebKit::NetworkSessionCreationParameters::decode): 50 * NetworkProcess/NetworkSessionCreationParameters.h: 51 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 52 (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): 53 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 54 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 55 * Shared/WebPreferences.yaml: 56 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 57 (WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting): 58 (WKWebsiteDataStoreStatisticsResetToConsistentState): 59 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 60 * UIProcess/Network/NetworkProcessProxy.cpp: 61 (WebKit::NetworkProcessProxy::setShouldBlockThirdPartyCookiesForTesting): 62 * UIProcess/Network/NetworkProcessProxy.h: 63 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 64 (WebKit::WebsiteDataStore::parameters): 65 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 66 (WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting): 67 * UIProcess/WebsiteData/WebsiteDataStore.h: 68 1 69 2019-10-16 Kate Cheney <katherine_cheney@apple.com> 2 70 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
r251016 r251213 1681 1681 1682 1682 auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode(); 1683 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } };1683 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { }, { } }; 1684 1684 updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 1685 1685 } … … 1753 1753 } 1754 1754 1755 Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::domainsWithUserInteractionAsFirstParty() const 1756 { 1757 ASSERT(!RunLoop::isMain()); 1758 1759 Vector<RegistrableDomain> results; 1760 SQLiteStatement statement(m_database, "SELECT registrableDomain FROM ObservedDomains WHERE hadUserInteraction = 1"_s); 1761 if (statement.prepare() != SQLITE_OK) 1762 return results; 1763 1764 while (statement.step() == SQLITE_ROW) 1765 results.append(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(statement.getColumnText(0))); 1766 1767 return results; 1768 } 1769 1755 1770 void ResourceLoadStatisticsDatabaseStore::updateCookieBlocking(CompletionHandler<void()>&& completionHandler) 1756 1771 { … … 1759 1774 auto domainsToBlockAndDeleteCookiesFor = this->domainsToBlockAndDeleteCookiesFor(); 1760 1775 auto domainsToBlockButKeepCookiesFor = this->domainsToBlockButKeepCookiesFor(); 1761 1762 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty()) { 1776 auto domainsWithUserInteractionAsFirstParty = this->domainsWithUserInteractionAsFirstParty(); 1777 1778 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && domainsWithUserInteractionAsFirstParty.isEmpty()) { 1763 1779 completionHandler(); 1764 1780 return; 1765 1781 } 1766 1782 1767 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor };1783 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor, domainsWithUserInteractionAsFirstParty }; 1768 1784 1769 1785 if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty()) -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
r250866 r251213 156 156 Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor() const; 157 157 Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor() const; 158 Vector<RegistrableDomain> domainsWithUserInteractionAsFirstParty() const; 158 159 159 160 struct PrevalentDomainData { -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r250621 r251213 698 698 699 699 auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode(); 700 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } };700 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { }, { } }; 701 701 updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 702 702 } … … 736 736 Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor; 737 737 Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor; 738 Vector<RegistrableDomain> domainsWithUserInteractionAsFirstParty; 738 739 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 739 if ( resourceStatistic.isPrevalentResource) {740 if ( hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long))741 domainsToBlockButKeepCookiesFor.append(resourceStatistic.registrableDomain );742 else743 domainsToBlockAndDeleteCookiesFor.append(resourceStatistic.registrableDomain);744 }745 } 746 747 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && !debugModeEnabled()) {740 if (hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long)) { 741 if (resourceStatistic.isPrevalentResource) 742 domainsToBlockButKeepCookiesFor.append(resourceStatistic.registrableDomain.isolatedCopy()); 743 domainsWithUserInteractionAsFirstParty.append(resourceStatistic.registrableDomain); 744 } else if (resourceStatistic.isPrevalentResource) 745 domainsToBlockAndDeleteCookiesFor.append(resourceStatistic.registrableDomain); 746 } 747 748 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && domainsWithUserInteractionAsFirstParty.isEmpty() && !debugModeEnabled()) { 748 749 completionHandler(); 749 750 return; 750 751 } 751 752 752 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor };753 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor, domainsWithUserInteractionAsFirstParty }; 753 754 754 755 if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty()) -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r251176 r251213 966 966 storageSession->setPrevalentDomainsToBlockAndDeleteCookiesFor(domainsToBlock.domainsToBlockAndDeleteCookiesFor); 967 967 storageSession->setPrevalentDomainsToBlockButKeepCookiesFor(domainsToBlock.domainsToBlockButKeepCookiesFor); 968 storageSession->setDomainsWithUserInteractionAsFirstParty(domainsToBlock.domainsWithUserInteractionAsFirstParty); 968 969 } 969 970 } -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r250866 r251213 66 66 enum class ShouldIncludeLocalhost : bool { No, Yes }; 67 67 enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes }; 68 enum class EnableResourceLoadStatisticsNSURLSessionSwitching : bool { No, Yes };69 68 enum class WebsiteDataToRemove : uint8_t { 70 69 All, … … 75 74 Vector<WebCore::RegistrableDomain> domainsToBlockAndDeleteCookiesFor; 76 75 Vector<WebCore::RegistrableDomain> domainsToBlockButKeepCookiesFor; 77 RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy() }; } 76 Vector<WebCore::RegistrableDomain> domainsWithUserInteractionAsFirstParty; 77 RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy(), domainsWithUserInteractionAsFirstParty.isolatedCopy() }; } 78 78 }; 79 79 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r251212 r251213 1259 1259 completionHandler(); 1260 1260 } 1261 1262 void NetworkProcess::setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled, CompletionHandler<void()>&& completionHandler) 1263 { 1264 if (auto* networkStorageSession = storageSession(sessionID)) 1265 networkStorageSession->setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(enabled); 1266 else 1267 ASSERT_NOT_REACHED(); 1268 completionHandler(); 1269 } 1261 1270 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 1262 1271 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r251212 r251213 267 267 bool isITPDatabaseEnabled() const { return m_isITPDatabaseEnabled; } 268 268 void setShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&); 269 void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, bool, CompletionHandler<void()>&&); 269 270 #endif 270 271 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r251212 r251213 138 138 HasIsolatedSession(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) -> (bool hasIsolatedSession) Async 139 139 SetShouldDowngradeReferrerForTesting(bool enabled) -> () Async 140 SetShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled) -> () Async 140 141 #endif 141 142 -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r250866 r251213 94 94 bool enableResourceLoadStatisticsLogTestingEvent() const { return m_enableResourceLoadStatisticsLogTestingEvent; } 95 95 void setResourceLoadStatisticsLogTestingEvent(bool log) { m_enableResourceLoadStatisticsLogTestingEvent = log; } 96 bool shouldIsolateSessionsForPrevalentTopFrames() const { return m_enableResourceLoadStatisticsNSURLSessionSwitching == EnableResourceLoadStatisticsNSURLSessionSwitching::Yes; }97 96 virtual bool hasIsolatedSession(const WebCore::RegistrableDomain) const { return false; } 98 97 virtual void clearIsolatedSessions() { } 99 98 void setShouldDowngradeReferrerForTesting(bool); 100 99 bool shouldDowngradeReferrer() const; 100 void setShouldBlockThirdPartyCookiesForTesting(bool); 101 101 #endif 102 102 void storeAdClickAttribution(WebCore::AdClickAttribution&&); … … 141 141 EnableResourceLoadStatisticsDebugMode m_enableResourceLoadStatisticsDebugMode { EnableResourceLoadStatisticsDebugMode::No }; 142 142 WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource; 143 EnableResourceLoadStatisticsNSURLSessionSwitching m_enableResourceLoadStatisticsNSURLSessionSwitching { EnableResourceLoadStatisticsNSURLSessionSwitching::No };144 143 bool m_enableResourceLoadStatisticsLogTestingEvent; 145 144 bool m_downgradeReferrer { true }; -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r250677 r251213 69 69 encoder << enableResourceLoadStatisticsDebugMode; 70 70 encoder << resourceLoadStatisticsManualPrevalentResource; 71 encoder << enable ResourceLoadStatisticsNSURLSessionSwitching;71 encoder << enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction; 72 72 73 73 encoder << networkCacheDirectory << networkCacheDirectoryExtensionHandle; … … 200 200 return WTF::nullopt; 201 201 202 Optional<bool> enable ResourceLoadStatisticsNSURLSessionSwitching;203 decoder >> enable ResourceLoadStatisticsNSURLSessionSwitching;204 if (!enable ResourceLoadStatisticsNSURLSessionSwitching)202 Optional<bool> enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction; 203 decoder >> enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction; 204 if (!enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction) 205 205 return WTF::nullopt; 206 206 … … 283 283 , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics) 284 284 , WTFMove(*enableResourceLoadStatisticsDebugMode) 285 , WTFMove(*enable ResourceLoadStatisticsNSURLSessionSwitching)285 , WTFMove(*enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction) 286 286 , WTFMove(*deviceManagementRestrictionsEnabled) 287 287 , WTFMove(*allLoadsBlockedByDeviceManagementRestrictionsForTesting) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r250677 r251213 86 86 bool shouldIncludeLocalhostInResourceLoadStatistics { true }; 87 87 bool enableResourceLoadStatisticsDebugMode { false }; 88 bool enable ResourceLoadStatisticsNSURLSessionSwitching { true };88 bool enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction { false }; 89 89 bool deviceManagementRestrictionsEnabled { false }; 90 90 bool allLoadsBlockedByDeviceManagementRestrictionsForTesting { false }; -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r250413 r251213 214 214 if (!shouldBlockCookies) 215 215 shouldBlockCookies = networkStorageSession->shouldBlockCookies(request, frameID, pageID); 216 needsIsolatedSession = session.shouldIsolateSessionsForPrevalentTopFrames() &&networkStorageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty);216 needsIsolatedSession = networkStorageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty); 217 217 } 218 218 #endif -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r251021 r251213 1110 1110 m_enableResourceLoadStatisticsDebugMode = parameters.enableResourceLoadStatisticsDebugMode ? EnableResourceLoadStatisticsDebugMode::Yes : EnableResourceLoadStatisticsDebugMode::No; 1111 1111 m_resourceLoadStatisticsManualPrevalentResource = parameters.resourceLoadStatisticsManualPrevalentResource; 1112 m_enableResourceLoadStatisticsNSURLSessionSwitching = parameters.enableResourceLoadStatisticsNSURLSessionSwitching ? EnableResourceLoadStatisticsNSURLSessionSwitching::Yes : EnableResourceLoadStatisticsNSURLSessionSwitching::No;1112 storageSession->setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(parameters.enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction); 1113 1113 setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics); 1114 1114 #endif -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r251160 r251213 1766 1766 category: experimental 1767 1767 1768 IsITPSessionSwitchingEnabled: 1769 type: bool 1770 defaultValue: true 1771 humanReadableName: "ITP Session Switching" 1772 humanReadableDescription: "Enable session switching for domains classified by ITP" 1773 webcoreBinding: RuntimeEnabledFeatures 1768 IsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled: 1769 type: bool 1770 defaultValue: false 1771 humanReadableName: "Block 3rd-Party Cookies On Sites Without Interaction (ITP)" 1772 humanReadableDescription: "Block all third-party cookies on websites without user interaction" 1774 1773 category: internal 1775 1774 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r251212 r251213 539 539 } 540 540 541 void WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction completionHandler) 542 { 543 #if ENABLE(RESOURCE_LOAD_STATISTICS) 544 WebKit::toImpl(dataStoreRef)->setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(enabled, [context, completionHandler] { 545 completionHandler(context); 546 }); 547 #else 548 completionHandler(context); 549 #endif 550 } 551 541 552 void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler) 542 553 { … … 551 562 store.resetCrossSiteLoadsWithLinkDecorationForTesting([callbackAggregator = callbackAggregator.copyRef()] { }); 552 563 store.setResourceLoadStatisticsShouldDowngradeReferrerForTesting(true, [callbackAggregator = callbackAggregator.copyRef()] { }); 564 store.setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(false, [callbackAggregator = callbackAggregator.copyRef()] { }); 553 565 store.resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { }); 554 566 store.scheduleClearInMemoryAndPersistent(WebKit::ShouldGrandfatherStatistics::No, [callbackAggregator = callbackAggregator.copyRef()] { }); -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r251212 r251213 118 118 typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTestingFunction)(void* functionContext); 119 119 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTestingFunction completionHandler); 120 typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction)(void* functionContext); 121 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction completionHandler); 120 122 typedef void (*WKWebsiteDataStoreStatisticsResetToConsistentStateFunction)(void* functionContext); 121 123 WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r251212 r251213 1055 1055 sendWithAsyncReply(Messages::NetworkProcess::SetShouldDowngradeReferrerForTesting(enabled), WTFMove(completionHandler)); 1056 1056 } 1057 1058 void NetworkProcessProxy::setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled, CompletionHandler<void()>&& completionHandler) 1059 { 1060 if (!canSendMessage()) { 1061 completionHandler(); 1062 return; 1063 } 1064 1065 sendWithAsyncReply(Messages::NetworkProcess::SetShouldBlockThirdPartyCookiesForTesting(sessionID, enabled), WTFMove(completionHandler)); 1066 } 1057 1067 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 1058 1068 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r251212 r251213 156 156 void hasIsolatedSession(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 157 157 void setShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&); 158 void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, bool, CompletionHandler<void()>&&); 158 159 #endif 159 160 -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r251108 r251213 30 30 #import "SandboxUtilities.h" 31 31 #import "StorageManager.h" 32 #import "WebPreferencesKeys.h" 32 33 #import "WebResourceLoadStatisticsStore.h" 33 34 #import "WebsiteDataStoreParameters.h" … … 69 70 bool shouldLogCookieInformation = false; 70 71 bool enableResourceLoadStatisticsDebugMode = false; 71 bool enableResourceLoadStatisticsNSURLSessionSwitching = WebCore::RuntimeEnabledFeatures::sharedFeatures().isITPSessionSwitchingEnabled(); 72 bool enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction = false; 73 bool enableLegacyTLS = [defaults boolForKey:@"WebKitEnableLegacyTLS"]; 72 74 WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { }; 73 bool enableLegacyTLS = [defaults boolForKey:@"WebKitEnableLegacyTLS"];74 75 #if ENABLE(RESOURCE_LOAD_STATISTICS) 75 76 enableResourceLoadStatisticsDebugMode = [defaults boolForKey:@"ITPDebugMode"]; 77 enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction = [defaults boolForKey:[NSString stringWithFormat:@"InternalDebug%@", WebPreferencesKey::isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabledKey().createCFString().get()]]; 76 78 auto* manualPrevalentResource = [defaults stringForKey:@"ITPManualPrevalentResource"]; 77 79 if (manualPrevalentResource) { … … 137 139 shouldIncludeLocalhostInResourceLoadStatistics, 138 140 enableResourceLoadStatisticsDebugMode, 139 enable ResourceLoadStatisticsNSURLSessionSwitching,141 enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction, 140 142 m_configuration->deviceManagementRestrictionsEnabled(), 141 143 m_configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting(), -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r251212 r251213 1783 1783 ASSERT(!completionHandler); 1784 1784 } 1785 1786 void WebsiteDataStore::setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(bool enabled, CompletionHandler<void()>&& completionHandler) 1787 { 1788 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1789 1790 for (auto& processPool : processPools()) { 1791 if (auto* networkProcess = processPool->networkProcess()) { 1792 networkProcess->setShouldBlockThirdPartyCookiesForTesting(m_sessionID, enabled, [callbackAggregator = callbackAggregator.copyRef()] { }); 1793 ASSERT(processPools().size() == 1); 1794 break; 1795 } 1796 } 1797 ASSERT(!completionHandler); 1798 } 1785 1799 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 1786 1800 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r251212 r251213 193 193 void hasIsolatedSessionForTesting(const URL&, CompletionHandler<void(bool)>&&) const; 194 194 void setResourceLoadStatisticsShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&); 195 void setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(bool, CompletionHandler<void()>&&); 195 196 #endif 196 197 void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&); -
trunk/Tools/ChangeLog
r251212 r251213 1 2019-10-16 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=203017 5 <rdar://problem/56262708> 6 7 Reviewed by Alex Christensen. 8 9 These changes are test infrastructure to be able to toggle the function 10 through testRunner.setStatisticsShouldBlockThirdPartyCookies(). 11 12 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 13 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 14 (WTR::InjectedBundle::didReceiveMessageToPage): 15 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 16 (WTR::TestRunner::setStatisticsShouldBlockThirdPartyCookies): 17 (WTR::TestRunner::statisticsCallDidSetShouldBlockThirdPartyCookiesCallback): 18 * WebKitTestRunner/InjectedBundle/TestRunner.h: 19 * WebKitTestRunner/TestController.cpp: 20 (WTR::TestController::setStatisticsShouldBlockThirdPartyCookies): 21 * WebKitTestRunner/TestController.h: 22 * WebKitTestRunner/TestInvocation.cpp: 23 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 24 (WTR::TestInvocation::didSetShouldBlockThirdPartyCookies): 25 * WebKitTestRunner/TestInvocation.h: 26 1 27 2019-10-16 Kate Cheney <katherine_cheney@apple.com> 2 28 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r251067 r251213 342 342 boolean hasStatisticsIsolatedSession(DOMString hostName); 343 343 void setStatisticsShouldDowngradeReferrer(boolean value, object callback); 344 void setStatisticsShouldBlockThirdPartyCookies(boolean value, object callback); 344 345 345 346 // Injected bundle form client. -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r251160 r251213 333 333 } 334 334 335 if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetShouldBlockThirdPartyCookies")) { 336 m_testRunner->statisticsCallDidSetShouldBlockThirdPartyCookiesCallback(); 337 return; 338 } 339 335 340 if (WKStringIsEqualToUTF8CString(messageName, "CallDidResetStatisticsToConsistentState")) { 336 341 m_testRunner->statisticsCallDidResetToConsistentStateCallback(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r251160 r251213 744 744 StatisticsDidSetBlockCookiesForHostCallbackID, 745 745 StatisticsDidSetShouldDowngradeReferrerCallbackID, 746 StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID, 746 747 AllStorageAccessEntriesCallbackID, 747 748 DidRemoveAllSessionCredentialsCallbackID, … … 2207 2208 { 2208 2209 callTestRunnerCallback(StatisticsDidSetShouldDowngradeReferrerCallbackID); 2210 } 2211 2212 void TestRunner::setStatisticsShouldBlockThirdPartyCookies(bool value, JSValueRef completionHandler) 2213 { 2214 if (m_hasSetBlockThirdPartyCookiesCallback) 2215 return; 2216 2217 cacheTestRunnerCallback(StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID, completionHandler); 2218 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsShouldBlockThirdPartyCookies")); 2219 WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value)); 2220 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 2221 m_hasSetBlockThirdPartyCookiesCallback = true; 2222 } 2223 2224 void TestRunner::statisticsCallDidSetShouldBlockThirdPartyCookiesCallback() 2225 { 2226 callTestRunnerCallback(StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID); 2209 2227 } 2210 2228 -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r251160 r251213 441 441 void setStatisticsShouldDowngradeReferrer(bool, JSValueRef callback); 442 442 void statisticsCallDidSetShouldDowngradeReferrerCallback(); 443 void setStatisticsShouldBlockThirdPartyCookies(bool, JSValueRef callback); 444 void statisticsCallDidSetShouldBlockThirdPartyCookiesCallback(); 443 445 void statisticsResetToConsistentState(JSValueRef completionHandler); 444 446 void statisticsCallDidResetToConsistentStateCallback(); … … 574 576 bool m_dumpAllHTTPRedirectedResponseHeaders { false }; 575 577 bool m_hasSetDowngradeReferrerCallback { false }; 578 bool m_hasSetBlockThirdPartyCookiesCallback { false }; 576 579 }; 577 580 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r251212 r251213 3556 3556 } 3557 3557 3558 void TestController::setStatisticsShouldBlockThirdPartyCookies(bool value) 3559 { 3560 ResourceStatisticsCallbackContext context(*this); 3561 WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(TestController::websiteDataStore(), value, &context, resourceStatisticsVoidResultCallback); 3562 runUntil(context.done, noTimeout); 3563 m_currentInvocation->didSetShouldBlockThirdPartyCookies(); 3564 } 3565 3558 3566 void TestController::statisticsResetToConsistentState() 3559 3567 { -
trunk/Tools/WebKitTestRunner/TestController.h
r250940 r251213 253 253 bool hasStatisticsIsolatedSession(WKStringRef hostName); 254 254 void setStatisticsShouldDowngradeReferrer(bool value); 255 void setStatisticsShouldBlockThirdPartyCookies(bool value); 255 256 void statisticsResetToConsistentState(); 256 257 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r251067 r251213 1543 1543 } 1544 1544 1545 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsShouldBlockThirdPartyCookies")) { 1546 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); 1547 WKBooleanRef value = static_cast<WKBooleanRef>(messageBody); 1548 TestController::singleton().setStatisticsShouldBlockThirdPartyCookies(WKBooleanGetValue(value)); 1549 return nullptr; 1550 } 1551 1545 1552 if (WKStringIsEqualToUTF8CString(messageName, "RemoveAllSessionCredentials")) { 1546 1553 TestController::singleton().removeAllSessionCredentials(); … … 1826 1833 } 1827 1834 1835 void TestInvocation::didSetShouldBlockThirdPartyCookies() 1836 { 1837 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetShouldBlockThirdPartyCookies")); 1838 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), nullptr); 1839 } 1840 1828 1841 void TestInvocation::didResetStatisticsToConsistentState() 1829 1842 { -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r250621 r251213 75 75 void didClearStatisticsThroughWebsiteDataRemoval(); 76 76 void didSetShouldDowngradeReferrer(); 77 void didSetShouldBlockThirdPartyCookies(); 77 78 void didResetStatisticsToConsistentState(); 78 79 void didSetBlockCookiesForHost();
Note: See TracChangeset
for help on using the changeset viewer.