Title: [263258] trunk
Revision
263258
Author
carlo...@webkit.org
Date
2020-06-19 00:49:23 -0700 (Fri, 19 Jun 2020)

Log Message

Add support for fetching registrable domains with resource load statistics
https://bugs.webkit.org/show_bug.cgi?id=213291

Source/WebKit:

Reviewed by Adrian Perez de Castro and Youenn Fablet.

WebsiteDataStore::fetchData() doesn't return anything for resource load statistics because
NetworkProcess::fetchWebsiteData() doesn't handle WebsiteDataType::ResourceLoadStatistics.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::allDomains const): Query all registrable domains from database.
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::allDomains const): Return all registrable domains in memory map.
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::registrableDomains): Get the list of registrable domains.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::fetchWebsiteData): Handle WebsiteDataType::ResourceLoadStatistics.
* Shared/WebsiteData/WebsiteData.cpp:
(WebKit::WebsiteData::encode const): Encode registrableDomainsWithResourceLoadStatistics.
(WebKit::WebsiteData::decode): Decode registrableDomainsWithResourceLoadStatistics.
* Shared/WebsiteData/WebsiteData.h:
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreRemoveITPDataForDomain): Use WebsiteDataRecord::addResourceLoadStatisticsRegistrableDomain()
instead of the display name.
* UIProcess/WebsiteData/WebsiteDataRecord.cpp:
(WebKit::WebsiteDataRecord::addResourceLoadStatisticsRegistrableDomain): Add the given registrable domain to the list.
* UIProcess/WebsiteData/WebsiteDataRecord.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchDataAndApply): Handle registrable domains with resource load statistics.
(WebKit::WebsiteDataStore::removeData): Use resourceLoadStatisticsRegistrableDomains instead of the display name.

Tools:

Reviewed by Adrian Perez de Castro.

Update GLib ITP unit test to check also fetch and remove.

* TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
(testWebsiteDataITP):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (263257 => 263258)


--- trunk/Source/WebKit/ChangeLog	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/ChangeLog	2020-06-19 07:49:23 UTC (rev 263258)
@@ -1,3 +1,39 @@
+2020-06-19  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Add support for fetching registrable domains with resource load statistics
+        https://bugs.webkit.org/show_bug.cgi?id=213291
+
+        Reviewed by Adrian Perez de Castro and Youenn Fablet.
+
+        WebsiteDataStore::fetchData() doesn't return anything for resource load statistics because
+        NetworkProcess::fetchWebsiteData() doesn't handle WebsiteDataType::ResourceLoadStatistics.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+        (WebKit::ResourceLoadStatisticsDatabaseStore::allDomains const): Query all registrable domains from database.
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::allDomains const): Return all registrable domains in memory map.
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::registrableDomains): Get the list of registrable domains.
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::fetchWebsiteData): Handle WebsiteDataType::ResourceLoadStatistics.
+        * Shared/WebsiteData/WebsiteData.cpp:
+        (WebKit::WebsiteData::encode const): Encode registrableDomainsWithResourceLoadStatistics.
+        (WebKit::WebsiteData::decode): Decode registrableDomainsWithResourceLoadStatistics.
+        * Shared/WebsiteData/WebsiteData.h:
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreRemoveITPDataForDomain): Use WebsiteDataRecord::addResourceLoadStatisticsRegistrableDomain()
+        instead of the display name.
+        * UIProcess/WebsiteData/WebsiteDataRecord.cpp:
+        (WebKit::WebsiteDataRecord::addResourceLoadStatisticsRegistrableDomain): Add the given registrable domain to the list.
+        * UIProcess/WebsiteData/WebsiteDataRecord.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchDataAndApply): Handle registrable domains with resource load statistics.
+        (WebKit::WebsiteDataStore::removeData): Use resourceLoadStatisticsRegistrableDomains instead of the display name.
+
 2020-06-18  David Kilzer  <ddkil...@apple.com>
 
         Use fastMalloc/fastFree in WebCoreArgumentCodersMac.mm

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -2261,6 +2261,20 @@
     }
 }
 
+Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::allDomains() const
+{
+    ASSERT(!RunLoop::isMain());
+
+    auto scopedStatement = this->scopedStatement(m_getAllDomainsStatement, getAllDomainsQuery, "allDomains"_s);
+    if (!scopedStatement)
+        return { };
+
+    Vector<RegistrableDomain> domains;
+    while (scopedStatement->step() == SQLITE_ROW)
+        domains.append(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(scopedStatement->getColumnText(0)));
+    return domains;
+}
+
 void ResourceLoadStatisticsDatabaseStore::clear(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -144,6 +144,7 @@
     bool isNewResourceLoadStatisticsDatabaseFile() const { return m_isNewResourceLoadStatisticsDatabaseFile; }
     void setIsNewResourceLoadStatisticsDatabaseFile(bool isNewResourceLoadStatisticsDatabaseFile) { m_isNewResourceLoadStatisticsDatabaseFile = isNewResourceLoadStatisticsDatabaseFile; }
     void removeDataForDomain(const RegistrableDomain&) override;
+    Vector<RegistrableDomain> allDomains() const final;
     bool domainIDExistsInDatabase(int);
     Optional<Vector<String>> checkForMissingTablesInSchema();
     void insertExpiredStatisticForTesting(const RegistrableDomain&, bool hasUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent) override;

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -1070,6 +1070,13 @@
     }
 }
 
+Vector<RegistrableDomain> ResourceLoadStatisticsMemoryStore::allDomains() const
+{
+    ASSERT(!RunLoop::isMain());
+
+    return copyToVector(m_resourceStatisticsMap.keys());
+}
+
 void ResourceLoadStatisticsMemoryStore::setPrevalentResource(const RegistrableDomain& domain)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -113,6 +113,7 @@
 
     void setLastSeen(const RegistrableDomain&, Seconds) override;
     void removeDataForDomain(const RegistrableDomain&) override;
+    Vector<RegistrableDomain> allDomains() const final;
     void insertExpiredStatisticForTesting(const RegistrableDomain&, bool hasUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent) override;
 
 private:

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -192,7 +192,9 @@
     virtual void setLastSeen(const RegistrableDomain& primaryDomain, Seconds) = 0;
 
     virtual void removeDataForDomain(const RegistrableDomain&) = 0;
-    
+
+    virtual Vector<RegistrableDomain> allDomains() const = 0;
+
     void didCreateNetworkProcess();
 
     const WebResourceLoadStatisticsStore& store() const { return m_store; }

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -1361,6 +1361,17 @@
     });
 }
 
+void WebResourceLoadStatisticsStore::registrableDomains(CompletionHandler<void(Vector<RegistrableDomain>&&)>&& completionHandler)
+{
+    ASSERT(RunLoop::isMain());
+    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
+        auto domains = m_statisticsStore ? m_statisticsStore->allDomains() : Vector<RegistrableDomain>();
+        postTaskReply([domains = crossThreadCopy(WTFMove(domains)), completionHandler = WTFMove(completionHandler)]() mutable {
+            completionHandler(WTFMove(domains));
+        });
+    });
+}
+
 void WebResourceLoadStatisticsStore::deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&& domainsToDeleteAndRestrictWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -219,6 +219,7 @@
     void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&);
     void removeDataForDomain(const RegistrableDomain, CompletionHandler<void()>&&);
     void deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
+    void registrableDomains(CompletionHandler<void(Vector<RegistrableDomain>&&)>&&);
     void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
     StorageAccessWasGranted grantStorageAccessInStorageSession(const SubFrameDomain&, const TopFrameDomain&, Optional<WebCore::FrameIdentifier>, WebCore::PageIdentifier, StorageAccessScope);
     void hasHadUserInteraction(const RegistrableDomain&, CompletionHandler<void(bool)>&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (263257 => 263258)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -1578,6 +1578,19 @@
         }
     }
 #endif
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
+        if (auto* session = networkSession(sessionID)) {
+            if (auto* resourceLoadStatistics = session->resourceLoadStatistics()) {
+                resourceLoadStatistics->registrableDomains([callbackAggregator = callbackAggregator.copyRef()](auto&& domains) mutable {
+                    while (!domains.isEmpty())
+                        callbackAggregator->m_websiteData.registrableDomainsWithResourceLoadStatistics.add(domains.takeLast());
+                });
+            }
+        }
+    }
+#endif
 }
 
 void NetworkProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, WallTime modifiedSince, CallbackID callbackID)

