Changeset 248640 in webkit
- Timestamp:
- Aug 13, 2019 3:34:29 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248639 r248640 1 2019-08-13 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Switch NSURLSession on top navigation to prevalent resource with user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=200642 5 <rdar://problem/53962073> 6 7 Reviewed by Alex Christensen. 8 9 * http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction-expected.txt: Added. 10 * http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.html: Added. 11 * http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt: Added. 12 * http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.html: Added. 13 1 14 2019-08-13 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r248635 r248640 1 2019-08-13 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Switch NSURLSession on top navigation to prevalent resource with user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=200642 5 <rdar://problem/53962073> 6 7 Reviewed by Alex Christensen. 8 9 Tests: http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.html 10 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.html 11 12 This patch splits m_registrableDomainsToBlockCookieFor in WebCore:NetworkStorageSession into: 13 - m_registrableDomainsToBlockAndDeleteCookiesFor 14 - m_registrableDomainsToBlockButKeepCookiesFor 15 ... to support different network load policies based on this distinction. 16 17 * page/RuntimeEnabledFeatures.h: 18 (WebCore::RuntimeEnabledFeatures::setITPSessionSwitchingEnabled): 19 (WebCore::RuntimeEnabledFeatures::itpSessionSwitchingEnabled const): 20 * page/Settings.yaml: 21 * platform/network/NetworkStorageSession.cpp: 22 (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const): 23 (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor const): 24 (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockAndDeleteCookiesFor): 25 (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockButKeepCookiesFor): 26 (WebCore::NetworkStorageSession::removePrevalentDomains): 27 (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor): Deleted. 28 * platform/network/NetworkStorageSession.h: 29 1 30 2019-08-13 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r248409 r248640 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; } 149 152 150 153 void setRestrictedHTTPResponseAccess(bool isEnabled) { m_isRestrictedHTTPResponseAccess = isEnabled; } … … 411 414 bool m_ariaReflectionEnabled { true }; 412 415 bool m_itpDebugMode { false }; 416 bool m_isITPSessionSwitchingEnabled { true }; 413 417 bool m_isRestrictedHTTPResponseAccess { true }; 414 418 bool m_crossOriginResourcePolicyEnabled { true }; -
trunk/Source/WebCore/page/Settings.yaml
r247530 r248640 862 862 inspectorOverride: true 863 863 864 isITPSessionSwitchingEnabled: 865 initial: true 866 864 867 # Deprecated 865 868 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp
r245796 r248640 64 64 return false; 65 65 66 return m_registrableDomainsToBlockCookieFor.contains(registrableDomain); 66 ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain))); 67 68 return m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) 69 || m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain); 70 } 71 72 bool NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain& registrableDomain) const 73 { 74 if (registrableDomain.isEmpty()) 75 return false; 76 77 ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain))); 78 79 return m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain); 67 80 } 68 81 … … 104 117 } 105 118 106 void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<RegistrableDomain>& domains) 107 { 108 m_registrableDomainsToBlockCookieFor.clear(); 109 m_registrableDomainsToBlockCookieFor.add(domains.begin(), domains.end()); 119 void NetworkStorageSession::setPrevalentDomainsToBlockAndDeleteCookiesFor(const Vector<RegistrableDomain>& domains) 120 { 121 m_registrableDomainsToBlockAndDeleteCookiesFor.clear(); 122 m_registrableDomainsToBlockAndDeleteCookiesFor.add(domains.begin(), domains.end()); 123 } 124 125 void NetworkStorageSession::setPrevalentDomainsToBlockButKeepCookiesFor(const Vector<RegistrableDomain>& domains) 126 { 127 m_registrableDomainsToBlockButKeepCookiesFor.clear(); 128 m_registrableDomainsToBlockButKeepCookiesFor.add(domains.begin(), domains.end()); 110 129 } 111 130 112 131 void NetworkStorageSession::removePrevalentDomains(const Vector<RegistrableDomain>& domains) 113 132 { 114 for (auto& domain : domains) 115 m_registrableDomainsToBlockCookieFor.remove(domain); 133 for (auto& domain : domains) { 134 m_registrableDomainsToBlockAndDeleteCookiesFor.remove(domain); 135 m_registrableDomainsToBlockButKeepCookiesFor.remove(domain); 136 } 116 137 } 117 138 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r248010 r248640 144 144 WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<uint64_t> frameID, Optional<PageIdentifier>) const; 145 145 WEBCORE_EXPORT bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const; 146 WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<RegistrableDomain>&); 146 WEBCORE_EXPORT bool shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain&) const; 147 WEBCORE_EXPORT void setPrevalentDomainsToBlockAndDeleteCookiesFor(const Vector<RegistrableDomain>&); 148 WEBCORE_EXPORT void setPrevalentDomainsToBlockButKeepCookiesFor(const Vector<RegistrableDomain>&); 147 149 WEBCORE_EXPORT void setAgeCapForClientSideCookies(Optional<Seconds>); 148 150 WEBCORE_EXPORT void removePrevalentDomains(const Vector<RegistrableDomain>& domains); … … 182 184 #if ENABLE(RESOURCE_LOAD_STATISTICS) 183 185 Optional<Seconds> clientSideCookieCap(const RegistrableDomain& firstParty, Optional<PageIdentifier>) const; 184 HashSet<RegistrableDomain> m_registrableDomainsToBlockCookieFor; 186 HashSet<RegistrableDomain> m_registrableDomainsToBlockAndDeleteCookiesFor; 187 HashSet<RegistrableDomain> m_registrableDomainsToBlockButKeepCookiesFor; 185 188 HashMap<PageIdentifier, HashMap<uint64_t, RegistrableDomain, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>> m_framesGrantedStorageAccess; 186 189 HashMap<PageIdentifier, HashMap<RegistrableDomain, RegistrableDomain>> m_pagesGrantedStorageAccess; -
trunk/Source/WebKit/ChangeLog
r248634 r248640 1 2019-08-13 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Switch NSURLSession on top navigation to prevalent resource with user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=200642 5 <rdar://problem/53962073> 6 7 Reviewed by Alex Christensen. 8 9 Since prevalent resources with user interaction get to keep their cookies and website 10 data, we should use a different NSURLSessions for when they are first-party websites 11 and have access to that data. This patch achieves that. 12 13 The WebKit::NetworkDataTaskCocoa constructor now checks with the network storage session 14 if the first party for this load should be isolated. The category for which this is true 15 is checked in the new function 16 WebCore:NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor() 17 which in turn is backed by a new split of m_registrableDomainsToBlockCookieFor into: 18 - m_registrableDomainsToBlockAndDeleteCookiesFor 19 - m_registrableDomainsToBlockButKeepCookiesFor 20 ... in WebCore:NetworkStorageSession. 21 22 Non-isolated sessions are now picked up through the convenience function 23 WebKit::NetworkSessionCocoa::session() whereas isolated sessions are created lazily and 24 picked up through WebKit::NetworkSessionCocoa::isolatedSession(). 25 26 The number of isolated NSURLSessions in memory is capped to 10. When the cap is hit, 27 the session that's been unused the longest is aged out. 28 29 The C API changes are test infrastructure. 30 31 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: 32 (WebKit::ResourceLoadStatisticsDatabaseStore::clear): 33 (WebKit::ResourceLoadStatisticsDatabaseStore::domainsToBlockAndDeleteCookiesFor const): 34 (WebKit::ResourceLoadStatisticsDatabaseStore::domainsToBlockButKeepCookiesFor const): 35 (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking): 36 (WebKit::ResourceLoadStatisticsDatabaseStore::domainsToBlock const): Deleted. 37 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: 38 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 39 (WebKit::ResourceLoadStatisticsMemoryStore::clear): 40 (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): 41 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: 42 (WebKit::ResourceLoadStatisticsStore::updateCookieBlockingForDomains): 43 (WebKit::ResourceLoadStatisticsStore::debugLogDomainsInBatches): 44 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: 45 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 46 (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler): 47 (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains): Deleted. 48 (WebKit::WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains): Deleted. 49 Dead code. 50 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 51 (WebKit::RegistrableDomainsToBlockCookiesFor::isolatedCopy const): 52 * NetworkProcess/NetworkProcess.cpp: 53 (WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor): 54 (WebKit::NetworkProcess::scheduleClearInMemoryAndPersistent): 55 (WebKit::NetworkProcess::hasIsolatedSession const): 56 * NetworkProcess/NetworkProcess.h: 57 * NetworkProcess/NetworkProcess.messages.in: 58 * NetworkProcess/NetworkSession.h: 59 (WebKit::NetworkSession::shouldIsolateSessionsForPrevalentTopFrames const): 60 (WebKit::NetworkSession::hasIsolatedSession const): 61 (WebKit::NetworkSession::clearIsolatedSessions): 62 * NetworkProcess/NetworkSessionCreationParameters.cpp: 63 (WebKit::NetworkSessionCreationParameters::encode const): 64 (WebKit::NetworkSessionCreationParameters::decode): 65 * NetworkProcess/NetworkSessionCreationParameters.h: 66 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 67 (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): 68 * NetworkProcess/cocoa/NetworkSessionCocoa.h: 69 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 70 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 71 (WebKit::NetworkSessionCocoa::session): 72 (WebKit::NetworkSessionCocoa::isolatedSession): 73 (WebKit::NetworkSessionCocoa::hasIsolatedSession const): 74 (WebKit::NetworkSessionCocoa::clearIsolatedSessions): 75 (WebKit::NetworkSessionCocoa::invalidateAndCancel): 76 (WebKit::NetworkSessionCocoa::clearCredentials): 77 * Shared/WebPreferences.yaml: 78 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 79 (WKWebsiteDataStoreStatisticsHasIsolatedSession): 80 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 81 * UIProcess/Network/NetworkProcessProxy.cpp: 82 (WebKit::NetworkProcessProxy::hasIsolatedSession): 83 * UIProcess/Network/NetworkProcessProxy.h: 84 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 85 (WebKit::WebsiteDataStore::parameters): 86 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 87 (WebKit::WebsiteDataStore::hasLocalStorageForTesting const): 88 (WebKit::WebsiteDataStore::hasIsolatedSessionForTesting const): 89 * UIProcess/WebsiteData/WebsiteDataStore.h: 90 1 91 2019-08-13 Chris Dumez <cdumez@apple.com> 2 92 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
r247119 r248640 1318 1318 removeAllStorageAccess([callbackAggregator = callbackAggregator.copyRef()] { }); 1319 1319 1320 auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode(); 1321 updateCookieBlockingForDomains(primaryDomainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 1320 auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode(); 1321 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } }; 1322 updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 1322 1323 } 1323 1324 … … 1354 1355 } 1355 1356 1356 Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::domainsToBlock () const1357 { 1358 ASSERT(!RunLoop::isMain()); 1359 1357 Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::domainsToBlockAndDeleteCookiesFor() const 1358 { 1359 ASSERT(!RunLoop::isMain()); 1360 1360 1361 Vector<RegistrableDomain> results; 1361 SQLiteStatement statement(m_database, "SELECT registrableDomain FROM ObservedDomains WHERE isPrevalent = 1 "_s);1362 SQLiteStatement statement(m_database, "SELECT registrableDomain FROM ObservedDomains WHERE isPrevalent = 1 AND hadUserInteraction = 0"_s); 1362 1363 if (statement.prepare() != SQLITE_OK) 1363 1364 return results; … … 1365 1366 while (statement.step() == SQLITE_ROW) 1366 1367 results.append(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(statement.getColumnText(0))); 1367 1368 1368 1369 return results; 1369 1370 } 1370 1371 1372 Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::domainsToBlockButKeepCookiesFor() const 1373 { 1374 ASSERT(!RunLoop::isMain()); 1375 1376 Vector<RegistrableDomain> results; 1377 SQLiteStatement statement(m_database, "SELECT registrableDomain FROM ObservedDomains WHERE isPrevalent = 1 AND hadUserInteraction = 1"_s); 1378 if (statement.prepare() != SQLITE_OK) 1379 return results; 1380 1381 while (statement.step() == SQLITE_ROW) 1382 results.append(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(statement.getColumnText(0))); 1383 1384 return results; 1385 } 1386 1371 1387 void ResourceLoadStatisticsDatabaseStore::updateCookieBlocking(CompletionHandler<void()>&& completionHandler) 1372 1388 { 1373 1389 ASSERT(!RunLoop::isMain()); 1374 1390 1375 auto domainsToBlock = this->domainsToBlock(); 1376 1377 if (domainsToBlock.isEmpty()) { 1391 auto domainsToBlockAndDeleteCookiesFor = this->domainsToBlockAndDeleteCookiesFor(); 1392 auto domainsToBlockButKeepCookiesFor = this->domainsToBlockButKeepCookiesFor(); 1393 1394 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty()) { 1378 1395 completionHandler(); 1379 1396 return; 1380 1397 } 1381 1398 1382 if (debugLoggingEnabled() && !domainsToBlock.isEmpty()) 1399 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor }; 1400 1401 if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty()) 1383 1402 debugLogDomainsInBatches("block", domainsToBlock); 1384 1403 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
r247119 r248640 118 118 void updateLastSeen(const RegistrableDomain&, WallTime); 119 119 void setUserInteraction(const RegistrableDomain&, bool hadUserInteraction, WallTime); 120 Vector<RegistrableDomain> domainsToBlock() const; 120 Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor() const; 121 Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor() const; 121 122 122 123 struct PrevalentDomainData { -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r248401 r248640 713 713 removeAllStorageAccess([callbackAggregator = callbackAggregator.copyRef()] { }); 714 714 715 auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode(); 716 updateCookieBlockingForDomains(primaryDomainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 715 auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode(); 716 RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } }; 717 updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { }); 717 718 } 718 719 … … 762 763 ASSERT(!RunLoop::isMain()); 763 764 764 Vector<RegistrableDomain> domainsToBlock; 765 Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor; 766 Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor; 765 767 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 766 if (resourceStatistic.isPrevalentResource) 767 domainsToBlock.append(resourceStatistic.registrableDomain); 768 } 769 770 if (domainsToBlock.isEmpty() && !debugModeEnabled()) { 768 if (resourceStatistic.isPrevalentResource) { 769 if (hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long)) 770 domainsToBlockButKeepCookiesFor.append(resourceStatistic.registrableDomain); 771 else 772 domainsToBlockAndDeleteCookiesFor.append(resourceStatistic.registrableDomain); 773 } 774 } 775 776 if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && !debugModeEnabled()) { 771 777 completionHandler(); 772 778 return; 773 779 } 774 780 775 if (debugLoggingEnabled() && !domainsToBlock.isEmpty()) 781 RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor }; 782 783 if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty()) 776 784 debugLogDomainsInBatches("block", domainsToBlock); 777 785 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
r248372 r248640 414 414 } 415 415 416 void ResourceLoadStatisticsStore::updateCookieBlockingForDomains(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler)416 void ResourceLoadStatisticsStore::updateCookieBlockingForDomains(const RegistrableDomainsToBlockCookiesFor& domainsToBlock, CompletionHandler<void()>&& completionHandler) 417 417 { 418 418 ASSERT(!RunLoop::isMain()); … … 572 572 } 573 573 574 void ResourceLoadStatisticsStore::debugLogDomainsInBatches(const char* action, const Vector<RegistrableDomain>& domains) 575 { 574 void ResourceLoadStatisticsStore::debugLogDomainsInBatches(const char* action, const RegistrableDomainsToBlockCookiesFor& domainsToBlock) 575 { 576 Vector<RegistrableDomain> domains; 577 domains.appendVector(domainsToBlock.domainsToBlockAndDeleteCookiesFor); 578 domains.appendVector(domainsToBlock.domainsToBlockButKeepCookiesFor); 576 579 static const auto maxNumberOfDomainsInOneLogStatement = 50; 577 580 if (domains.isEmpty()) -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
r247119 r248640 99 99 100 100 virtual void updateCookieBlocking(CompletionHandler<void()>&&) = 0; 101 void updateCookieBlockingForDomains(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&&);101 void updateCookieBlockingForDomains(const RegistrableDomainsToBlockCookiesFor&, CompletionHandler<void()>&&); 102 102 void clearBlockingStateForDomains(const Vector<RegistrableDomain>& domains, CompletionHandler<void()>&&); 103 103 … … 187 187 static unsigned computeImportance(const WebCore::ResourceLoadStatistics&); 188 188 static Vector<OperatingDate> mergeOperatingDates(const Vector<OperatingDate>& existingDates, Vector<OperatingDate>&& newDates); 189 static void debugLogDomainsInBatches(const char* action, const Vector<RegistrableDomain>& domains);189 static void debugLogDomainsInBatches(const char* action, const RegistrableDomainsToBlockCookiesFor&); 190 190 191 191 ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost); -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r248634 r248640 841 841 } 842 842 843 void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler)844 {845 // Helper function used by testing system. Should only be called from the main thread.846 ASSERT(RunLoop::isMain());847 postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)]() mutable {848 if (!m_statisticsStore) {849 postTaskReply(WTFMove(completionHandler));850 return;851 }852 853 m_statisticsStore->updateCookieBlockingForDomains(domainsToBlock, [completionHandler = WTFMove(completionHandler)]() mutable {854 postTaskReply(WTFMove(completionHandler));855 });856 });857 }858 859 void WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains(const Vector<RegistrableDomain>& domains, CompletionHandler<void()>&& completionHandler)860 {861 // Helper function used by testing system. Should only be called from the main thread.862 ASSERT(RunLoop::isMain());863 postTask([this, domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)]() mutable {864 if (!m_statisticsStore) {865 postTaskReply(WTFMove(completionHandler));866 return;867 }868 869 m_statisticsStore->clearBlockingStateForDomains(domains, [completionHandler = WTFMove(completionHandler)]() mutable {870 postTaskReply(WTFMove(completionHandler));871 });872 });873 }874 875 843 void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfatherStatistics shouldGrandfather, CompletionHandler<void()>&& completionHandler) 876 844 { … … 957 925 } 958 926 959 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler)927 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const RegistrableDomainsToBlockCookiesFor& domainsToBlock, CompletionHandler<void()>&& completionHandler) 960 928 { 961 929 ASSERT(RunLoop::isMain()); 962 930 963 931 if (m_networkSession) { 964 if (auto* storageSession = m_networkSession->networkStorageSession()) 965 storageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock); 932 if (auto* storageSession = m_networkSession->networkStorageSession()) { 933 storageSession->setPrevalentDomainsToBlockAndDeleteCookiesFor(domainsToBlock.domainsToBlockAndDeleteCookiesFor); 934 storageSession->setPrevalentDomainsToBlockButKeepCookiesFor(domainsToBlock.domainsToBlockButKeepCookiesFor); 935 } 966 936 } 967 937 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r247784 r248640 64 64 enum class ShouldIncludeLocalhost : bool { No, Yes }; 65 65 enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes }; 66 enum class EnableResourceLoadStatisticsNSURLSessionSwitching : bool { No, Yes }; 66 67 enum class WebsiteDataToRemove : uint8_t { 67 68 All, 68 69 AllButHttpOnlyCookies, 69 70 AllButCookies 71 }; 72 struct RegistrableDomainsToBlockCookiesFor { 73 Vector<WebCore::RegistrableDomain> domainsToBlockAndDeleteCookiesFor; 74 Vector<WebCore::RegistrableDomain> domainsToBlockButKeepCookiesFor; 75 RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy() }; } 70 76 }; 71 77 … … 169 175 void callGrantStorageAccessHandler(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, WebCore::PageIdentifier, CompletionHandler<void(StorageAccessWasGranted)>&&); 170 176 void removeAllStorageAccess(CompletionHandler<void()>&&); 171 void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&);177 void callUpdatePrevalentDomainsToBlockCookiesForHandler(const RegistrableDomainsToBlockCookiesFor&, CompletionHandler<void()>&&); 172 178 void callRemoveDomainsHandler(const Vector<RegistrableDomain>&); 173 179 void callHasStorageAccessForFrameHandler(const SubFrameDomain&, const TopFrameDomain&, FrameID, WebCore::PageIdentifier, CompletionHandler<void(bool)>&&); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r248593 r248640 637 637 { 638 638 if (auto* networkStorageSession = storageSession(sessionID)) 639 networkStorageSession->setPrevalentDomainsToBlock CookiesFor(domainsToBlock);639 networkStorageSession->setPrevalentDomainsToBlockAndDeleteCookiesFor(domainsToBlock); 640 640 completionHandler(); 641 641 } … … 781 781 { 782 782 if (auto* networkSession = this->networkSession(sessionID)) { 783 networkSession->clearIsolatedSessions(); 783 784 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { 784 785 if (modifiedSince) … … 1235 1236 ASSERT_NOT_REACHED(); 1236 1237 completionHandler(); 1238 } 1239 1240 void NetworkProcess::hasIsolatedSession(PAL::SessionID sessionID, const WebCore::RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) const 1241 { 1242 bool result = false; 1243 if (auto* networkSession = this->networkSession(sessionID)) 1244 result = networkSession->hasIsolatedSession(domain); 1245 completionHandler(result); 1237 1246 } 1238 1247 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r248593 r248640 260 260 void setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&&); 261 261 void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&); 262 void hasIsolatedSession(PAL::SessionID, const WebCore::RegistrableDomain&, CompletionHandler<void(bool)>&&) const; 262 263 #endif 263 264 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r248526 r248640 138 138 ResetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID) -> () Async 139 139 DeleteCookiesForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain domain, bool includeHttpOnlyCookies) -> () Async 140 HasIsolatedSession(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) -> (bool hasIsolatedSession) Async 140 141 #endif 141 142 -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r248593 r248640 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 virtual bool hasIsolatedSession(const WebCore::RegistrableDomain) const { return false; } 98 virtual void clearIsolatedSessions() { } 96 99 #endif 97 100 void storeAdClickAttribution(WebCore::AdClickAttribution&&); … … 134 137 EnableResourceLoadStatisticsDebugMode m_enableResourceLoadStatisticsDebugMode { EnableResourceLoadStatisticsDebugMode::No }; 135 138 WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource; 139 EnableResourceLoadStatisticsNSURLSessionSwitching m_enableResourceLoadStatisticsNSURLSessionSwitching { EnableResourceLoadStatisticsNSURLSessionSwitching::No }; 136 140 bool m_enableResourceLoadStatisticsLogTestingEvent; 137 141 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r248144 r248640 51 51 , { }, { } 52 52 #endif 53 , { }, { }, false, false, { }, { }, { }, { }, { }, { }, { }, { }, { } 53 , { }, { }, false, false, { }, { }, { }, { }, { }, { }, { }, { }, { }, { } 54 54 }; 55 55 } … … 85 85 encoder << enableResourceLoadStatisticsDebugMode; 86 86 encoder << resourceLoadStatisticsManualPrevalentResource; 87 encoder << enableResourceLoadStatisticsNSURLSessionSwitching; 87 88 88 89 encoder << localStorageDirectory << localStorageDirectoryExtensionHandle; … … 209 210 return WTF::nullopt; 210 211 212 Optional<bool> enableResourceLoadStatisticsNSURLSessionSwitching; 213 decoder >> enableResourceLoadStatisticsNSURLSessionSwitching; 214 if (!enableResourceLoadStatisticsNSURLSessionSwitching) 215 return WTF::nullopt; 216 211 217 Optional<String> localStorageDirectory; 212 218 decoder >> localStorageDirectory; … … 267 273 , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics) 268 274 , WTFMove(*enableResourceLoadStatisticsDebugMode) 275 , WTFMove(*enableResourceLoadStatisticsNSURLSessionSwitching) 269 276 , WTFMove(*deviceManagementRestrictionsEnabled) 270 277 , WTFMove(*allLoadsBlockedByDeviceManagementRestrictionsForTesting) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r248144 r248640 88 88 bool shouldIncludeLocalhostInResourceLoadStatistics { true }; 89 89 bool enableResourceLoadStatisticsDebugMode { false }; 90 bool enableResourceLoadStatisticsNSURLSessionSwitching { true }; 90 91 bool deviceManagementRestrictionsEnabled { false }; 91 92 bool allLoadsBlockedByDeviceManagementRestrictionsForTesting { false }; -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r248273 r248640 39 39 #import <WebCore/NetworkStorageSession.h> 40 40 #import <WebCore/NotImplemented.h> 41 #import <WebCore/RegistrableDomain.h> 41 42 #import <WebCore/ResourceRequest.h> 42 43 #import <pal/spi/cf/CFNetworkSPI.h> … … 206 207 207 208 bool shouldBlockCookies = false; 209 bool needsIsolatedSession = false; 210 auto firstParty = WebCore::RegistrableDomain(request.firstPartyForCookies()); 208 211 #if ENABLE(RESOURCE_LOAD_STATISTICS) 209 shouldBlockCookies = storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless 210 || (session.networkStorageSession() && session.networkStorageSession()->shouldBlockCookies(request, frameID, pageID)); 212 shouldBlockCookies = storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless; 213 if (auto* networkStorageSession = session.networkStorageSession()) { 214 if (!shouldBlockCookies) 215 shouldBlockCookies = networkStorageSession->shouldBlockCookies(request, frameID, pageID); 216 needsIsolatedSession = session.shouldIsolateSessionsForPrevalentTopFrames() && networkStorageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty); 217 } 211 218 #endif 212 219 restrictRequestReferrerToOriginIfNeeded(request, shouldBlockCookies); … … 216 223 217 224 auto& cocoaSession = static_cast<NetworkSessionCocoa&>(*m_session); 225 if (needsIsolatedSession) 226 m_task = [cocoaSession.isolatedSession(storedCredentialsPolicy, firstParty) dataTaskWithRequest:nsRequest]; 227 else 228 m_task = [cocoaSession.session(storedCredentialsPolicy) dataTaskWithRequest:nsRequest]; 218 229 switch (storedCredentialsPolicy) { 219 230 case WebCore::StoredCredentialsPolicy::Use: 220 m_task = [cocoaSession.m_sessionWithCredentialStorage dataTaskWithRequest:nsRequest];221 231 ASSERT(!cocoaSession.m_dataTaskMapWithCredentials.contains([m_task taskIdentifier])); 222 232 cocoaSession.m_dataTaskMapWithCredentials.add([m_task taskIdentifier], this); … … 224 234 break; 225 235 case WebCore::StoredCredentialsPolicy::DoNotUse: 226 m_task = [cocoaSession.m_statelessSession dataTaskWithRequest:nsRequest];227 236 ASSERT(!cocoaSession.m_dataTaskMapWithoutState.contains([m_task taskIdentifier])); 228 237 cocoaSession.m_dataTaskMapWithoutState.add([m_task taskIdentifier], this); … … 230 239 break; 231 240 case WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless: 232 if (!cocoaSession.m_ephemeralStatelessCookielessSession)233 cocoaSession.initializeEphemeralStatelessCookielessSession();234 m_task = [cocoaSession.m_ephemeralStatelessCookielessSession dataTaskWithRequest:nsRequest];235 241 ASSERT(!cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.contains([m_task taskIdentifier])); 236 242 cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.add([m_task taskIdentifier], this); -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h
r248592 r248640 39 39 #include "WebSocketTask.h" 40 40 #include <WebCore/NetworkLoadMetrics.h> 41 #include <WebCore/RegistrableDomain.h> 41 42 #include <wtf/HashMap.h> 43 #include <wtf/Seconds.h> 42 44 43 45 namespace WebKit { … … 84 86 CFDictionaryRef proxyConfiguration() const { return m_proxyConfiguration.get(); } 85 87 88 NSURLSession* session(WebCore::StoredCredentialsPolicy); 89 NSURLSession* isolatedSession(WebCore::StoredCredentialsPolicy, const WebCore::RegistrableDomain); 90 bool hasIsolatedSession(const WebCore::RegistrableDomain) const override; 91 void clearIsolatedSessions() override; 92 86 93 private: 87 94 void invalidateAndCancel() override; … … 104 111 #endif 105 112 113 struct IsolatedSession { 114 RetainPtr<NSURLSession> sessionWithCredentialStorage; 115 RetainPtr<WKNetworkSessionDelegate> sessionWithCredentialStorageDelegate; 116 RetainPtr<NSURLSession> statelessSession; 117 RetainPtr<WKNetworkSessionDelegate> statelessSessionDelegate; 118 WallTime lastUsed; 119 }; 120 121 HashMap<WebCore::RegistrableDomain, IsolatedSession> m_isolatedSessions; 122 106 123 RetainPtr<NSURLSession> m_sessionWithCredentialStorage; 107 124 RetainPtr<WKNetworkSessionDelegate> m_sessionWithCredentialStorageDelegate; -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r248394 r248640 67 67 CFStringRef const WebKit2HTTPProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPProxy"); 68 68 CFStringRef const WebKit2HTTPSProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPSProxy"); 69 70 constexpr unsigned maxNumberOfIsolatedSessions { 10 }; 69 71 70 72 static NSURLSessionResponseDisposition toNSURLSessionResponseDisposition(WebCore::PolicyAction disposition) … … 1035 1037 m_enableResourceLoadStatisticsDebugMode = parameters.enableResourceLoadStatisticsDebugMode ? EnableResourceLoadStatisticsDebugMode::Yes : EnableResourceLoadStatisticsDebugMode::No; 1036 1038 m_resourceLoadStatisticsManualPrevalentResource = parameters.resourceLoadStatisticsManualPrevalentResource; 1039 m_enableResourceLoadStatisticsNSURLSessionSwitching = parameters.enableResourceLoadStatisticsNSURLSessionSwitching ? EnableResourceLoadStatisticsNSURLSessionSwitching::Yes : EnableResourceLoadStatisticsNSURLSessionSwitching::No; 1037 1040 setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics); 1038 1041 #endif … … 1067 1070 m_ephemeralStatelessCookielessSessionDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:false]); 1068 1071 m_ephemeralStatelessCookielessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_ephemeralStatelessCookielessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1072 } 1073 1074 NSURLSession* NetworkSessionCocoa::session(WebCore::StoredCredentialsPolicy storedCredentialsPolicy) 1075 { 1076 switch (storedCredentialsPolicy) { 1077 case WebCore::StoredCredentialsPolicy::Use: 1078 return m_sessionWithCredentialStorage.get(); 1079 case WebCore::StoredCredentialsPolicy::DoNotUse: 1080 return m_statelessSession.get(); 1081 case WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless: 1082 if (!m_ephemeralStatelessCookielessSession) 1083 initializeEphemeralStatelessCookielessSession(); 1084 return m_ephemeralStatelessCookielessSession.get(); 1085 } 1086 } 1087 1088 NSURLSession* NetworkSessionCocoa::isolatedSession(WebCore::StoredCredentialsPolicy storedCredentialsPolicy, const WebCore::RegistrableDomain firstPartyDomain) 1089 { 1090 auto entry = m_isolatedSessions.ensure(firstPartyDomain, [this] { 1091 IsolatedSession newEntry { }; 1092 newEntry.sessionWithCredentialStorageDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:true]); 1093 newEntry.sessionWithCredentialStorage = [NSURLSession sessionWithConfiguration:m_sessionWithCredentialStorage.get().configuration delegate:static_cast<id>(newEntry.sessionWithCredentialStorageDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1094 1095 newEntry.statelessSessionDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:false]); 1096 newEntry.statelessSession = [NSURLSession sessionWithConfiguration:m_statelessSession.get().configuration delegate:static_cast<id>(newEntry.statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1097 1098 return newEntry; 1099 }).iterator->value; 1100 1101 entry.lastUsed = WallTime::now(); 1102 1103 if (m_isolatedSessions.size() > maxNumberOfIsolatedSessions) { 1104 WebCore::RegistrableDomain keyToRemove; 1105 auto oldestTimestamp = WallTime::now(); 1106 for (auto& key : m_isolatedSessions.keys()) { 1107 auto timestamp = m_isolatedSessions.get(key).lastUsed; 1108 if (timestamp < oldestTimestamp) { 1109 oldestTimestamp = timestamp; 1110 keyToRemove = key; 1111 } 1112 } 1113 LOG(NetworkSession, "About to remove isolated NSURLSession."); 1114 m_isolatedSessions.remove(keyToRemove); 1115 } 1116 1117 RELEASE_ASSERT(m_isolatedSessions.size() <= maxNumberOfIsolatedSessions); 1118 1119 switch (storedCredentialsPolicy) { 1120 case WebCore::StoredCredentialsPolicy::Use: 1121 LOG(NetworkSession, "Using isolated NSURLSession with credential storage."); 1122 return entry.sessionWithCredentialStorage.get(); 1123 case WebCore::StoredCredentialsPolicy::DoNotUse: 1124 LOG(NetworkSession, "Using isolated NSURLSession without credential storage."); 1125 return entry.statelessSession.get(); 1126 case WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless: 1127 if (!m_ephemeralStatelessCookielessSession) 1128 initializeEphemeralStatelessCookielessSession(); 1129 return m_ephemeralStatelessCookielessSession.get(); 1130 } 1131 } 1132 1133 bool NetworkSessionCocoa::hasIsolatedSession(const WebCore::RegistrableDomain domain) const 1134 { 1135 return m_isolatedSessions.contains(domain); 1136 } 1137 1138 void NetworkSessionCocoa::clearIsolatedSessions() 1139 { 1140 m_isolatedSessions.clear(); 1069 1141 } 1070 1142 … … 1079 1151 [m_statelessSessionDelegate sessionInvalidated]; 1080 1152 [m_ephemeralStatelessCookielessSessionDelegate sessionInvalidated]; 1153 1154 for (auto& session : m_isolatedSessions.values()) { 1155 [session.sessionWithCredentialStorage invalidateAndCancel]; 1156 [session.sessionWithCredentialStorageDelegate sessionInvalidated]; 1157 } 1158 m_isolatedSessions.clear(); 1081 1159 } 1082 1160 … … 1090 1168 m_sessionWithCredentialStorage = [NSURLSession sessionWithConfiguration:m_sessionWithCredentialStorage.get().configuration delegate:static_cast<id>(m_sessionWithCredentialStorageDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1091 1169 m_statelessSession = [NSURLSession sessionWithConfiguration:m_statelessSession.get().configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1170 for (auto& entry : m_isolatedSessions.values()) 1171 entry.session = [NSURLSession sessionWithConfiguration:entry.session.get().configuration delegate:static_cast<id>(entry.delegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; 1092 1172 #endif 1093 1173 } -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r248471 r248640 1724 1724 category: experimental 1725 1725 1726 IsITPSessionSwitchingEnabled: 1727 type: bool 1728 defaultValue: true 1729 humanReadableName: "ITP Session Switching" 1730 humanReadableDescription: "Enable session switching for domains classified by ITP" 1731 webcoreBinding: RuntimeEnabledFeatures 1732 category: internal 1733 1726 1734 # Deprecated 1727 1735 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r245500 r248640 473 473 } 474 474 475 void WKWebsiteDataStoreStatisticsHasIsolatedSession(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasIsolatedSessionFunction callback) 476 { 477 #if ENABLE(RESOURCE_LOAD_STATISTICS) 478 WebKit::toImpl(dataStoreRef)->websiteDataStore().hasIsolatedSessionForTesting(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasIsolatedSession) { 479 callback(hasIsolatedSession, context); 480 }); 481 #else 482 callback(false, context); 483 #endif 484 } 485 475 486 void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler) 476 487 { -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r244572 r248640 104 104 typedef void (*WKWebsiteDataStoreSetStatisticsCacheMaxAgeCapFunction)(void* functionContext); 105 105 WK_EXPORT void WKWebsiteDataStoreSetStatisticsCacheMaxAgeCap(WKWebsiteDataStoreRef dataStoreRef, double seconds, void* context, WKWebsiteDataStoreSetStatisticsCacheMaxAgeCapFunction); 106 typedef void (*WKWebsiteDataStoreStatisticsHasIsolatedSessionFunction)(bool hasIsolatedSession, void* functionContext); 107 WK_EXPORT void WKWebsiteDataStoreStatisticsHasIsolatedSession(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsHasIsolatedSessionFunction callback); 106 108 typedef void (*WKWebsiteDataStoreStatisticsResetToConsistentStateFunction)(void* functionContext); 107 109 WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r248047 r248640 975 975 } 976 976 977 void NetworkProcessProxy::hasIsolatedSession(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 978 { 979 if (!canSendMessage()) { 980 completionHandler(false); 981 return; 982 } 983 984 sendWithAsyncReply(Messages::NetworkProcess::HasIsolatedSession(sessionID, domain), WTFMove(completionHandler)); 985 } 986 977 987 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 978 988 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r248047 r248640 151 151 void deleteCookiesForTesting(PAL::SessionID, const RegistrableDomain&, bool includeHttpOnlyCookies, CompletionHandler<void()>&&); 152 152 void deleteWebsiteDataInUIProcessForRegistrableDomains(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<RegistrableDomain>, CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&); 153 void hasIsolatedSession(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 153 154 #endif 154 155 -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r248144 r248640 33 33 #import <WebCore/RegistrableDomain.h> 34 34 #import <WebCore/RuntimeApplicationChecks.h> 35 #import <WebCore/RuntimeEnabledFeatures.h> 35 36 #import <WebCore/SearchPopupMenuCocoa.h> 36 37 #import <pal/spi/cf/CFNetworkSPI.h> … … 67 68 bool shouldLogCookieInformation = false; 68 69 bool enableResourceLoadStatisticsDebugMode = false; 70 bool enableResourceLoadStatisticsNSURLSessionSwitching = WebCore::RuntimeEnabledFeatures::sharedFeatures().isITPSessionSwitchingEnabled(); 69 71 WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { }; 70 72 #if ENABLE(RESOURCE_LOAD_STATISTICS) … … 138 140 shouldIncludeLocalhostInResourceLoadStatistics, 139 141 enableResourceLoadStatisticsDebugMode, 142 enableResourceLoadStatisticsNSURLSessionSwitching, 140 143 m_configuration->deviceManagementRestrictionsEnabled(), 141 144 m_configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting(), -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r248144 r248640 1685 1685 ASSERT(!completionHandler); 1686 1686 } 1687 1688 void WebsiteDataStore::hasIsolatedSessionForTesting(const URL& url, CompletionHandler<void(bool)>&& completionHandler) const 1689 { 1690 for (auto& processPool : processPools()) { 1691 if (auto* networkProcess = processPool->networkProcess()) { 1692 networkProcess->hasIsolatedSession(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler)); 1693 ASSERT(processPools().size() == 1); 1694 break; 1695 } 1696 } 1697 ASSERT(!completionHandler); 1698 } 1687 1699 #endif // ENABLE(RESOURCE_LOAD_STATISTICS) 1688 1700 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r248144 r248640 180 180 void deleteCookiesForTesting(const URL&, bool includeHttpOnlyCookies, CompletionHandler<void()>&&); 181 181 void hasLocalStorageForTesting(const URL&, CompletionHandler<void(bool)>&&) const; 182 void hasIsolatedSessionForTesting(const URL&, CompletionHandler<void(bool)>&&) const; 182 183 #endif 183 184 void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&); -
trunk/Tools/ChangeLog
r248636 r248640 1 2019-08-13 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Switch NSURLSession on top navigation to prevalent resource with user interaction 4 https://bugs.webkit.org/show_bug.cgi?id=200642 5 <rdar://problem/53962073> 6 7 Reviewed by Alex Christensen. 8 9 This patch adds test infrastructure to query whether an origin has an 10 isolated NSURLSession or not. 11 12 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 13 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 14 (WTR::TestRunner::hasStatisticsIsolatedSession): 15 * WebKitTestRunner/InjectedBundle/TestRunner.h: 16 * WebKitTestRunner/TestController.cpp: 17 (WTR::TestController::hasStatisticsIsolatedSession): 18 * WebKitTestRunner/TestController.h: 19 * WebKitTestRunner/TestInvocation.cpp: 20 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 21 1 22 2019-08-13 Zhifei Fang <zhifei_fang@apple.com> 2 23 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r248526 r248640 334 334 void setStatisticsCacheMaxAgeCap(double seconds); 335 335 void statisticsResetToConsistentState(object completionHandler); 336 boolean hasStatisticsIsolatedSession(DOMString hostName); 336 337 337 338 // Injected bundle form client. -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r248526 r248640 2067 2067 } 2068 2068 2069 bool TestRunner::hasStatisticsIsolatedSession(JSStringRef hostName) 2070 { 2071 auto messageName = adoptWK(WKStringCreateWithUTF8CString("HasStatisticsIsolatedSession")); 2072 auto messageBody = adoptWK(WKStringCreateWithJSString(hostName)); 2073 WKTypeRef returnData = nullptr; 2074 WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData); 2075 ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID()); 2076 return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get()); 2077 } 2078 2069 2079 void TestRunner::statisticsCallClearThroughWebsiteDataRemovalCallback() 2070 2080 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r248526 r248640 432 432 bool isStatisticsHasLocalStorage(JSStringRef hostName); 433 433 void setStatisticsCacheMaxAgeCap(double seconds); 434 bool hasStatisticsIsolatedSession(JSStringRef hostName); 434 435 void statisticsResetToConsistentState(JSValueRef completionHandler); 435 436 void statisticsCallDidResetToConsistentStateCallback(); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r248526 r248640 3512 3512 } 3513 3513 3514 bool TestController::hasStatisticsIsolatedSession(WKStringRef host) 3515 { 3516 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 3517 ResourceStatisticsCallbackContext context(*this); 3518 WKWebsiteDataStoreStatisticsHasIsolatedSession(dataStore, host, &context, resourceStatisticsBooleanResultCallback); 3519 runUntil(context.done, noTimeout); 3520 return context.result; 3521 } 3522 3514 3523 void TestController::statisticsResetToConsistentState() 3515 3524 { -
trunk/Tools/WebKitTestRunner/TestController.h
r248526 r248640 245 245 bool isStatisticsHasLocalStorage(WKStringRef hostName); 246 246 void setStatisticsCacheMaxAgeCap(double seconds); 247 bool hasStatisticsIsolatedSession(WKStringRef hostName); 247 248 void statisticsResetToConsistentState(); 248 249 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r248526 r248640 1463 1463 } 1464 1464 1465 if (WKStringIsEqualToUTF8CString(messageName, "HasStatisticsIsolatedSession")) { 1466 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 1467 1468 WKStringRef hostName = static_cast<WKStringRef>(messageBody); 1469 bool hasIsolatedSession = TestController::singleton().hasStatisticsIsolatedSession(hostName); 1470 auto result = adoptWK(WKBooleanCreate(hasIsolatedSession)); 1471 return result; 1472 } 1473 1465 1474 if (WKStringIsEqualToUTF8CString(messageName, "RemoveAllSessionCredentials")) { 1466 1475 TestController::singleton().removeAllSessionCredentials();
Note: See TracChangeset
for help on using the changeset viewer.