Changeset 228304 in webkit


Ignore:
Timestamp:
Feb 8, 2018 5:32:55 PM (6 years ago)
Author:
Michael Catanzaro
Message:

TestController should not exercise cocoa-specific resource load statistics APIs
https://bugs.webkit.org/show_bug.cgi?id=182355

Reviewed by Alex Christensen.

Source/WebKit:

Remove the Cocoa testing SPI, since it's redundant with the C API. Also, add a couple
missing cookie partitioning callbacks to the C API.

  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreStatisticsUpdateCookiePartitioning):
(WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost):

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/API/Cocoa/WKWebsiteDataStore.mm:

(-[WKWebsiteDataStore _resourceLoadStatisticsSetLastSeen:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetIsPrevalentResource:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsIsPrevalentResource:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsIsRegisteredAsSubFrameUnder:topFrameHost:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsIsRegisteredAsRedirectingTo:hostRedirectedTo:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetHadUserInteraction:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsHadUserInteraction:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetIsGrandfathered:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsIsGrandfathered:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetSubresourceUniqueRedirectTo:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetTimeToLiveUserInteraction:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetGrandfatheringTime:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSubmitTelemetry]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:completionHandler:]): Deleted.
(-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]): Deleted.

  • UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:

Tools:

Remove unnecessary use of platform-specific APIs in the TestController, since there are
cross-platform APIs to do the same thing.

Also, ensure callbacks execute before returning from TestController's functions, since
otherwise the tests are guaranteed to be flaky at best, and also since there's nothing to
prevent the TestController from being destroyed before the callbacks execute.

  • WebKitTestRunner/TestController.cpp:

(WTR::resourceStatisticsVoidResultCallback):
(WTR::resourceStatisticsBooleanResultCallback):
(WTR::TestController::isStatisticsPrevalentResource):
(WTR::TestController::isStatisticsRegisteredAsSubFrameUnder):
(WTR::TestController::isStatisticsRegisteredAsRedirectingTo):
(WTR::TestController::isStatisticsHasHadUserInteraction):
(WTR::TestController::isStatisticsGrandfathered):
(WTR::TestController::statisticsUpdateCookiePartitioning):
(WTR::TestController::statisticsSetShouldPartitionCookiesForHost):
(WTR::TestController::statisticsClearInMemoryAndPersistentStore):
(WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
(WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
(WTR::resourceStatisticsCallback): Deleted.
(WTR::TestController::statisticsClearThroughWebsiteDataRemovalCallback): Deleted.

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/cocoa/TestControllerCocoa.mm:

(WTR::toNSString): Deleted.
(WTR::TestController::setStatisticsLastSeen): Deleted.
(WTR::TestController::setStatisticsPrevalentResource): Deleted.
(WTR::TestController::isStatisticsPrevalentResource): Deleted.
(WTR::TestController::isStatisticsRegisteredAsSubFrameUnder): Deleted.
(WTR::TestController::isStatisticsRegisteredAsRedirectingTo): Deleted.
(WTR::TestController::setStatisticsHasHadUserInteraction): Deleted.
(WTR::TestController::setStatisticsHasHadNonRecentUserInteraction): Deleted.
(WTR::TestController::isStatisticsHasHadUserInteraction): Deleted.
(WTR::TestController::setStatisticsGrandfathered): Deleted.
(WTR::TestController::isStatisticsGrandfathered): Deleted.
(WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin): Deleted.
(WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin): Deleted.
(WTR::TestController::setStatisticsSubresourceUniqueRedirectTo): Deleted.
(WTR::TestController::setStatisticsTimeToLiveUserInteraction): Deleted.
(WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree): Deleted.
(WTR::TestController::statisticsProcessStatisticsAndDataRecords): Deleted.
(WTR::TestController::statisticsUpdateCookiePartitioning): Deleted.
(WTR::TestController::statisticsSetShouldPartitionCookiesForHost): Deleted.
(WTR::TestController::statisticsSubmitTelemetry): Deleted.
(WTR::TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned): Deleted.
(WTR::TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval): Deleted.
(WTR::TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured): Deleted.
(WTR::TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval): Deleted.
(WTR::TestController::setStatisticsGrandfatheringTime): Deleted.
(WTR::TestController::setStatisticsMaxStatisticsEntries): Deleted.
(WTR::TestController::setStatisticsPruneEntriesDownTo): Deleted.
(WTR::TestController::statisticsClearInMemoryAndPersistentStore): Deleted.
(WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours): Deleted.
(WTR::TestController::statisticsClearThroughWebsiteDataRemoval): Deleted.
(WTR::TestController::statisticsResetToConsistentState): Deleted.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228302 r228304  
     12018-02-08  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        TestController should not exercise cocoa-specific resource load statistics APIs
     4        https://bugs.webkit.org/show_bug.cgi?id=182355
     5
     6        Reviewed by Alex Christensen.
     7
     8        Remove the Cocoa testing SPI, since it's redundant with the C API. Also, add a couple
     9        missing cookie partitioning callbacks to the C API.
     10
     11        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     12        (WKWebsiteDataStoreStatisticsUpdateCookiePartitioning):
     13        (WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost):
     14        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     15        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
     16        (-[WKWebsiteDataStore _resourceLoadStatisticsSetLastSeen:forHost:]): Deleted.
     17        (-[WKWebsiteDataStore _resourceLoadStatisticsSetIsPrevalentResource:forHost:]): Deleted.
     18        (-[WKWebsiteDataStore _resourceLoadStatisticsIsPrevalentResource:completionHandler:]): Deleted.
     19        (-[WKWebsiteDataStore _resourceLoadStatisticsIsRegisteredAsSubFrameUnder:topFrameHost:completionHandler:]): Deleted.
     20        (-[WKWebsiteDataStore _resourceLoadStatisticsIsRegisteredAsRedirectingTo:hostRedirectedTo:completionHandler:]): Deleted.
     21        (-[WKWebsiteDataStore _resourceLoadStatisticsSetHadUserInteraction:forHost:]): Deleted.
     22        (-[WKWebsiteDataStore _resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:]): Deleted.
     23        (-[WKWebsiteDataStore _resourceLoadStatisticsHadUserInteraction:completionHandler:]): Deleted.
     24        (-[WKWebsiteDataStore _resourceLoadStatisticsSetIsGrandfathered:forHost:]): Deleted.
     25        (-[WKWebsiteDataStore _resourceLoadStatisticsIsGrandfathered:completionHandler:]): Deleted.
     26        (-[WKWebsiteDataStore _resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:forHost:]): Deleted.
     27        (-[WKWebsiteDataStore _resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:forHost:]): Deleted.
     28        (-[WKWebsiteDataStore _resourceLoadStatisticsSetSubresourceUniqueRedirectTo:forHost:]): Deleted.
     29        (-[WKWebsiteDataStore _resourceLoadStatisticsSetTimeToLiveUserInteraction:]): Deleted.
     30        (-[WKWebsiteDataStore _resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:]): Deleted.
     31        (-[WKWebsiteDataStore _resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:]): Deleted.
     32        (-[WKWebsiteDataStore _resourceLoadStatisticsSetGrandfatheringTime:]): Deleted.
     33        (-[WKWebsiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:]): Deleted.
     34        (-[WKWebsiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:]): Deleted.
     35        (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]): Deleted.
     36        (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]): Deleted.
     37        (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning:]): Deleted.
     38        (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]): Deleted.
     39        (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:completionHandler:]): Deleted.
     40        (-[WKWebsiteDataStore _resourceLoadStatisticsSubmitTelemetry]): Deleted.
     41        (-[WKWebsiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:]): Deleted.
     42        (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:]): Deleted.
     43        (-[WKWebsiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:]): Deleted.
     44        (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]): Deleted.
     45        (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore:]): Deleted.
     46        (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]): Deleted.
     47        (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:completionHandler:]): Deleted.
     48        (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]): Deleted.
     49        * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
     50
    1512018-02-08  Don Olmstead  <don.olmstead@sony.com>
    252
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r228025 r228304  
    239239}
    240240
    241 void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef)
    242 {
    243     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    244     if (!store)
    245         return;
    246 
    247     store->scheduleCookiePartitioningUpdate([]() { });
    248 }
    249 
    250 void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
     241void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookiePartitioningFunction callback)
     242{
     243    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     244    if (!store)
     245        return;
     246
     247    store->scheduleCookiePartitioningUpdate([context, callback]() {
     248        callback(context);
     249    });
     250}
     251
     252void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction callback)
    251253{
    252254    auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
     
    255257
    256258    if (value)
    257         store->scheduleCookiePartitioningUpdateForDomains({ WebKit::toImpl(host)->string() }, { }, { }, WebKit::ShouldClearFirst::No, []() { });
     259        store->scheduleCookiePartitioningUpdateForDomains({ WebKit::toImpl(host)->string() }, { }, { }, WebKit::ShouldClearFirst::No, [context, callback]() {
     260            callback(context);
     261        });
    258262    else
    259         store->scheduleClearPartitioningStateForDomains({ WebKit::toImpl(host)->string() }, []() { });
     263        store->scheduleClearPartitioningStateForDomains({ WebKit::toImpl(host)->string() }, [context, callback]() {
     264            callback(context);
     265        });
    260266}
    261267
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r228025 r228304  
    6262WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds);
    6363WK_EXPORT void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef);
    64 WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef);
    65 WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
     64typedef void (*WKWebsiteDataStoreStatisticsUpdateCookiePartitioningFunction)(void* functionContext);
     65WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookiePartitioningFunction callback);
     66typedef void (*WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction)(void* functionContext);
     67WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction callback);
    6668WK_EXPORT void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef);
    6769WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value);
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm

    r228109 r228304  
    296296}
    297297
    298 - (void)_resourceLoadStatisticsSetLastSeen:(double)seconds forHost:(NSString *)host
     298- (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value
    299299{
    300300    auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    301301    if (!store)
    302302        return;
    303    
    304     store->setLastSeen(URL(URL(), host), Seconds { seconds });
    305 }
    306 
    307 - (void)_resourceLoadStatisticsSetIsPrevalentResource:(BOOL)value forHost:(NSString *)host
    308 {
    309     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    310     if (!store)
    311         return;
    312 
    313     if (value)
    314         store->setPrevalentResource(URL(URL(), host));
    315     else
    316         store->clearPrevalentResource(URL(URL(), host));
    317 }
    318 
    319 - (void)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
    320 {
    321     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    322     if (!store) {
    323         completionHandler(NO);
    324         return;
    325     }
    326 
    327     auto completionHandlerCopy = makeBlockPtr(completionHandler);
    328     store->isPrevalentResource(URL(URL(), host), [completionHandlerCopy](bool isPrevalentResource) {
    329         completionHandlerCopy(isPrevalentResource);
    330     });
    331 }
    332 
    333 - (void)_resourceLoadStatisticsIsRegisteredAsSubFrameUnder:(NSString *)subFrameHost topFrameHost:(NSString *)topFrameHost completionHandler:(void (^)(BOOL))completionHandler
    334 {
    335     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    336     if (!store) {
    337         completionHandler(NO);
    338         return;
    339     }
    340    
    341     auto completionHandlerCopy = makeBlockPtr(completionHandler);
    342     store->isRegisteredAsSubFrameUnder(URL(URL(), subFrameHost), URL(URL(), topFrameHost), [completionHandlerCopy](bool isRegisteredAsSubFrameUnder) {
    343         completionHandlerCopy(isRegisteredAsSubFrameUnder);
    344     });
    345 }
    346 
    347 - (void)_resourceLoadStatisticsIsRegisteredAsRedirectingTo:(NSString *)hostRedirectedFrom hostRedirectedTo:(NSString *)hostRedirectedTo completionHandler:(void (^)(BOOL))completionHandler
    348 {
    349     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    350     if (!store) {
    351         completionHandler(NO);
    352         return;
    353     }
    354    
    355     auto completionHandlerCopy = makeBlockPtr(completionHandler);
    356     store->isRegisteredAsRedirectingTo(URL(URL(), hostRedirectedFrom), URL(URL(), hostRedirectedTo), [completionHandlerCopy](bool isRegisteredAsRedirectingTo) {
    357         completionHandlerCopy(isRegisteredAsRedirectingTo);
    358     });
    359 }
    360 
    361 - (void)_resourceLoadStatisticsSetHadUserInteraction:(BOOL)value forHost:(NSString *)host
    362 {
    363     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    364     if (!store)
    365         return;
    366 
    367     if (value)
    368         store->logUserInteraction(URL(URL(), host));
    369     else
    370         store->clearUserInteraction(URL(URL(), host));
    371 }
    372 
    373 - (void)_resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:(NSString *)host
    374 {
    375     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    376     if (!store)
    377         return;
    378    
    379     store->logNonRecentUserInteraction(URL(URL(), host));
    380 }
    381 
    382 - (void)_resourceLoadStatisticsHadUserInteraction:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
    383 {
    384     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    385     if (!store) {
    386         completionHandler(NO);
    387         return;
    388     }
    389 
    390     auto completionHandlerCopy = makeBlockPtr(completionHandler);
    391     store->hasHadUserInteraction(URL(URL(), host), [completionHandlerCopy](bool hasHadUserInteraction) {
    392         completionHandlerCopy(hasHadUserInteraction);
    393     });
    394 }
    395 
    396 - (void)_resourceLoadStatisticsSetIsGrandfathered:(BOOL)value forHost:(NSString *)host
    397 {
    398     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    399     if (!store)
    400         return;
    401 
    402     store->setGrandfathered(URL(URL(), host), value);
    403 }
    404 
    405 - (void)_resourceLoadStatisticsIsGrandfathered:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler
    406 {
    407     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    408     if (!store) {
    409         completionHandler(NO);
    410         return;
    411     }
    412 
    413     auto completionHandlerCopy = makeBlockPtr(completionHandler);
    414     store->isGrandfathered(URL(URL(), host), [completionHandlerCopy](bool isGrandfathered) {
    415         completionHandlerCopy(isGrandfathered);
    416     });
    417 }
    418 
    419 - (void)_resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host
    420 {
    421     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    422     if (!store)
    423         return;
    424 
    425     store->setSubframeUnderTopFrameOrigin(URL(URL(), host), URL(URL(), topFrameHostName));
    426 }
    427 
    428 - (void)_resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host
    429 {
    430     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    431     if (!store)
    432         return;
    433 
    434     store->setSubresourceUnderTopFrameOrigin(URL(URL(), host), URL(URL(), topFrameHostName));
    435 }
    436 
    437 - (void)_resourceLoadStatisticsSetSubresourceUniqueRedirectTo:(NSString *)hostNameRedirectedTo forHost:(NSString *)host
    438 {
    439     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    440     if (!store)
    441         return;
    442 
    443     store->setSubresourceUniqueRedirectTo(URL(URL(), host), URL(URL(), hostNameRedirectedTo));
    444 }
    445 
    446 - (void)_resourceLoadStatisticsSetTimeToLiveUserInteraction:(double)seconds
    447 {
    448     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    449     if (!store)
    450         return;
    451 
    452     store->setTimeToLiveUserInteraction(Seconds { seconds });
    453 }
    454 
    455 - (void)_resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:(double)seconds
    456 {
    457     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    458     if (!store)
    459         return;
    460 
    461     store->setTimeToLiveCookiePartitionFree(Seconds { seconds });
    462 }
    463 
    464 - (void)_resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:(double)seconds
    465 {
    466     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    467     if (!store)
    468         return;
    469 
    470     store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds });
    471 }
    472 
    473 - (void)_resourceLoadStatisticsSetGrandfatheringTime:(double)seconds
    474 {
    475     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    476     if (!store)
    477         return;
    478 
    479     store->setGrandfatheringTime(Seconds {seconds });
    480 }
    481 
    482 - (void)_resourceLoadStatisticsSetMaxStatisticsEntries:(size_t)entries
    483 {
    484     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    485     if (!store)
    486         return;
    487 
    488     store->setMaxStatisticsEntries(entries);
    489 }
    490 
    491 - (void)_resourceLoadStatisticsSetPruneEntriesDownTo:(size_t)entries
    492 {
    493     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    494     if (!store)
    495         return;
    496 
    497     store->setPruneEntriesDownTo(entries);
    498 }
    499 
    500 - (void)_resourceLoadStatisticsProcessStatisticsAndDataRecords
    501 {
    502     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    503     if (!store)
    504         return;
    505 
    506     store->scheduleStatisticsAndDataRecordsProcessing();
    507 }
    508 
    509 - (void)_resourceLoadStatisticsUpdateCookiePartitioning
    510 {
    511     [self _resourceLoadStatisticsUpdateCookiePartitioning:^() { }];
    512 }
    513 
    514 - (void)_resourceLoadStatisticsUpdateCookiePartitioning:(void (^)())completionHandler
    515 {
    516     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    517     if (!store) {
    518         completionHandler();
    519         return;
    520     }
    521    
    522     store->scheduleCookiePartitioningUpdate([completionHandler = makeBlockPtr(completionHandler)]() {
    523         completionHandler();
    524     });
    525 }
    526 
    527 - (void)_resourceLoadStatisticsSetShouldPartitionCookies:(BOOL)value forHost:(NSString *)host
    528 {
    529     [self _resourceLoadStatisticsSetShouldPartitionCookies:value forHost:host completionHandler:^() { }];
    530 }
    531 
    532 - (void)_resourceLoadStatisticsSetShouldPartitionCookies:(BOOL)value forHost:(NSString *)host completionHandler:(void (^)())completionHandler
    533 {
    534     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    535     if (!store) {
    536         completionHandler();
    537         return;
    538     }
    539 
    540     if (value)
    541         store->scheduleCookiePartitioningUpdateForDomains({ host }, { }, { }, WebKit::ShouldClearFirst::No, [completionHandler = makeBlockPtr(completionHandler)]() {
    542             completionHandler();
    543         });
    544     else
    545         store->scheduleClearPartitioningStateForDomains({ host }, [completionHandler = makeBlockPtr(completionHandler)]() {
    546             completionHandler();
    547         });
    548 }
    549 
    550 - (void)_resourceLoadStatisticsSubmitTelemetry
    551 {
    552     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    553     if (!store)
    554         return;
    555 
    556     store->submitTelemetry();
    557 }
    558 
    559 - (void)_resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:(BOOL)value
    560 {
    561     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    562     if (!store)
    563         return;
    564 
    565     store->setNotifyPagesWhenDataRecordsWereScanned(value);
    566 }
    567 
    568 - (void)_resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:(BOOL)value
    569 {
    570     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    571     if (!store)
    572         return;
    573 
    574     store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
    575 }
    576 
    577 - (void)_resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:(BOOL)value
    578 {
    579     WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
    580 }
    581 
    582 - (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value
    583 {
    584     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    585     if (!store)
    586         return;
    587303
    588304    store->setShouldSubmitTelemetry(value);
    589 }
    590 
    591 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore
    592 {
    593     [self _resourceLoadStatisticsClearInMemoryAndPersistentStore:^() { }];
    594 }
    595 
    596 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore:(void (^)())completionHandler
    597 {
    598     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    599     if (!store) {
    600         completionHandler();
    601         return;
    602     }
    603 
    604     store->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [completionHandler = makeBlockPtr(completionHandler)]() {
    605         completionHandler();
    606     });
    607 }
    608 
    609 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours
    610 {
    611     [self _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:hours completionHandler:^() { }];
    612 }
    613 
    614 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours completionHandler:(void (^)())completionHandler
    615 {
    616     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    617     if (!store) {
    618         completionHandler();
    619         return;
    620     }
    621 
    622     store->scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [completionHandler = makeBlockPtr(completionHandler)]() {
    623         completionHandler();
    624     });
    625 }
    626 
    627 - (void)_resourceLoadStatisticsResetToConsistentState
    628 {
    629     WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(false);
    630 
    631     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    632     if (!store)
    633         return;
    634 
    635     store->resetParametersToDefaultValues();
    636     store->scheduleClearInMemory();
    637305}
    638306
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h

    r228109 r228304  
    5454@property (nonatomic, setter=_setAllowsCellularAccess:) BOOL _allowsCellularAccess WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    5555
    56 // ResourceLoadStatistics SPI for testing.
    57 - (void)_resourceLoadStatisticsSetLastSeen:(double)seconds forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    58 - (void)_resourceLoadStatisticsSetIsPrevalentResource:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    59 - (void)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    60 - (void)_resourceLoadStatisticsIsRegisteredAsSubFrameUnder:(NSString *)subFrameHost topFrameHost:(NSString *)topFrameHost completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    61 - (void)_resourceLoadStatisticsIsRegisteredAsRedirectingTo:(NSString *)hostRedirectedFrom hostRedirectedTo:(NSString *)hostRedirectedTo completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    62 - (void)_resourceLoadStatisticsSetHadUserInteraction:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    63 - (void)_resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:(NSString *)host WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    64 - (void)_resourceLoadStatisticsHadUserInteraction:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    65 - (void)_resourceLoadStatisticsSetIsGrandfathered:(BOOL)value forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    66 - (void)_resourceLoadStatisticsIsGrandfathered:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    67 - (void)_resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    68 - (void)_resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:(NSString *)topFrameHostName forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    69 - (void)_resourceLoadStatisticsSetSubresourceUniqueRedirectTo:(NSString *)hostNameRedirectedTo forHost:(NSString *)host WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    70 - (void)_resourceLoadStatisticsSetTimeToLiveUserInteraction:(double)seconds WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    71 - (void)_resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:(double)seconds WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    72 - (void)_resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:(double)seconds WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    73 - (void)_resourceLoadStatisticsSetGrandfatheringTime:(double)seconds WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    74 - (void)_resourceLoadStatisticsSetMaxStatisticsEntries:(size_t)entries WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    75 - (void)_resourceLoadStatisticsSetPruneEntriesDownTo:(size_t)entries WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    76 - (void)_resourceLoadStatisticsProcessStatisticsAndDataRecords WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    77 - (void)_resourceLoadStatisticsUpdateCookiePartitioning WK_API_DEPRECATED_WITH_REPLACEMENT("_resourceLoadStatisticsUpdateCookiePartitioning", macosx(10.13, WK_MAC_TBA), ios(11.0, WK_IOS_TBA));
    78 - (void)_resourceLoadStatisticsUpdateCookiePartitioning:(void (^)(void))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    79 - (void)_resourceLoadStatisticsSetShouldPartitionCookies:(BOOL)value forHost:(NSString *)host WK_API_DEPRECATED_WITH_REPLACEMENT("_resourceLoadStatisticsSetShouldPartitionCookies", macosx(10.13, WK_MAC_TBA), ios(11.0, WK_IOS_TBA));
    80 - (void)_resourceLoadStatisticsSetShouldPartitionCookies:(BOOL)value forHost:(NSString *)host completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    81 - (void)_resourceLoadStatisticsSubmitTelemetry WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    82 - (void)_resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    83 - (void)_resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    84 - (void)_resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    8556- (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    86 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore WK_API_DEPRECATED_WITH_REPLACEMENT("_resourceLoadStatisticsClearInMemoryAndPersistentStore", macosx(10.13, WK_MAC_TBA), ios(11.0, WK_IOS_TBA));
    87 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore:(void (^)(void))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    88 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours WK_API_DEPRECATED_WITH_REPLACEMENT("_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours", macosx(10.13, WK_MAC_TBA), ios(11.0, WK_IOS_TBA));
    89 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    90 - (void)_resourceLoadStatisticsResetToConsistentState WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    9157- (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    9258- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Tools/ChangeLog

    r228303 r228304  
     12018-02-08  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        TestController should not exercise cocoa-specific resource load statistics APIs
     4        https://bugs.webkit.org/show_bug.cgi?id=182355
     5
     6        Reviewed by Alex Christensen.
     7
     8        Remove unnecessary use of platform-specific APIs in the TestController, since there are
     9        cross-platform APIs to do the same thing.
     10
     11        Also, ensure callbacks execute before returning from TestController's functions, since
     12        otherwise the tests are guaranteed to be flaky at best, and also since there's nothing to
     13        prevent the TestController from being destroyed before the callbacks execute.
     14
     15        * WebKitTestRunner/TestController.cpp:
     16        (WTR::resourceStatisticsVoidResultCallback):
     17        (WTR::resourceStatisticsBooleanResultCallback):
     18        (WTR::TestController::isStatisticsPrevalentResource):
     19        (WTR::TestController::isStatisticsRegisteredAsSubFrameUnder):
     20        (WTR::TestController::isStatisticsRegisteredAsRedirectingTo):
     21        (WTR::TestController::isStatisticsHasHadUserInteraction):
     22        (WTR::TestController::isStatisticsGrandfathered):
     23        (WTR::TestController::statisticsUpdateCookiePartitioning):
     24        (WTR::TestController::statisticsSetShouldPartitionCookiesForHost):
     25        (WTR::TestController::statisticsClearInMemoryAndPersistentStore):
     26        (WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
     27        (WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
     28        (WTR::resourceStatisticsCallback): Deleted.
     29        (WTR::TestController::statisticsClearThroughWebsiteDataRemovalCallback): Deleted.
     30        * WebKitTestRunner/TestController.h:
     31        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
     32        (WTR::toNSString): Deleted.
     33        (WTR::TestController::setStatisticsLastSeen): Deleted.
     34        (WTR::TestController::setStatisticsPrevalentResource): Deleted.
     35        (WTR::TestController::isStatisticsPrevalentResource): Deleted.
     36        (WTR::TestController::isStatisticsRegisteredAsSubFrameUnder): Deleted.
     37        (WTR::TestController::isStatisticsRegisteredAsRedirectingTo): Deleted.
     38        (WTR::TestController::setStatisticsHasHadUserInteraction): Deleted.
     39        (WTR::TestController::setStatisticsHasHadNonRecentUserInteraction): Deleted.
     40        (WTR::TestController::isStatisticsHasHadUserInteraction): Deleted.
     41        (WTR::TestController::setStatisticsGrandfathered): Deleted.
     42        (WTR::TestController::isStatisticsGrandfathered): Deleted.
     43        (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin): Deleted.
     44        (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin): Deleted.
     45        (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo): Deleted.
     46        (WTR::TestController::setStatisticsTimeToLiveUserInteraction): Deleted.
     47        (WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree): Deleted.
     48        (WTR::TestController::statisticsProcessStatisticsAndDataRecords): Deleted.
     49        (WTR::TestController::statisticsUpdateCookiePartitioning): Deleted.
     50        (WTR::TestController::statisticsSetShouldPartitionCookiesForHost): Deleted.
     51        (WTR::TestController::statisticsSubmitTelemetry): Deleted.
     52        (WTR::TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned): Deleted.
     53        (WTR::TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval): Deleted.
     54        (WTR::TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured): Deleted.
     55        (WTR::TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval): Deleted.
     56        (WTR::TestController::setStatisticsGrandfatheringTime): Deleted.
     57        (WTR::TestController::setStatisticsMaxStatisticsEntries): Deleted.
     58        (WTR::TestController::setStatisticsPruneEntriesDownTo): Deleted.
     59        (WTR::TestController::statisticsClearInMemoryAndPersistentStore): Deleted.
     60        (WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours): Deleted.
     61        (WTR::TestController::statisticsClearThroughWebsiteDataRemoval): Deleted.
     62        (WTR::TestController::statisticsResetToConsistentState): Deleted.
     63
    1642018-02-08  Jonathan Bedard  <jbedard@apple.com>
    265
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r228218 r228304  
    24732473}
    24742474
    2475 #if !PLATFORM(COCOA) || !WK_API_ENABLED
    2476 
    24772475void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
    24782476{
     
    24982496};
    24992497
    2500 static void resourceStatisticsCallback(bool result, void* userData)
     2498static void resourceStatisticsVoidResultCallback(void* userData)
     2499{
     2500    auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData);
     2501    context->done = true;
     2502    context->testController.notifyDone();
     2503}
     2504
     2505static void resourceStatisticsBooleanResultCallback(bool result, void* userData)
    25012506{
    25022507    auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData);
     
    25102515    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    25112516    ResourceStatisticsCallbackContext context(*this);
    2512     WKWebsiteDataStoreIsStatisticsPrevalentResource(dataStore, host, &context, resourceStatisticsCallback);
     2517    WKWebsiteDataStoreIsStatisticsPrevalentResource(dataStore, host, &context, resourceStatisticsBooleanResultCallback);
    25132518    if (!context.done)
    25142519        runUntil(context.done, m_currentInvocation->shortTimeout());
     
    25202525    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    25212526    ResourceStatisticsCallbackContext context(*this);
    2522     WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(dataStore, subFrameHost, topFrameHost, &context, resourceStatisticsCallback);
     2527    WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(dataStore, subFrameHost, topFrameHost, &context, resourceStatisticsBooleanResultCallback);
    25232528    if (!context.done)
    25242529        runUntil(context.done, m_currentInvocation->shortTimeout());
     
    25302535    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    25312536    ResourceStatisticsCallbackContext context(*this);
    2532     WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(dataStore, hostRedirectedFrom, hostRedirectedTo, &context, resourceStatisticsCallback);
     2537    WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(dataStore, hostRedirectedFrom, hostRedirectedTo, &context, resourceStatisticsBooleanResultCallback);
    25332538    if (!context.done)
    25342539        runUntil(context.done, m_currentInvocation->shortTimeout());
     
    25522557    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    25532558    ResourceStatisticsCallbackContext context(*this);
    2554     WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(dataStore, host, &context, resourceStatisticsCallback);
     2559    WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(dataStore, host, &context, resourceStatisticsBooleanResultCallback);
    25552560    if (!context.done)
    25562561        runUntil(context.done, m_currentInvocation->shortTimeout());
     
    25682573    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    25692574    ResourceStatisticsCallbackContext context(*this);
    2570     WKWebsiteDataStoreIsStatisticsGrandfathered(dataStore, host, &context, resourceStatisticsCallback);
     2575    WKWebsiteDataStoreIsStatisticsGrandfathered(dataStore, host, &context, resourceStatisticsBooleanResultCallback);
    25712576    if (!context.done)
    25722577        runUntil(context.done, m_currentInvocation->shortTimeout());
     
    26132618{
    26142619    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2615     WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(dataStore);
     2620    ResourceStatisticsCallbackContext context(*this);
     2621    WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(dataStore, &context, resourceStatisticsVoidResultCallback);
     2622    if (!context.done)
     2623        runUntil(context.done, m_currentInvocation->shortTimeout());
     2624    m_currentInvocation->didSetPartitionOrBlockCookiesForHost();
    26162625}
    26172626
     
    26192628{
    26202629    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2621     WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(dataStore, host, value);
     2630    ResourceStatisticsCallbackContext context(*this);
     2631    WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(dataStore, host, value, &context, resourceStatisticsVoidResultCallback);
     2632    if (!context.done)
     2633        runUntil(context.done, m_currentInvocation->shortTimeout());
     2634    m_currentInvocation->didSetPartitionOrBlockCookiesForHost();
    26222635}
    26232636
     
    26702683}
    26712684
    2672 void TestController::statisticsClearThroughWebsiteDataRemovalCallback(void* userData)
    2673 {
    2674     static_cast<TestController*>(userData)->m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    2675 }
    2676 
    26772685void TestController::statisticsClearInMemoryAndPersistentStore()
    26782686{
    26792687    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2680     WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(dataStore, this, statisticsClearThroughWebsiteDataRemovalCallback);
     2688    ResourceStatisticsCallbackContext context(*this);
     2689    WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(dataStore, &context, resourceStatisticsVoidResultCallback);
     2690    if (!context.done)
     2691        runUntil(context.done, m_currentInvocation->shortTimeout());
     2692    m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    26812693}
    26822694
     
    26842696{
    26852697    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2686     WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(dataStore, hours, this, statisticsClearThroughWebsiteDataRemovalCallback);
     2698    ResourceStatisticsCallbackContext context(*this);
     2699    WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(dataStore, hours, &context, resourceStatisticsVoidResultCallback);
     2700    if (!context.done)
     2701        runUntil(context.done, m_currentInvocation->shortTimeout());
     2702    m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    26872703}
    26882704
     
    26902706{
    26912707    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    2692     WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(dataStore, this, statisticsClearThroughWebsiteDataRemovalCallback);
     2708    ResourceStatisticsCallbackContext context(*this);
     2709    WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(dataStore, &context, resourceStatisticsVoidResultCallback);
     2710    if (!context.done)
     2711        runUntil(context.done, m_currentInvocation->shortTimeout());
     2712    m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    26932713}
    26942714
     
    26992719}
    27002720
     2721#if !PLATFORM(COCOA)
    27012722void TestController::getAllStorageAccessEntries()
    27022723{
    27032724    // FIXME: Implement C API version of this test.
    27042725}
    2705 
    27062726#endif
    27072727
  • trunk/Tools/WebKitTestRunner/TestController.h

    r228109 r228304  
    339339    static const char* platformLibraryPathForTesting();
    340340
    341     static void statisticsClearThroughWebsiteDataRemovalCallback(void*);
    342 
    343341    std::unique_ptr<TestInvocation> m_currentInvocation;
    344342
  • trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r228109 r228304  
    5454namespace WTR {
    5555
    56 #if WK_API_ENABLED
    57 static NSString* toNSString(WKStringRef string)
    58 {
    59     return [NSString stringWithCString:toWTFString(string).utf8().data()];
    60 }
    61 #endif
    62 
    6356static WKWebViewConfiguration *globalWebViewConfiguration;
    6457
     
    257250}
    258251
    259 #if WK_API_ENABLED
    260 void TestController::setStatisticsLastSeen(WKStringRef hostName, double seconds)
    261 {
    262     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetLastSeen:seconds forHost:toNSString(hostName)];
    263 }
    264    
    265 void TestController::setStatisticsPrevalentResource(WKStringRef hostName, bool value)
    266 {
    267     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetIsPrevalentResource:value forHost:toNSString(hostName)];
    268 }
    269 
    270 bool TestController::isStatisticsPrevalentResource(WKStringRef hostName)
    271 {
    272     __block bool isDataReady = false;
    273     __block bool isPrevalentResource = false;
    274     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsPrevalentResource:toNSString(hostName) completionHandler:^(BOOL _isPrevalentResource) {
    275         isPrevalentResource = _isPrevalentResource;
    276         isDataReady = true;
    277     }];
    278     platformRunUntil(isDataReady, 0);
    279 
    280     return isPrevalentResource;
    281 }
    282 
    283 bool TestController::isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost)
    284 {
    285     __block bool isDataReady = false;
    286     __block bool isRegisteredAsSubFrameUnder = false;
    287     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsRegisteredAsSubFrameUnder:toNSString(subFrameHost) topFrameHost:toNSString(topFrameHost) completionHandler:^(BOOL _isRegisteredAsSubFrameUnder) {
    288         isRegisteredAsSubFrameUnder = _isRegisteredAsSubFrameUnder;
    289         isDataReady = true;
    290     }];
    291     platformRunUntil(isDataReady, 0);
    292    
    293     return isRegisteredAsSubFrameUnder;
    294 }
    295 
    296 bool TestController::isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo)
    297 {
    298     __block bool isDataReady = false;
    299     __block bool isRegisteredAsRedirectingTo = false;
    300     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsRegisteredAsRedirectingTo:toNSString(hostRedirectedFrom) hostRedirectedTo:toNSString(hostRedirectedTo) completionHandler:^(BOOL _isRegisteredAsRedirectingTo) {
    301         isRegisteredAsRedirectingTo = _isRegisteredAsRedirectingTo;
    302         isDataReady = true;
    303     }];
    304     platformRunUntil(isDataReady, 0);
    305    
    306     return isRegisteredAsRedirectingTo;
    307 }
    308 
    309 void TestController::setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value)
    310 {
    311     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetHadUserInteraction:value forHost:toNSString(hostName)];
    312 }
    313 
    314 void TestController::setStatisticsHasHadNonRecentUserInteraction(WKStringRef hostName)
    315 {
    316     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:toNSString(hostName)];
    317 }
    318 
    319 bool TestController::isStatisticsHasHadUserInteraction(WKStringRef hostName)
    320 {
    321     __block bool isDataReady = false;
    322     __block bool hasHadUserInteraction = false;
    323     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsHadUserInteraction:toNSString(hostName) completionHandler:^(BOOL _hasHadUserInteraction) {
    324         hasHadUserInteraction = _hasHadUserInteraction;
    325         isDataReady = true;
    326     }];
    327     platformRunUntil(isDataReady, 0);
    328 
    329     return hasHadUserInteraction;
    330 }
    331 
    332 void TestController::setStatisticsGrandfathered(WKStringRef hostName, bool value)
    333 {
    334     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetIsGrandfathered:value forHost:toNSString(hostName)];
    335 }
    336 
    337 bool TestController::isStatisticsGrandfathered(WKStringRef hostName)
    338 {
    339     __block bool isDataReady = false;
    340     __block bool isGrandfathered = false;
    341     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsIsGrandfathered:toNSString(hostName) completionHandler:^(BOOL _isGrandfathered) {
    342         isGrandfathered = _isGrandfathered;
    343         isDataReady = true;
    344     }];
    345     platformRunUntil(isDataReady, 0);
    346 
    347     return isGrandfathered;
    348 }
    349 
    350 void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
    351 {
    352     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetSubframeUnderTopFrameOrigin:toNSString(topFrameHostName) forHost:toNSString(hostName)];
    353 }
    354 
    355 void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
    356 {
    357     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetSubresourceUnderTopFrameOrigin:toNSString(topFrameHostName) forHost:toNSString(hostName)];
    358 }
    359 
    360 void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
    361 {
    362     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetSubresourceUniqueRedirectTo:toNSString(hostNameRedirectedTo) forHost:toNSString(hostName)];
    363 }
    364 
    365 void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
    366 {
    367     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetTimeToLiveUserInteraction:seconds];
    368 }
    369 
    370 void TestController::setStatisticsTimeToLiveCookiePartitionFree(double seconds)
    371 {
    372     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:seconds];
    373 }
    374 
    375 void TestController::statisticsProcessStatisticsAndDataRecords()
    376 {
    377     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords];
    378 }
    379 
    380 void TestController::statisticsUpdateCookiePartitioning()
    381 {
    382     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning:^() {
    383         m_currentInvocation->didSetPartitionOrBlockCookiesForHost();
    384     }];
    385 }
    386 
    387 void TestController::statisticsSetShouldPartitionCookiesForHost(WKStringRef hostName, bool value)
    388 {
    389     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:value forHost:toNSString(hostName) completionHandler:^() {
    390         m_currentInvocation->didSetPartitionOrBlockCookiesForHost();
    391     }];
    392 }
    393 
    394 void TestController::statisticsSubmitTelemetry()
    395 {
    396     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSubmitTelemetry];
    397 }
    398 
    399 void TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
    400 {
    401     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:value];
    402 }
    403 
    404 void TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
    405 {
    406     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:value];
    407 }
    408 
    409 void TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value)
    410 {
    411     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:value];
    412 }
    413 
    414 void TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval(double seconds)
    415 {
    416     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:seconds];
    417 }
    418 
    419 void TestController::setStatisticsGrandfatheringTime(double seconds)
    420 {
    421     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetGrandfatheringTime:seconds];
    422 }
    423 
    424 void TestController::setStatisticsMaxStatisticsEntries(unsigned entries)
    425 {
    426     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:entries];
    427 }
    428    
    429 void TestController::setStatisticsPruneEntriesDownTo(unsigned entries)
    430 {
    431     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:entries];
    432 }
    433    
    434 void TestController::statisticsClearInMemoryAndPersistentStore()
    435 {
    436     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore:^() {
    437         m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    438     }];
    439 }
    440 
    441 void TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours)
    442 {
    443     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:hours completionHandler:^() {
    444         m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    445     }];
    446 }
    447 
    448 void TestController::statisticsClearThroughWebsiteDataRemoval()
    449 {
    450 #if WK_API_ENABLED
    451     auto types = adoptNS([[NSSet alloc] initWithObjects:_WKWebsiteDataTypeResourceLoadStatistics, nil]);
    452     [globalWebViewConfiguration.websiteDataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:^() {
    453         m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
    454     }];
    455 #endif
    456 }
    457 
    458 void TestController::statisticsResetToConsistentState()
    459 {
    460     [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState];
    461 }
    462 
    463252void TestController::getAllStorageAccessEntries()
    464253{
     254#if WK_API_ENABLED
    465255    [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntries:^(NSArray<NSString *> *nsDomains) {
    466256        Vector<String> domains;
     
    470260        m_currentInvocation->didReceiveAllStorageAccessEntries(domains);
    471261    }];
    472 }
    473 
    474 #endif // WK_API_ENABLED
     262#endif
     263}
    475264
    476265} // namespace WTR
Note: See TracChangeset for help on using the changeset viewer.