Modified: trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.cpp (263257 => 263258)


--- trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -28,6 +28,7 @@
 
 #include "ArgumentCoders.h"
 #include "WebsiteDataType.h"
+#include <WebCore/RegistrableDomain.h>
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/text/StringHash.h>
 
@@ -67,6 +68,9 @@
     encoder << hostNamesWithPluginData;
 #endif
     encoder << hostNamesWithHSTSCache;
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    encoder << registrableDomainsWithResourceLoadStatistics;
+#endif
 }
 
 bool WebsiteData::decode(IPC::Decoder& decoder, WebsiteData& result)
@@ -81,6 +85,10 @@
 #endif
     if (!decoder.decode(result.hostNamesWithHSTSCache))
         return false;
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    if (!decoder.decode(result.registrableDomainsWithResourceLoadStatistics))
+        return false;
+#endif
     return true;
 }
 

Modified: trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h (263257 => 263258)


--- trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <WebCore/RegistrableDomain.h>
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -59,6 +60,9 @@
     HashSet<String> hostNamesWithPluginData;
 #endif
     HashSet<String> hostNamesWithHSTSCache;
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    HashSet<WebCore::RegistrableDomain> registrableDomainsWithResourceLoadStatistics;
+#endif
 
     void encode(IPC::Encoder&) const;
     static WARN_UNUSED_RETURN bool decode(IPC::Decoder&, WebsiteData&);

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (263257 => 263258)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -72,7 +72,7 @@
 {
     WebKit::WebsiteDataRecord dataRecord;
     dataRecord.types.add(WebKit::WebsiteDataType::ResourceLoadStatistics);
-    dataRecord.displayName = WebKit::toImpl(host)->string();
+    dataRecord.addResourceLoadStatisticsRegistrableDomain(WebCore::RegistrableDomain::uncheckedCreateFromHost(WebKit::toImpl(host)->string()));
     Vector<WebKit::WebsiteDataRecord> dataRecords = { WTFMove(dataRecord) };
 
     OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::ResourceLoadStatistics;

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.cpp (263257 => 263258)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -28,7 +28,6 @@
 
 #include <WebCore/LocalizedStrings.h>
 #include <WebCore/PublicSuffix.h>
-#include <WebCore/RegistrableDomain.h>
 #include <WebCore/SecurityOrigin.h>
 
 #if PLATFORM(COCOA)
@@ -114,6 +113,14 @@
 #endif
 }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebsiteDataRecord::addResourceLoadStatisticsRegistrableDomain(const WebCore::RegistrableDomain& domain)
+{
+    types.add(WebsiteDataType::ResourceLoadStatistics);
+    resourceLoadStatisticsRegistrableDomains.add(domain);
+}
+#endif
+
 static inline bool hostIsInDomain(StringView host, StringView domain)
 {
     if (!host.endsWithIgnoringASCIICase(domain))

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.h (263257 => 263258)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.h	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.h	2020-06-19 07:49:23 UTC (rev 263258)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "WebsiteDataType.h"
+#include <WebCore/RegistrableDomain.h>
 #include <WebCore/SecurityOriginData.h>
 #include <WebCore/SecurityOriginHash.h>
 #include <wtf/HashMap.h>
@@ -36,7 +37,6 @@
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
-class RegistrableDomain;
 class SecurityOrigin;
 }
 
@@ -55,6 +55,9 @@
 #endif
     void addHSTSCacheHostname(const String& hostName);
     void addAlternativeServicesHostname(const String& hostName);
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    void addResourceLoadStatisticsRegistrableDomain(const WebCore::RegistrableDomain&);
+#endif
 
     String displayName;
     OptionSet<WebsiteDataType> types;
@@ -72,6 +75,9 @@
 #endif
     HashSet<String> HSTSCacheHostNames;
     HashSet<String> alternativeServicesHostNames;
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    HashSet<WebCore::RegistrableDomain> resourceLoadStatisticsRegistrableDomains;
+#endif
 
     bool matches(const WebCore::RegistrableDomain&) const;
     String topPrivatelyControlledDomain();

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (263257 => 263258)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -366,6 +366,20 @@
                 record.addHSTSCacheHostname(hostName);
             }
 
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+            for (const auto& domain : websiteData.registrableDomainsWithResourceLoadStatistics) {
+                auto displayName = WebsiteDataRecord::displayNameForHostName(domain.string());
+                if (!displayName)
+                    continue;
+
+                auto& record = m_websiteDataRecords.add(displayName, WebsiteDataRecord { }).iterator->value;
+                if (!record.displayName)
+                    record.displayName = WTFMove(displayName);
+
+                record.addResourceLoadStatisticsRegistrableDomain(domain);
+            }
+#endif
+
             callIfNeeded();
         }
 
