Changeset 252014 in webkit
- Timestamp:
- Nov 4, 2019 2:13:40 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252013 r252014 1 2019-11-04 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Flush the shared ResourceLoadObserver when the webpage is closed by JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=203623 5 <rdar://problem/56756427> 6 7 Reviewed by Alex Christensen. 8 9 New API test added. 10 11 * loader/ResourceLoadObserver.cpp: 12 (WebCore::ResourceLoadObserver::shared): 13 Now returns its own empty observer if no shared one has been set. 14 * loader/ResourceLoadObserver.h: 15 (WebCore::ResourceLoadObserver::logSubresourceLoadingForTesting): 16 Test function to seed the web process' observer. 17 * page/DOMWindow.cpp: 18 (WebCore::DOMWindow::close): 19 Now flushes the shared observer. 20 1 21 2019-11-04 Alex Christensen <achristensen@webkit.org> 2 22 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r249920 r252014 26 26 #include "config.h" 27 27 #include "ResourceLoadObserver.h" 28 #include <wtf/NeverDestroyed.h> 28 29 29 30 namespace WebCore { … … 43 44 ResourceLoadObserver& ResourceLoadObserver::shared() 44 45 { 46 static NeverDestroyed<ResourceLoadObserver> emptyObserver; 45 47 if (!sharedObserver()) 46 sharedObserver() = new ResourceLoadObserver;48 return emptyObserver; 47 49 return *sharedObserver(); 48 50 } -
trunk/Source/WebCore/loader/ResourceLoadObserver.h
r249920 r252014 53 53 virtual void logNavigatorAPIAccessed(const Document&, const ResourceLoadStatistics::NavigatorAPI) { } 54 54 virtual void logScreenAPIAccessed(const Document&, const ResourceLoadStatistics::ScreenAPI) { } 55 virtual void logSubresourceLoadingForTesting(const RegistrableDomain& /* firstPartyDomain */, const RegistrableDomain& /* thirdPartyDomain */, bool /* shouldScheduleNotification */) { } 55 56 56 57 virtual String statisticsForURL(const URL&) { return { }; } -
trunk/Source/WebCore/page/DOMWindow.cpp
r251425 r252014 1059 1059 return; 1060 1060 1061 ResourceLoadObserver::shared().updateCentralStatisticsStore(); 1062 1061 1063 page->setIsClosing(); 1062 1064 page->chrome().closeWindowSoon(); -
trunk/Source/WebKit/ChangeLog
r252011 r252014 1 2019-11-04 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Flush the shared ResourceLoadObserver when the webpage is closed by JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=203623 5 <rdar://problem/56756427> 6 7 Reviewed by Alex Christensen. 8 9 This patch adds flushing of pending statistics when a window is closed by JavaScript, 10 when a webpage is removed from the web process, and when the web process prepares to 11 suspend. 12 13 New API test added. 14 15 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 16 (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated): 17 Now calls logTestingEvent() so that the test infrastructure can wait for updates. 18 * UIProcess/API/Cocoa/WKProcessPool.mm: 19 (-[WKProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:thirdParty:shouldScheduleNotification:completionHandler:]): 20 Test infrastructure to seed every web process' WebCore::ResourceLoadObserver with test data. 21 * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: 22 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 23 (-[WKWebsiteDataStore _clearResourceLoadStatistics:]): 24 (-[WKWebsiteDataStore _isRegisteredAsSubresourceUnderFirstParty:thirdParty:completionHandler:]): 25 Test infrastructure. 26 * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: 27 * UIProcess/WebProcessPool.cpp: 28 (WebKit::WebProcessPool::seedResourceLoadStatisticsForTesting): 29 Test infrastructure. 30 * UIProcess/WebProcessPool.h: 31 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 32 (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder): 33 Made sure the completion handler is called even if there is no network process. 34 (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled): 35 Now tells all web processes to turn ITP on or off. 36 * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp: 37 (WebKit::WebResourceLoadObserver::~WebResourceLoadObserver): 38 (WebKit::WebResourceLoadObserver::logSubresourceLoadingForTesting): 39 Test infrastructure to seed the observer with test data. 40 * WebProcess/WebCoreSupport/WebResourceLoadObserver.h: 41 * WebProcess/WebProcess.cpp: 42 (WebKit::WebProcess::setWebsiteDataStoreParameters): 43 Now checks whether a shared observer already exists before setting one. 44 (WebKit::WebProcess::removeWebPage): 45 (WebKit::WebProcess::prepareToSuspend): 46 These two functions now call WebProcess::flushResourceLoadStatistics(). 47 (WebKit::WebProcess::setResourceLoadStatisticsEnabled): 48 This function now sets the process' shared WebCore::ResourceLoadObserver if none exists. 49 (WebKit::WebProcess::flushResourceLoadStatistics): 50 This function tells the shared WebCore::ResourceLoadObserver to send any pending 51 statistics to the central ITP store. 52 (WebKit::WebProcess::seedResourceLoadStatisticsForTesting): 53 Test infrastructure to seed the shared observer with test data. 54 * WebProcess/WebProcess.h: 55 * WebProcess/WebProcess.messages.in: 56 1 57 2019-11-04 Chris Dumez <cdumez@apple.com> 2 58 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r251672 r252014 274 274 // coming from IPC. ResourceLoadStatistics only contains strings which are safe to move to other threads as long 275 275 // as nobody on this thread holds a reference to those strings. 276 postTask([this, statistics = WTFMove(statistics)]() mutable {276 postTask([this, protectedThis = makeRef(*this), statistics = WTFMove(statistics)]() mutable { 277 277 if (!m_statisticsStore) 278 278 return; … … 284 284 285 285 // Fire before processing statistics to propagate user interaction as fast as possible to the network process. 286 m_statisticsStore->updateCookieBlocking([]() { }); 286 m_statisticsStore->updateCookieBlocking([this, protectedThis = protectedThis.copyRef()]() { 287 postTaskReply([this, protectedThis = protectedThis.copyRef()]() { 288 logTestingEvent("Statistics Updated"_s); 289 }); 290 }); 287 291 m_statisticsStore->processStatisticsAndDataRecords(); 288 292 }); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
r251067 r252014 50 50 #import <WebCore/CertificateInfo.h> 51 51 #import <WebCore/PluginData.h> 52 #import <WebCore/RegistrableDomain.h> 52 53 #import <pal/spi/cf/CFNetworkSPI.h> 53 54 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> … … 654 655 } 655 656 657 - (void)_seedResourceLoadStatisticsForTestingWithFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL shouldScheduleNotification:(BOOL)shouldScheduleNotification completionHandler:(void(^)(void))completionHandler 658 { 659 #if ENABLE(RESOURCE_LOAD_STATISTICS) 660 _processPool->seedResourceLoadStatisticsForTesting(WebCore::RegistrableDomain { firstPartyURL }, WebCore::RegistrableDomain { thirdPartyURL }, shouldScheduleNotification, [completionHandler = makeBlockPtr(completionHandler)] () { 661 completionHandler(); 662 }); 663 #else 664 UNUSED_PARAM(firstPartyURL); 665 UNUSED_PARAM(thirdPartyURL); 666 UNUSED_PARAM(shouldScheduleNotification); 667 UNUSED_PARAM(completionHandler); 668 #endif 669 } 670 656 671 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
r251067 r252014 133 133 - (void)_synthesizeAppIsBackground:(BOOL)background WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 134 134 135 // Test only. 136 - (void)_seedResourceLoadStatisticsForTestingWithFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL shouldScheduleNotification:(BOOL)shouldScheduleNotification completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 137 135 138 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r251687 r252014 30 30 #import "AuthenticationChallengeDispositionCocoa.h" 31 31 #import "CompletionHandlerCallChecker.h" 32 #import "ShouldGrandfatherStatistics.h" 32 33 #import "WKHTTPCookieStoreInternal.h" 33 34 #import "WKNSArray.h" … … 496 497 } 497 498 499 - (void)_clearResourceLoadStatistics:(void (^)(void))completionHandler 500 { 501 #if ENABLE(RESOURCE_LOAD_STATISTICS) 502 _websiteDataStore->scheduleClearInMemoryAndPersistent(WebKit::ShouldGrandfatherStatistics::No, [completionHandler = makeBlockPtr(completionHandler)]() { 503 completionHandler(); 504 }); 505 #else 506 completionHandler(); 507 #endif 508 } 509 510 - (void)_isRegisteredAsSubresourceUnderFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler 511 { 512 #if ENABLE(RESOURCE_LOAD_STATISTICS) 513 _websiteDataStore->isRegisteredAsSubresourceUnder(thirdPartyURL, firstPartyURL, [completionHandler = makeBlockPtr(completionHandler)](bool enabled) { 514 completionHandler(enabled); 515 }); 516 #else 517 completionHandler(NO); 518 #endif 519 } 520 498 521 - (void)_processStatisticsAndDataRecords:(void (^)(void))completionHandler 499 522 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
r251687 r252014 71 71 - (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 72 72 - (void)_getIsPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 73 - (void)_clearPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler; 73 - (void)_clearPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 74 - (void)_clearResourceLoadStatistics:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 75 - (void)_isRegisteredAsSubresourceUnderFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 74 76 - (void)_processStatisticsAndDataRecords:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 75 77 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r252011 r252014 90 90 #include <WebCore/ProcessIdentifier.h> 91 91 #include <WebCore/ProcessWarming.h> 92 #include <WebCore/RegistrableDomain.h> 92 93 #include <WebCore/RegistrationDatabase.h> 93 94 #include <WebCore/ResourceRequest.h> 94 95 #include <WebCore/RuntimeApplicationChecks.h> 95 96 #include <pal/SessionID.h> 97 #include <wtf/CallbackAggregator.h> 96 98 #include <wtf/Language.h> 97 99 #include <wtf/MainThread.h> … … 2277 2279 m_networkProcess->didCommitCrossSiteLoadWithDataTransfer(sessionID, fromDomain, toDomain, navigationDataTransfer, webPageProxyID, webPageID); 2278 2280 } 2281 2282 void WebProcessPool::seedResourceLoadStatisticsForTesting(const RegistrableDomain& firstPartyDomain, const RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&& completionHandler) 2283 { 2284 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 2285 2286 for (auto& process : processes()) 2287 process->sendWithAsyncReply(Messages::WebProcess::SeedResourceLoadStatisticsForTesting(firstPartyDomain, thirdPartyDomain, shouldScheduleNotification), [callbackAggregator = callbackAggregator.copyRef()] { }); 2288 } 2279 2289 #endif 2280 2290 -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r252011 r252014 46 46 #include <WebCore/CrossSiteNavigationDataTransfer.h> 47 47 #include <WebCore/ProcessIdentifier.h> 48 #include <WebCore/RegistrableDomain.h>49 48 #include <WebCore/SecurityOriginHash.h> 50 49 #include <WebCore/SharedStringHash.h> … … 91 90 92 91 namespace WebCore { 92 class RegistrableDomain; 93 93 struct MockMediaDevice; 94 94 } … … 496 496 #if ENABLE(RESOURCE_LOAD_STATISTICS) 497 497 void didCommitCrossSiteLoadWithDataTransfer(PAL::SessionID, const WebCore::RegistrableDomain& fromDomain, const WebCore::RegistrableDomain& toDomain, OptionSet<WebCore::CrossSiteNavigationDataTransfer::Flag>, WebPageProxyIdentifier, WebCore::PageIdentifier); 498 void seedResourceLoadStatisticsForTesting(const WebCore::RegistrableDomain& firstPartyDomain, const WebCore::RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&&); 498 499 #endif 499 500 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r251222 r252014 1370 1370 ASSERT(processPools().size() == 1); 1371 1371 break; 1372 } else { 1373 ASSERT_NOT_REACHED(); 1374 completionHandler(false); 1375 break; 1372 1376 } 1373 1377 } … … 1962 1966 resolveDirectoriesIfNecessary(); 1963 1967 1964 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) 1968 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { 1965 1969 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true)); 1966 return; 1967 } 1968 1969 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) 1970 processPool->sendToAllProcesses(Messages::WebProcess::SetResourceLoadStatisticsEnabled(true)); 1971 } 1972 return; 1973 } 1974 1975 for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { 1970 1976 processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false)); 1977 processPool->sendToAllProcesses(Messages::WebProcess::SetResourceLoadStatisticsEnabled(false)); 1978 } 1971 1979 1972 1980 m_resourceLoadStatisticsEnabled = false; -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp
r250579 r252014 66 66 } 67 67 68 WebResourceLoadObserver::~WebResourceLoadObserver() 69 { 70 if (hasStatistics()) 71 updateCentralStatisticsStore(); 72 } 73 68 74 void WebResourceLoadObserver::requestStorageAccessUnderOpener(const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument) 69 75 { … … 357 363 } 358 364 365 void WebResourceLoadObserver::logSubresourceLoadingForTesting(const RegistrableDomain& firstPartyDomain, const RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification) 366 { 367 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(thirdPartyDomain); 368 auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now()); 369 targetStatistics.lastSeen = lastSeen; 370 targetStatistics.subresourceUnderTopFrameDomains.add(firstPartyDomain); 371 372 if (shouldScheduleNotification) 373 scheduleNotificationIfNeeded(); 374 else 375 m_notificationTimer.stop(); 376 } 377 359 378 } // namespace WebKit 360 379 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h
r249920 r252014 38 38 public: 39 39 WebResourceLoadObserver(); 40 40 ~WebResourceLoadObserver(); 41 41 42 void logSubresourceLoading(const WebCore::Frame*, const WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse) final; 42 43 void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL) final; … … 47 48 void logNavigatorAPIAccessed(const WebCore::Document&, const WebCore::ResourceLoadStatistics::NavigatorAPI) final; 48 49 void logScreenAPIAccessed(const WebCore::Document&, const WebCore::ResourceLoadStatistics::ScreenAPI) final; 50 void logSubresourceLoadingForTesting(const WebCore::RegistrableDomain& firstPartyDomain, const WebCore::RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification); 49 51 50 52 #if !RELEASE_LOG_DISABLED -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r251814 r252014 459 459 460 460 #if ENABLE(RESOURCE_LOAD_STATISTICS) 461 if (parameters.resourceLoadStatisticsEnabled && !parameters.sessionID.isEphemeral() )461 if (parameters.resourceLoadStatisticsEnabled && !parameters.sessionID.isEphemeral() && !ResourceLoadObserver::sharedIfExists()) 462 462 ResourceLoadObserver::setShared(*new WebResourceLoadObserver); 463 463 #endif … … 671 671 { 672 672 ASSERT(m_pageMap.contains(pageID)); 673 674 flushResourceLoadStatistics(); 673 675 674 676 pageWillLeaveWindow(pageID); … … 1384 1386 m_processIsSuspended = true; 1385 1387 1388 flushResourceLoadStatistics(); 1389 1386 1390 #if PLATFORM(COCOA) 1387 1391 if (m_processType == ProcessType::PrewarmedWebContent) { … … 1553 1557 void WebProcess::setResourceLoadStatisticsEnabled(bool enabled) 1554 1558 { 1559 if (WebCore::DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() == enabled || m_sessionID->isEphemeral()) 1560 return; 1555 1561 WebCore::DeprecatedGlobalSettings::setResourceLoadStatisticsEnabled(enabled); 1562 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1563 if (enabled && !ResourceLoadObserver::sharedIfExists()) 1564 WebCore::ResourceLoadObserver::setShared(*new WebResourceLoadObserver); 1565 #endif 1556 1566 } 1557 1567 … … 1562 1572 observer->clearState(); 1563 1573 #endif 1574 } 1575 1576 void WebProcess::flushResourceLoadStatistics() 1577 { 1578 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1579 if (auto* observer = ResourceLoadObserver::sharedIfExists()) 1580 observer->updateCentralStatisticsStore(); 1581 #endif 1582 } 1583 1584 void WebProcess::seedResourceLoadStatisticsForTesting(const RegistrableDomain& firstPartyDomain, const RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&& completionHandler) 1585 { 1586 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1587 if (auto* observer = ResourceLoadObserver::sharedIfExists()) 1588 observer->logSubresourceLoadingForTesting(firstPartyDomain, thirdPartyDomain, shouldScheduleNotification); 1589 #endif 1590 completionHandler(); 1564 1591 } 1565 1592 -
trunk/Source/WebKit/WebProcess/WebProcess.h
r251814 r252014 88 88 class CertificateInfo; 89 89 class PageGroup; 90 class RegistrableDomain; 90 91 class ResourceRequest; 91 92 class UserGestureToken; … … 347 348 void setResourceLoadStatisticsEnabled(bool); 348 349 void clearResourceLoadStatistics(); 350 void flushResourceLoadStatistics(); 351 void seedResourceLoadStatisticsForTesting(const WebCore::RegistrableDomain& firstPartyDomain, const WebCore::RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&&); 349 352 void userPreferredLanguagesChanged(const Vector<String>&) const; 350 353 void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled); -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r251814 r252014 161 161 SendMessageToWebExtension(struct WebKit::UserMessage userMessage) 162 162 #endif 163 164 #if ENABLE(RESOURCE_LOAD_STATISTICS) 165 SeedResourceLoadStatisticsForTesting(WebCore::RegistrableDomain firstPartyDomain, WebCore::RegistrableDomain thirdPartyDomain, bool shouldScheduleNotification) -> () Async 166 #endif 163 167 } -
trunk/Tools/ChangeLog
r252012 r252014 1 2019-11-04 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Flush the shared ResourceLoadObserver when the webpage is closed by JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=203623 5 <rdar://problem/56756427> 6 7 Reviewed by Alex Christensen. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm: 10 (TEST): 11 1 12 2019-11-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm
r248144 r252014 485 485 EXPECT_FALSE([WKWebsiteDataStore _defaultDataStoreExists]); 486 486 } 487 488 TEST(ResourceLoadStatistics, FlushObserverWhenWebPageIsClosedByJavaScript) 489 { 490 auto *sharedProcessPool = [WKProcessPool _sharedProcessPool]; 491 auto *dataStore = [WKWebsiteDataStore defaultDataStore]; 492 493 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 494 [configuration setProcessPool: sharedProcessPool]; 495 configuration.get().websiteDataStore = dataStore; 496 497 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 498 499 [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; 500 [webView _test_waitForDidFinishNavigation]; 501 502 [dataStore _setResourceLoadStatisticsEnabled:YES]; 503 504 static bool doneFlag = false; 505 [dataStore _clearResourceLoadStatistics:^(void) { 506 doneFlag = true; 507 }]; 508 509 static bool statisticsUpdated = false; 510 [dataStore _setResourceLoadStatisticsTestingCallback:^(WKWebsiteDataStore *, NSString *message) { 511 if (![message isEqualToString:@"Statistics Updated"]) 512 return; 513 statisticsUpdated = true; 514 }]; 515 516 TestWebKitAPI::Util::run(&doneFlag); 517 518 // Seed test data in the web process' observer. 519 doneFlag = false; 520 [sharedProcessPool _seedResourceLoadStatisticsForTestingWithFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil.com"] shouldScheduleNotification:NO completionHandler: ^() { 521 doneFlag = true; 522 }]; 523 524 TestWebKitAPI::Util::run(&doneFlag); 525 526 // Check that the third-party is not yet registered. 527 doneFlag = false; 528 [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL isRegistered) { 529 EXPECT_FALSE(isRegistered); 530 doneFlag = true; 531 }]; 532 533 TestWebKitAPI::Util::run(&doneFlag); 534 535 statisticsUpdated = false; 536 [webView loadHTMLString:@"<body><script>close();</script></body>" baseURL:[NSURL URLWithString:@"http://webkit.org"]]; 537 538 // Wait for the statistics to be updated in the network process. 539 TestWebKitAPI::Util::run(&statisticsUpdated); 540 541 // Check that the third-party is now registered. 542 doneFlag = false; 543 [dataStore _isRegisteredAsSubresourceUnderFirstParty:[NSURL URLWithString:@"http://webkit.org"] thirdParty:[NSURL URLWithString:@"http://evil.com"] completionHandler: ^(BOOL isRegistered) { 544 EXPECT_TRUE(isRegistered); 545 doneFlag = true; 546 }]; 547 548 TestWebKitAPI::Util::run(&doneFlag); 549 }
Note: See TracChangeset
for help on using the changeset viewer.