Resource Load Statistics: Add logging of Storage Access API use in experimental debug...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2018 20:17:42 +0000 (20:17 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2018 20:17:42 +0000 (20:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187918
<rdar://problem/42509062>

Reviewed by Jiewen Tan.

Tested manually by looking at log output.

* UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords):
    This is just a clean-up change.
(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
    Both these now log proper info in debug mode.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234108 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp

index f7798d0..1c28fa0 100644 (file)
@@ -1,3 +1,20 @@
+2018-07-23  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add logging of Storage Access API use in experimental debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=187918
+        <rdar://problem/42509062>
+
+        Reviewed by Jiewen Tan.
+
+        Tested manually by looking at log output.
+
+        * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords):
+            This is just a clean-up change.
+        (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
+        (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
+            Both these now log proper info in debug mode.
+
 2018-07-23  Aditya Keerthi  <akeerthi@apple.com>
 
         [iOS] Add support for input[type=color]
index ccfad18..3efd5b2 100644 (file)
@@ -239,8 +239,7 @@ void ResourceLoadStatisticsMemoryStore::removeDataRecords(CompletionHandler<void
     }
 
 #if !RELEASE_LOG_DISABLED
-    if (m_debugLoggingEnabled)
-        RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to remove data records for %{public}s.", domainsToString(prevalentResourceDomains).utf8().data());
+    RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to remove data records for %{public}s.", domainsToString(prevalentResourceDomains).utf8().data());
 #endif
 
     setDataRecordsBeingRemoved(true);
@@ -403,19 +402,32 @@ void ResourceLoadStatisticsMemoryStore::requestStorageAccess(String&& subFramePr
 
     auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain);
     if (shouldBlockCookies(subFrameStatistic)) {
+#if !RELEASE_LOG_DISABLED
+        RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Cannot grant storage access to %{public}s since its cookies are blocked in third-party contexts.", subFramePrimaryDomain.utf8().data());
+#endif
         completionHandler(StorageAccessStatus::CannotRequestAccess);
         return;
     }
 
     if (!shouldPartitionCookies(subFrameStatistic)) {
+#if !RELEASE_LOG_DISABLED
+        RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "No need to grant storage access to %{public}s since its cookies are neither blocked nor partitioned in third-party contexts.", subFramePrimaryDomain.utf8().data());
+#endif
         completionHandler(StorageAccessStatus::HasAccess);
         return;
     }
 
     auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFramePrimaryDomain);
     if (promptEnabled && !userWasPromptedEarlier) {
+#if !RELEASE_LOG_DISABLED
+        RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to ask the user whether they want to grant storage access to %{public}s under %{public}s or not.", subFramePrimaryDomain.utf8().data(), topFramePrimaryDomain.utf8().data());
+#endif
         completionHandler(StorageAccessStatus::RequiresUserPrompt);
         return;
+    } else if (userWasPromptedEarlier) {
+#if !RELEASE_LOG_DISABLED
+        RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Storage access was granted to %{public}s under %{public}s.", subFramePrimaryDomain.utf8().data(), topFramePrimaryDomain.utf8().data());
+#endif
     }
 
     subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++;
@@ -445,7 +457,7 @@ void ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener(String&&
         return;
 
 #if !RELEASE_LOG_DISABLED
-    RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Grant storage access for %{public}s under opener %{public}s, %{public}s user interaction.", primaryDomainInNeedOfStorageAccess.utf8().data(), openerPrimaryDomain.utf8().data(), (isTriggeredByUserGesture ? "with" : "without"));
+    RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "[Temporary combatibility fix] Storage access was granted for %{public}s under opener page from %{public}s, %{public}s user interaction in the opened window.", primaryDomainInNeedOfStorageAccess.utf8().data(), openerPrimaryDomain.utf8().data(), (isTriggeredByUserGesture ? "with" : "without"));
 #endif
     grantStorageAccessInternal(WTFMove(primaryDomainInNeedOfStorageAccess), WTFMove(openerPrimaryDomain), std::nullopt, openerPageID, false, [](bool) { });
 }