Changeset 234080 in webkit
- Timestamp:
- Jul 20, 2018 8:10:53 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r234077 r234080 1 2018-07-20 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Enable basic functionality in experimental debug mode 4 https://bugs.webkit.org/show_bug.cgi?id=187835 5 <rdar://problem/42408590> 6 7 Reviewed by Chris Dumez. 8 9 This patch makes the experimental ITP Debug Mode feature work, at least 10 to a basic level. 11 12 * http/tests/resourceLoadStatistics/enable-debug-mode-expected.txt: Added. 13 * http/tests/resourceLoadStatistics/enable-debug-mode.html: Added. 14 * http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode-expected.txt: Added. 15 * http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html: Added. 16 1 17 2018-07-20 Sihui Liu <sihui_liu@apple.com> 2 18 -
trunk/Source/WebKit/ChangeLog
r234067 r234080 1 2018-07-20 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Enable basic functionality in experimental debug mode 4 https://bugs.webkit.org/show_bug.cgi?id=187835 5 <rdar://problem/42408590> 6 7 Reviewed by Chris Dumez. 8 9 This patch makes the experimental ITP Debug Mode feature work, at least 10 to a basic level. This means: 11 - Debug logging on the INFO level. 12 - Permanently treat 3rdpartytestwebkit.org as a prevalent resource. 13 - Support manual setting of a custom permanently prevalent resource through user 14 defaults on Cocoa platforms. 15 16 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 17 (WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler): 18 (WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode): 19 Test infrastructure. 20 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 21 * UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm: 22 (WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded): 23 Used to pick up custom set prevalent resource on Cocoa platforms (for debug mode). 24 * UIProcess/ResourceLoadStatisticsMemoryStore.cpp: 25 (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentDueToDebugMode): 26 (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords): 27 Now skips processing of debug mode prevalent resources so that they 28 stay prevalent. 29 (WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode): 30 Convenience function to make 3rdpartytestwebkit.org and any custom domain 31 set through ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode() 32 be prevalent resources. 33 (WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode): 34 (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode): 35 Sets a custom domain to always be treated as prevalent in debug mode. 36 (WebKit::ResourceLoadStatisticsMemoryStore::clear): 37 Now makes sure 3rdpartytestwebkit.org and any custom domain set through 38 ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode() 39 are prevalent resources even after a clear of the store. 40 (WebKit::debugLogDomainsInBatches): 41 We may have too many domain names to fit in a single log statement. 42 This function logs them in batches of 50, if we have more than 50. 43 (WebKit::ResourceLoadStatisticsMemoryStore::updateCookiePartitioning): 44 Now makes use of debugLogDomainsInBatches() in debug mode. 45 * UIProcess/ResourceLoadStatisticsMemoryStore.h: 46 (WebKit::ResourceLoadStatisticsMemoryStore::isDebugModeEnabled const): 47 * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp: 48 (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk): 49 Now accepts a non-empty memory store in debug mode. This is to support a 50 pre-populated store with 3rdpartytestwebkit.org and any custom domain already 51 set as prevalent. 52 (WebKit::ResourceLoadStatisticsPersistentStorage::setResourceLoadStatisticsDebugMode): 53 * UIProcess/WebResourceLoadStatisticsStore.cpp: 54 (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode): 55 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode): 56 * UIProcess/WebResourceLoadStatisticsStore.h: 57 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 58 (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode): 59 * UIProcess/WebsiteData/WebsiteDataStore.h: 60 1 61 2018-07-20 Tim Horton <timothy_horton@apple.com> 2 62 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r233888 r234080 70 70 } 71 71 72 void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) 73 { 74 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 75 if (!store) { 76 completionHandler(context); 77 return; 78 } 79 80 store->setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] { 81 completionHandler(context); 82 }); 83 } 84 85 void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) 86 { 87 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 88 if (!store) { 89 completionHandler(context); 90 return; 91 } 92 93 store->setPrevalentResourceForDebugMode(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { 94 completionHandler(context); 95 }); 96 } 72 97 void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler) 73 98 { -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r233888 r234080 41 41 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable); 42 42 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef dataStoreRef, bool enable); 43 typedef void (*WKWebsiteDataStoreStatisticsDebugModeFunction)(void* functionContext); 44 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler); 45 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler); 43 46 typedef void (*WKWebsiteDataStoreStatisticsLastSeenFunction)(void* functionContext); 44 47 WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler); -
trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm
r233310 r234080 26 26 #import "config.h" 27 27 #import "ResourceLoadStatisticsMemoryStore.h" 28 #import <wtf/text/WTFString.h> 28 29 29 30 namespace WebKit { … … 52 53 setDebugLogggingEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ResourceLoadStatisticsDebugLoggingEnabled"]); 53 54 setResourceLoadStatisticsDebugMode([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalResourceLoadStatisticsDebugMode"]); 55 auto* debugManualPrevalentResource = [[NSUserDefaults standardUserDefaults] stringForKey:@"ResourceLoadStatisticsManualPrevalentResource"]; 56 if (debugManualPrevalentResource) 57 setPrevalentResourceForDebugMode(debugManualPrevalentResource); 54 58 setStorageAccessPromptsEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalStorageAccessPromptsEnabled"]); 55 59 }); -
trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp
r234020 r234080 52 52 constexpr unsigned operatingDatesWindow { 30 }; 53 53 constexpr unsigned maxImportance { 3 }; 54 static const char* debugStaticPrevalentResource { "3rdpartytestwebkit.org" }; 54 55 55 56 #if !RELEASE_LOG_DISABLED … … 320 321 } 321 322 323 bool ResourceLoadStatisticsMemoryStore::isPrevalentDueToDebugMode(ResourceLoadStatistics& resourceStatistic) 324 { 325 if (!m_debugModeEnabled) 326 return false; 327 328 return resourceStatistic.highLevelDomain == debugStaticPrevalentResource || resourceStatistic.highLevelDomain == m_debugManualPrevalentResource; 329 } 330 322 331 void ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords() 323 332 { … … 326 335 if (m_parameters.shouldClassifyResourcesBeforeDataRecordsRemoval) { 327 336 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 328 if (!resourceStatistic.isVeryPrevalentResource) { 337 if (isPrevalentDueToDebugMode(resourceStatistic)) 338 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); 339 else if (!resourceStatistic.isVeryPrevalentResource) { 329 340 markAsPrevalentIfHasRedirectedToPrevalent(resourceStatistic); 330 341 auto currentPrevalence = resourceStatistic.isPrevalentResource ? ResourceLoadPrevalence::High : ResourceLoadPrevalence::Low; … … 508 519 } 509 520 521 Vector<String> ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode() 522 { 523 if (!m_debugModeEnabled) 524 return { }; 525 526 Vector<String> primaryDomainsToBlock; 527 primaryDomainsToBlock.reserveInitialCapacity(2); 528 529 auto& staticSesourceStatistic = ensureResourceStatisticsForPrimaryDomain(debugStaticPrevalentResource); 530 setPrevalentResource(staticSesourceStatistic, ResourceLoadPrevalence::High); 531 primaryDomainsToBlock.uncheckedAppend(debugStaticPrevalentResource); 532 533 if (!m_debugManualPrevalentResource.isEmpty()) { 534 auto& manualResourceStatistic = ensureResourceStatisticsForPrimaryDomain(m_debugManualPrevalentResource); 535 setPrevalentResource(manualResourceStatistic, ResourceLoadPrevalence::High); 536 primaryDomainsToBlock.uncheckedAppend(m_debugManualPrevalentResource); 537 } 538 539 return primaryDomainsToBlock; 540 } 541 510 542 void ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode(bool enable) 511 543 { … … 513 545 514 546 m_debugModeEnabled = enable; 547 m_debugLoggingEnabled = enable; 548 549 ensurePrevalentResourcesForDebugMode(); 550 } 551 552 void ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode(const String& domain) 553 { 554 if (!m_debugModeEnabled) 555 return; 556 557 m_debugManualPrevalentResource = domain; 558 auto& resourceStatistic = ensureResourceStatisticsForPrimaryDomain(domain); 559 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); 560 515 561 #if !RELEASE_LOG_DISABLED 516 RELEASE_LOG_INFO _IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "ITP Debug Mode %{public}s.", (m_debugModeEnabled ? "enabled" : "disabled"));562 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Did set %{public}s as prevalent resource for the purposes of ITP Debug Mode.", domain.utf8().data()); 517 563 #endif 518 564 } … … 892 938 893 939 removeAllStorageAccess(); 894 updateCookiePartitioningForDomains({ }, { }, { }, ShouldClearFirst::Yes, []() { }); 940 941 auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode(); 942 updateCookiePartitioningForDomains({ }, primaryDomainsToBlock, { }, ShouldClearFirst::Yes, []() { }); 895 943 } 896 944 … … 934 982 { 935 983 return statistic.storageAccessUnderTopFrameOrigins.contains(firstPartyPrimaryDomain); 984 } 985 986 static void debugLogDomainsInBatches(const char* action, const Vector<String>& domains) 987 { 988 #if !RELEASE_LOG_DISABLED 989 static const auto maxNumberOfDomainsInOneLogStatement = 50; 990 if (domains.isEmpty()) 991 return; 992 993 if (domains.size() <= maxNumberOfDomainsInOneLogStatement) { 994 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to %{public}s cookies in third-party contexts for: %{public}s.", action, domainsToString(domains).utf8().data()); 995 return; 996 } 997 998 Vector<String> batch; 999 batch.reserveInitialCapacity(maxNumberOfDomainsInOneLogStatement); 1000 auto batchNumber = 1; 1001 unsigned numberOfBatches = std::ceil(domains.size() / static_cast<float>(maxNumberOfDomainsInOneLogStatement)); 1002 1003 for (auto& domain : domains) { 1004 if (batch.size() == maxNumberOfDomainsInOneLogStatement) { 1005 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to %{public}s cookies in third-party contexts for (%{public}d of %u): %{public}s.", action, batchNumber, numberOfBatches, domainsToString(batch).utf8().data()); 1006 batch.shrink(0); 1007 ++batchNumber; 1008 } 1009 batch.append(domain); 1010 } 1011 if (!batch.isEmpty()) 1012 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to %{public}s cookies in third-party contexts for (%{public}d of %u): %{public}s.", action, batchNumber, numberOfBatches, domainsToString(batch).utf8().data()); 1013 #else 1014 UNUSED_PARAM(action); 1015 UNUSED_PARAM(domains); 1016 #endif 936 1017 } 937 1018 … … 966 1047 } 967 1048 968 #if !RELEASE_LOG_DISABLED969 1049 if (m_debugLoggingEnabled) { 970 1050 if (!domainsToPartition.isEmpty()) 971 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to partition cookies in third-party contexts for %{public}s.", domainsToString(domainsToPartition).utf8().data());1051 debugLogDomainsInBatches("partition", domainsToPartition); 972 1052 if (!domainsToBlock.isEmpty()) 973 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to block cookies in third-party contexts for %{public}s.", domainsToString(domainsToBlock).utf8().data());1053 debugLogDomainsInBatches("block", domainsToBlock); 974 1054 if (!domainsToNeitherPartitionNorBlock.isEmpty()) 975 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to neither partition nor block cookies in third-party contexts for %{public}s.", domainsToString(domainsToNeitherPartitionNorBlock).utf8().data()); 976 } 977 #endif 1055 debugLogDomainsInBatches("neither partition nor block", domainsToNeitherPartitionNorBlock); 1056 } 978 1057 979 1058 RunLoop::main().dispatch([this, store = makeRef(m_store), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), completionHandler = WTFMove(completionHandler)] () mutable { -
trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h
r233310 r234080 114 114 void setGrandfatheringTime(Seconds); 115 115 void setResourceLoadStatisticsDebugMode(bool); 116 bool isDebugModeEnabled() const { return m_debugModeEnabled; }; 117 void setPrevalentResourceForDebugMode(const String& domain); 116 118 117 119 void hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); … … 144 146 void grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&); 145 147 void markAsPrevalentIfHasRedirectedToPrevalent(WebCore::ResourceLoadStatistics&); 148 bool isPrevalentDueToDebugMode(WebCore::ResourceLoadStatistics&); 149 Vector<String> ensurePrevalentResourcesForDebugMode(); 146 150 void removeDataRecords(CompletionHandler<void()>&&); 147 151 void pruneStatisticsIfNeeded(); … … 182 186 bool m_debugLoggingEnabled { false }; 183 187 bool m_debugModeEnabled { false }; 188 String m_debugManualPrevalentResource; 184 189 bool m_storageAccessPromptsEnabled { false }; 185 190 bool m_dataRecordsBeingRemoved { false }; -
trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp
r233367 r234080 236 236 } 237 237 238 ASSERT_WITH_MESSAGE(m_memoryStore.isEmpty(), "This is the initial import so the store should be empty"); 238 // Debug mode has a prepoulated memory store. 239 ASSERT_WITH_MESSAGE(m_memoryStore.isEmpty() || m_memoryStore.isDebugModeEnabled(), "This is the initial import so the store should be empty"); 239 240 m_memoryStore.mergeWithDataFromDecoder(*decoder); 240 241 -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
r233888 r234080 170 170 } 171 171 172 void WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode(bool value )173 { 174 ASSERT(RunLoop::isMain()); 175 176 postTask([this, value ]{172 void WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode(bool value, CompletionHandler<void()>&& completionHandler) 173 { 174 ASSERT(RunLoop::isMain()); 175 176 postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable { 177 177 if (m_memoryStore) 178 178 m_memoryStore->setResourceLoadStatisticsDebugMode(value); 179 postTaskReply([completionHandler = WTFMove(completionHandler)] { 180 completionHandler(); 181 }); 182 }); 183 } 184 185 void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const WebCore::URL& url, CompletionHandler<void()>&& completionHandler) 186 { 187 ASSERT(RunLoop::isMain()); 188 189 postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { 190 if (m_memoryStore) 191 m_memoryStore->setPrevalentResourceForDebugMode(primaryDomain); 192 postTaskReply([completionHandler = WTFMove(completionHandler)] { 193 completionHandler(); 194 }); 179 195 }); 180 196 } -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
r233888 r234080 133 133 void resetParametersToDefaultValues(CompletionHandler<void()>&&); 134 134 135 void setResourceLoadStatisticsDebugMode(bool); 136 135 void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); 136 void setPrevalentResourceForDebugMode(const WebCore::URL&, CompletionHandler<void()>&&); 137 137 138 void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } 138 139 void logTestingEvent(const String&); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r233538 r234080 1509 1509 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) 1510 1510 { 1511 setResourceLoadStatisticsDebugMode(enabled, []() { }); 1512 } 1513 1514 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler) 1515 { 1511 1516 m_resourceLoadStatisticsDebugMode = enabled; 1512 1517 if (m_resourceLoadStatistics) 1513 m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled); 1518 m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler)); 1519 else 1520 completionHandler(); 1514 1521 } 1515 1522 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r233468 r234080 110 110 bool resourceLoadStatisticsDebugMode() const; 111 111 void setResourceLoadStatisticsDebugMode(bool); 112 void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); 112 113 113 114 uint64_t cacheStoragePerOriginQuota() const { return m_resolvedConfiguration.cacheStoragePerOriginQuota; } -
trunk/Tools/ChangeLog
r234064 r234080 1 2018-07-20 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Enable basic functionality in experimental debug mode 4 https://bugs.webkit.org/show_bug.cgi?id=187835 5 <rdar://problem/42408590> 6 7 Reviewed by Chris Dumez. 8 9 This patch makes the experimental ITP Debug Mode feature work, at least 10 to a basic level. All of the changes to TestRunner are to support the 11 layout tests for the functionality. 12 13 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 14 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 15 (WTR::InjectedBundle::didReceiveMessageToPage): 16 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 17 (WTR::TestRunner::setStatisticsDebugMode): 18 (WTR::TestRunner::statisticsCallDidSetDebugModeCallback): 19 (WTR::TestRunner::setStatisticsPrevalentResourceForDebugMode): 20 (WTR::TestRunner::statisticsCallDidSetPrevalentResourceForDebugModeCallback): 21 * WebKitTestRunner/InjectedBundle/TestRunner.h: 22 * WebKitTestRunner/TestController.cpp: 23 (WTR::TestController::setStatisticsDebugMode): 24 (WTR::TestController::setStatisticsPrevalentResourceForDebugMode): 25 * WebKitTestRunner/TestController.h: 26 * WebKitTestRunner/TestInvocation.cpp: 27 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 28 (WTR::TestInvocation::didSetStatisticsDebugMode): 29 (WTR::TestInvocation::didSetPrevalentResourceForDebugMode): 30 * WebKitTestRunner/TestInvocation.h: 31 1 32 2018-07-20 Ryosuke Niwa <rniwa@apple.com> 2 33 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r234064 r234080 273 273 void installStatisticsDidScanDataRecordsCallback(object callback); 274 274 void installStatisticsDidRunTelemetryCallback(object callback); 275 void setStatisticsDebugMode(boolean value, object completionHandler); 276 void setStatisticsPrevalentResourceForDebugMode(DOMString hostName, object completionHandler); 275 277 void setStatisticsLastSeen(DOMString hostName, double seconds, object completionHandler); 276 278 void setStatisticsPrevalentResource(DOMString hostName, boolean value, object completionHandler); -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r233941 r234080 316 316 } 317 317 318 if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetStatisticsDebugMode")) { 319 m_testRunner->statisticsCallDidSetDebugModeCallback(); 320 return; 321 } 322 323 if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetPrevalentResourceForDebugMode")) { 324 m_testRunner->statisticsCallDidSetPrevalentResourceForDebugModeCallback(); 325 return; 326 } 327 318 328 if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetLastSeen")) { 319 329 m_testRunner->statisticsCallDidSetLastSeenCallback(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r234064 r234080 737 737 DidEndSwipeCallbackID, 738 738 DidRemoveSwipeSnapshotCallbackID, 739 SetStatisticsDebugModeCallbackID, 740 SetStatisticsPrevalentResourceForDebugModeCallbackID, 739 741 SetStatisticsLastSeenCallbackID, 740 742 SetStatisticsPrevalentResourceCallbackID, … … 1332 1334 } 1333 1335 1336 void TestRunner::setStatisticsDebugMode(bool value, JSValueRef completionHandler) 1337 { 1338 cacheTestRunnerCallback(SetStatisticsDebugModeCallbackID, completionHandler); 1339 1340 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsDebugMode")); 1341 WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value)); 1342 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1343 1344 } 1345 1346 void TestRunner::statisticsCallDidSetDebugModeCallback() 1347 { 1348 callTestRunnerCallback(SetStatisticsDebugModeCallbackID); 1349 } 1350 1351 void TestRunner::setStatisticsPrevalentResourceForDebugMode(JSStringRef hostName, JSValueRef completionHandler) 1352 { 1353 cacheTestRunnerCallback(SetStatisticsPrevalentResourceForDebugModeCallbackID, completionHandler); 1354 1355 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsPrevalentResourceForDebugMode")); 1356 WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(hostName)); 1357 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1358 } 1359 1360 void TestRunner::statisticsCallDidSetPrevalentResourceForDebugModeCallback() 1361 { 1362 callTestRunnerCallback(SetStatisticsPrevalentResourceForDebugModeCallbackID); 1363 } 1364 1334 1365 void TestRunner::setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler) 1335 1366 { … … 1363 1394 callTestRunnerCallback(SetStatisticsLastSeenCallbackID); 1364 1395 } 1365 1366 1396 1367 1397 void TestRunner::setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler) -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r234064 r234080 383 383 void statisticsCallDidSetPartitionOrBlockCookiesForHostCallback(); 384 384 void statisticsSubmitTelemetry(); 385 void setStatisticsDebugMode(bool value, JSValueRef completionHandler); 386 void statisticsCallDidSetDebugModeCallback(); 387 void setStatisticsPrevalentResourceForDebugMode(JSStringRef hostName, JSValueRef completionHandler); 388 void statisticsCallDidSetPrevalentResourceForDebugModeCallback(); 385 389 void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler); 386 390 void statisticsCallDidSetLastSeenCallback(); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r233888 r234080 2646 2646 context->testController.notifyDone(); 2647 2647 } 2648 2648 2649 void TestController::setStatisticsDebugMode(bool value) 2650 { 2651 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2652 ResourceStatisticsCallbackContext context(*this); 2653 WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(dataStore, value, &context, resourceStatisticsVoidResultCallback); 2654 runUntil(context.done, noTimeout); 2655 m_currentInvocation->didSetStatisticsDebugMode(); 2656 } 2657 2658 void TestController::setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName) 2659 { 2660 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2661 ResourceStatisticsCallbackContext context(*this); 2662 WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(dataStore, hostName, &context, resourceStatisticsVoidResultCallback); 2663 runUntil(context.done, noTimeout); 2664 m_currentInvocation->didSetPrevalentResourceForDebugMode(); 2665 } 2666 2649 2667 void TestController::setStatisticsLastSeen(WKStringRef host, double seconds) 2650 2668 { -
trunk/Tools/WebKitTestRunner/TestController.h
r233782 r234080 157 157 void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; } 158 158 159 void setStatisticsDebugMode(bool value); 160 void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName); 159 161 void setStatisticsLastSeen(WKStringRef hostName, double seconds); 160 162 void setStatisticsPrevalentResource(WKStringRef hostName, bool value); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r233888 r234080 1037 1037 } 1038 1038 1039 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsDebugMode")) { 1040 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); 1041 WKBooleanRef value = static_cast<WKBooleanRef>(messageBody); 1042 TestController::singleton().setStatisticsDebugMode(WKBooleanGetValue(value)); 1043 return nullptr; 1044 } 1045 1046 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsPrevalentResourceForDebugMode")) { 1047 ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); 1048 WKStringRef hostName = static_cast<WKStringRef>(messageBody); 1049 TestController::singleton().setStatisticsPrevalentResourceForDebugMode(hostName); 1050 return nullptr; 1051 } 1052 1039 1053 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsLastSeen")) { 1040 1054 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); … … 1528 1542 } 1529 1543 1544 void TestInvocation::didSetStatisticsDebugMode() 1545 { 1546 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetStatisticsDebugMode")); 1547 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1548 } 1549 1550 void TestInvocation::didSetPrevalentResourceForDebugMode() 1551 { 1552 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetPrevalentResourceForDebugMode")); 1553 WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); 1554 } 1555 1530 1556 void TestInvocation::didSetLastSeen() 1531 1557 { -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r233888 r234080 75 75 void didResetStatisticsToConsistentState(); 76 76 void didSetPartitionOrBlockCookiesForHost(); 77 void didSetStatisticsDebugMode(); 78 void didSetPrevalentResourceForDebugMode(); 77 79 void didSetLastSeen(); 78 80 void didSetPrevalentResource();
Note: See TracChangeset
for help on using the changeset viewer.