Changeset 228304 in webkit
- Timestamp:
- Feb 8, 2018 5:32:55 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r228302 r228304 1 2018-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 1 51 2018-02-08 Don Olmstead <don.olmstead@sony.com> 2 52 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r228025 r228304 239 239 } 240 240 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) 241 void 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 252 void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction callback) 251 253 { 252 254 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); … … 255 257 256 258 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 }); 258 262 else 259 store->scheduleClearPartitioningStateForDomains({ WebKit::toImpl(host)->string() }, []() { }); 263 store->scheduleClearPartitioningStateForDomains({ WebKit::toImpl(host)->string() }, [context, callback]() { 264 callback(context); 265 }); 260 266 } 261 267 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r228025 r228304 62 62 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds); 63 63 WK_EXPORT void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef); 64 WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef); 65 WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value); 64 typedef void (*WKWebsiteDataStoreStatisticsUpdateCookiePartitioningFunction)(void* functionContext); 65 WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookiePartitioningFunction callback); 66 typedef void (*WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction)(void* functionContext); 67 WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHostFunction callback); 66 68 WK_EXPORT void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef); 67 69 WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r228109 r228304 296 296 } 297 297 298 - (void)_resourceLoadStatisticsSet LastSeen:(double)seconds forHost:(NSString *)host298 - (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value 299 299 { 300 300 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics(); 301 301 if (!store) 302 302 return; 303 304 store->setLastSeen(URL(URL(), host), Seconds { seconds });305 }306 307 - (void)_resourceLoadStatisticsSetIsPrevalentResource:(BOOL)value forHost:(NSString *)host308 {309 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();310 if (!store)311 return;312 313 if (value)314 store->setPrevalentResource(URL(URL(), host));315 else316 store->clearPrevalentResource(URL(URL(), host));317 }318 319 - (void)_resourceLoadStatisticsIsPrevalentResource:(NSString *)host completionHandler:(void (^)(BOOL))completionHandler320 {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))completionHandler334 {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))completionHandler348 {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 *)host362 {363 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();364 if (!store)365 return;366 367 if (value)368 store->logUserInteraction(URL(URL(), host));369 else370 store->clearUserInteraction(URL(URL(), host));371 }372 373 - (void)_resourceLoadStatisticsSetHasHadNonRecentUserInteractionForHost:(NSString *)host374 {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))completionHandler383 {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 *)host397 {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))completionHandler406 {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 *)host420 {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 *)host429 {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 *)host438 {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)seconds447 {448 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();449 if (!store)450 return;451 452 store->setTimeToLiveUserInteraction(Seconds { seconds });453 }454 455 - (void)_resourceLoadStatisticsSetTimeToLiveCookiePartitionFree:(double)seconds456 {457 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();458 if (!store)459 return;460 461 store->setTimeToLiveCookiePartitionFree(Seconds { seconds });462 }463 464 - (void)_resourceLoadStatisticsSetMinimumTimeBetweenDataRecordsRemoval:(double)seconds465 {466 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();467 if (!store)468 return;469 470 store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds });471 }472 473 - (void)_resourceLoadStatisticsSetGrandfatheringTime:(double)seconds474 {475 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();476 if (!store)477 return;478 479 store->setGrandfatheringTime(Seconds {seconds });480 }481 482 - (void)_resourceLoadStatisticsSetMaxStatisticsEntries:(size_t)entries483 {484 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();485 if (!store)486 return;487 488 store->setMaxStatisticsEntries(entries);489 }490 491 - (void)_resourceLoadStatisticsSetPruneEntriesDownTo:(size_t)entries492 {493 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();494 if (!store)495 return;496 497 store->setPruneEntriesDownTo(entries);498 }499 500 - (void)_resourceLoadStatisticsProcessStatisticsAndDataRecords501 {502 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();503 if (!store)504 return;505 506 store->scheduleStatisticsAndDataRecordsProcessing();507 }508 509 - (void)_resourceLoadStatisticsUpdateCookiePartitioning510 {511 [self _resourceLoadStatisticsUpdateCookiePartitioning:^() { }];512 }513 514 - (void)_resourceLoadStatisticsUpdateCookiePartitioning:(void (^)())completionHandler515 {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 *)host528 {529 [self _resourceLoadStatisticsSetShouldPartitionCookies:value forHost:host completionHandler:^() { }];530 }531 532 - (void)_resourceLoadStatisticsSetShouldPartitionCookies:(BOOL)value forHost:(NSString *)host completionHandler:(void (^)())completionHandler533 {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 else545 store->scheduleClearPartitioningStateForDomains({ host }, [completionHandler = makeBlockPtr(completionHandler)]() {546 completionHandler();547 });548 }549 550 - (void)_resourceLoadStatisticsSubmitTelemetry551 {552 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();553 if (!store)554 return;555 556 store->submitTelemetry();557 }558 559 - (void)_resourceLoadStatisticsSetNotifyPagesWhenDataRecordsWereScanned:(BOOL)value560 {561 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();562 if (!store)563 return;564 565 store->setNotifyPagesWhenDataRecordsWereScanned(value);566 }567 568 - (void)_resourceLoadStatisticsSetShouldClassifyResourcesBeforeDataRecordsRemoval:(BOOL)value569 {570 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();571 if (!store)572 return;573 574 store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);575 }576 577 - (void)_resourceLoadStatisticsSetNotifyPagesWhenTelemetryWasCaptured:(BOOL)value578 {579 WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);580 }581 582 - (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value583 {584 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();585 if (!store)586 return;587 303 588 304 store->setShouldSubmitTelemetry(value); 589 }590 591 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore592 {593 [self _resourceLoadStatisticsClearInMemoryAndPersistentStore:^() { }];594 }595 596 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStore:(void (^)())completionHandler597 {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)hours610 {611 [self _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:hours completionHandler:^() { }];612 }613 614 - (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours completionHandler:(void (^)())completionHandler615 {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)_resourceLoadStatisticsResetToConsistentState628 {629 WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(false);630 631 auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();632 if (!store)633 return;634 635 store->resetParametersToDefaultValues();636 store->scheduleClearInMemory();637 305 } 638 306 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
r228109 r228304 54 54 @property (nonatomic, setter=_setAllowsCellularAccess:) BOOL _allowsCellularAccess WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 55 55 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));85 56 - (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));91 57 - (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 92 58 - (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); -
trunk/Tools/ChangeLog
r228303 r228304 1 2018-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 1 64 2018-02-08 Jonathan Bedard <jbedard@apple.com> 2 65 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r228218 r228304 2473 2473 } 2474 2474 2475 #if !PLATFORM(COCOA) || !WK_API_ENABLED2476 2477 2475 void TestController::setStatisticsLastSeen(WKStringRef host, double seconds) 2478 2476 { … … 2498 2496 }; 2499 2497 2500 static void resourceStatisticsCallback(bool result, void* userData) 2498 static void resourceStatisticsVoidResultCallback(void* userData) 2499 { 2500 auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData); 2501 context->done = true; 2502 context->testController.notifyDone(); 2503 } 2504 2505 static void resourceStatisticsBooleanResultCallback(bool result, void* userData) 2501 2506 { 2502 2507 auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData); … … 2510 2515 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2511 2516 ResourceStatisticsCallbackContext context(*this); 2512 WKWebsiteDataStoreIsStatisticsPrevalentResource(dataStore, host, &context, resourceStatistics Callback);2517 WKWebsiteDataStoreIsStatisticsPrevalentResource(dataStore, host, &context, resourceStatisticsBooleanResultCallback); 2513 2518 if (!context.done) 2514 2519 runUntil(context.done, m_currentInvocation->shortTimeout()); … … 2520 2525 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2521 2526 ResourceStatisticsCallbackContext context(*this); 2522 WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(dataStore, subFrameHost, topFrameHost, &context, resourceStatistics Callback);2527 WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(dataStore, subFrameHost, topFrameHost, &context, resourceStatisticsBooleanResultCallback); 2523 2528 if (!context.done) 2524 2529 runUntil(context.done, m_currentInvocation->shortTimeout()); … … 2530 2535 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2531 2536 ResourceStatisticsCallbackContext context(*this); 2532 WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(dataStore, hostRedirectedFrom, hostRedirectedTo, &context, resourceStatistics Callback);2537 WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(dataStore, hostRedirectedFrom, hostRedirectedTo, &context, resourceStatisticsBooleanResultCallback); 2533 2538 if (!context.done) 2534 2539 runUntil(context.done, m_currentInvocation->shortTimeout()); … … 2552 2557 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2553 2558 ResourceStatisticsCallbackContext context(*this); 2554 WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(dataStore, host, &context, resourceStatistics Callback);2559 WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(dataStore, host, &context, resourceStatisticsBooleanResultCallback); 2555 2560 if (!context.done) 2556 2561 runUntil(context.done, m_currentInvocation->shortTimeout()); … … 2568 2573 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2569 2574 ResourceStatisticsCallbackContext context(*this); 2570 WKWebsiteDataStoreIsStatisticsGrandfathered(dataStore, host, &context, resourceStatistics Callback);2575 WKWebsiteDataStoreIsStatisticsGrandfathered(dataStore, host, &context, resourceStatisticsBooleanResultCallback); 2571 2576 if (!context.done) 2572 2577 runUntil(context.done, m_currentInvocation->shortTimeout()); … … 2613 2618 { 2614 2619 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(); 2616 2625 } 2617 2626 … … 2619 2628 { 2620 2629 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(); 2622 2635 } 2623 2636 … … 2670 2683 } 2671 2684 2672 void TestController::statisticsClearThroughWebsiteDataRemovalCallback(void* userData)2673 {2674 static_cast<TestController*>(userData)->m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();2675 }2676 2677 2685 void TestController::statisticsClearInMemoryAndPersistentStore() 2678 2686 { 2679 2687 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(); 2681 2693 } 2682 2694 … … 2684 2696 { 2685 2697 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(); 2687 2703 } 2688 2704 … … 2690 2706 { 2691 2707 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(); 2693 2713 } 2694 2714 … … 2699 2719 } 2700 2720 2721 #if !PLATFORM(COCOA) 2701 2722 void TestController::getAllStorageAccessEntries() 2702 2723 { 2703 2724 // FIXME: Implement C API version of this test. 2704 2725 } 2705 2706 2726 #endif 2707 2727 -
trunk/Tools/WebKitTestRunner/TestController.h
r228109 r228304 339 339 static const char* platformLibraryPathForTesting(); 340 340 341 static void statisticsClearThroughWebsiteDataRemovalCallback(void*);342 343 341 std::unique_ptr<TestInvocation> m_currentInvocation; 344 342 -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r228109 r228304 54 54 namespace WTR { 55 55 56 #if WK_API_ENABLED57 static NSString* toNSString(WKStringRef string)58 {59 return [NSString stringWithCString:toWTFString(string).utf8().data()];60 }61 #endif62 63 56 static WKWebViewConfiguration *globalWebViewConfiguration; 64 57 … … 257 250 } 258 251 259 #if WK_API_ENABLED260 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_ENABLED451 auto types = adoptNS([[NSSet alloc] initWithObjects:_WKWebsiteDataTypeResourceLoadStatistics, nil]);452 [globalWebViewConfiguration.websiteDataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:^() {453 m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();454 }];455 #endif456 }457 458 void TestController::statisticsResetToConsistentState()459 {460 [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState];461 }462 463 252 void TestController::getAllStorageAccessEntries() 464 253 { 254 #if WK_API_ENABLED 465 255 [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntries:^(NSArray<NSString *> *nsDomains) { 466 256 Vector<String> domains; … … 470 260 m_currentInvocation->didReceiveAllStorageAccessEntries(domains); 471 261 }]; 472 } 473 474 #endif // WK_API_ENABLED 262 #endif 263 } 475 264 476 265 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.