@@ -996,7 +1010,8 @@
                     cookieHostNames.append(hostName);
                 for (auto& hostName : dataRecord.HSTSCacheHostNames)
                     HSTSCacheHostNames.append(hostName);
-                registrableDomains.append(WebCore::RegistrableDomain::uncheckedCreateFromHost(dataRecord.displayName));
+                for (auto& registrableDomain : dataRecord.resourceLoadStatisticsRegistrableDomains)
+                    registrableDomains.append(registrableDomain);
             }
 
             callbackAggregator->addPendingCallback();

Modified: trunk/Tools/ChangeLog (263257 => 263258)


--- trunk/Tools/ChangeLog	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Tools/ChangeLog	2020-06-19 07:49:23 UTC (rev 263258)
@@ -1,3 +1,15 @@
+2020-06-19  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Add support for fetching registrable domains with resource load statistics
+        https://bugs.webkit.org/show_bug.cgi?id=213291
+
+        Reviewed by Adrian Perez de Castro.
+
+        Update GLib ITP unit test to check also fetch and remove.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
+        (testWebsiteDataITP):
+
 2020-06-19  Tomoki Imai  <tomoki.i...@sony.com>
 
         Change my (Tomoki Imai's) status to committer

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp (263257 => 263258)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp	2020-06-19 07:43:12 UTC (rev 263257)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp	2020-06-19 07:49:23 UTC (rev 263258)
@@ -670,7 +670,7 @@
     g_rmdir(itpDirectory);
 
     g_assert_false(webkit_website_data_manager_get_itp_enabled(test->m_manager));
-    test->loadURI(kServer->getURIForPath("/").data());
+    test->loadURI(kServer->getURIForPath("/empty").data());
     test->waitUntilLoadFinished();
 
     webkit_website_data_manager_set_itp_enabled(test->m_manager, TRUE);
@@ -678,14 +678,28 @@
     g_assert_false(g_file_test(itpDirectory, G_FILE_TEST_IS_DIR));
     g_assert_false(g_file_test(itpLogFile.get(), G_FILE_TEST_IS_REGULAR));
 
-    test->loadURI(kServer->getURIForPath("/").data());
+    test->loadURI(kServer->getURIForPath("/empty").data());
     test->waitUntilLoadFinished();
 
     test->waitUntilFileChanged(itpLogFile.get(), G_FILE_MONITOR_EVENT_CREATED);
-
     g_assert_true(g_file_test(itpDirectory, G_FILE_TEST_IS_DIR));
     g_assert_true(g_file_test(itpLogFile.get(), G_FILE_TEST_IS_REGULAR));
 
+    GList* dataList = test->fetch(WEBKIT_WEBSITE_DATA_ITP);
+    g_assert_nonnull(dataList);
+    g_assert_cmpuint(g_list_length(dataList), ==, 1);
+    auto* data = ""
+    g_assert_nonnull(data);
+    WebKitSecurityOrigin* origin = webkit_security_origin_new_for_uri(kServer->getURIForPath("/").data());
+    g_assert_cmpstr(webkit_website_data_get_name(data), ==, webkit_security_origin_get_host(origin));
+    webkit_security_origin_unref(origin);
+
+    // Remove the registration.
+    GList removeList = { data, nullptr, nullptr };
+    test->remove(WEBKIT_WEBSITE_DATA_ITP, &removeList);
+    dataList = test->fetch(WEBKIT_WEBSITE_DATA_ITP);
+    g_assert_null(dataList);
+
     // Clear all.
     static const WebKitWebsiteDataTypes cacheAndITP = static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_ITP | WEBKIT_WEBSITE_DATA_MEMORY_CACHE | WEBKIT_WEBSITE_DATA_DISK_CACHE);
     test->clear(cacheAndITP, 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to