Remove Ad Click Attribution data when removing website data
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 00:13:00 +0000 (00:13 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 00:13:00 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197215
<rdar://problem/47668988>

Reviewed by Chris Dumez.

Source/WebKit:

This patch adds a new WebsiteDataType called AdClickAttributions and flags
it as owned by the network process.

The new website data type is added to the Cocoa API layer for
website data records management.

When either of the two WebsiteDataStore::removeData() functions calls
NetworkProcess::deleteWebsiteData() or
NetworkProcess::deleteWebsiteDataForOrigins() over IPC, the network
process now calls into AdClickAttributionManager::clear() and
AdClickAttributionManager::clearForRegistrableDomain() respectively,
if the website datatypes include WebsiteDataType::AdClickAttributions.

The patch removes a couple of completion handlers in NetworkSession function
calls are because those are not asynchronous.

* NetworkProcess/AdClickAttributionManager.cpp:
(WebKit::AdClickAttributionManager::clear):
(WebKit::AdClickAttributionManager::clearForRegistrableDomain):
(WebKit::AdClickAttributionManager::toString const):
* NetworkProcess/AdClickAttributionManager.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
(WebKit::NetworkProcess::clearAdClickAttribution):
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::clearAdClickAttribution):
(WebKit::NetworkSession::clearAdClickAttributionForRegistrableDomain):
* NetworkProcess/NetworkSession.h:
* Shared/WebsiteData/WebsiteData.cpp:
(WebKit::WebsiteData::ownerProcess):
* Shared/WebsiteData/WebsiteDataType.h:
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
(dataTypesToString):
* UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
(WebKit::toWebsiteDataType):
(WebKit::toWKWebsiteDataTypes):
* UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate]):

Tools:

This patch adds test infrastructure to delete Ad Click Attribution data
through WebsiteDataStore::removeData().

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::clearAdClickAttribution):
(WTR::TestRunner::clearAdClickAttributionsThroughWebsiteDataRemoval):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::clearAdClickAttributionsThroughWebsiteDataRemoval):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/adClickAttribution/clear-through-website-data-removal-expected.txt: Added.
* http/tests/adClickAttribution/clear-through-website-data-removal.html: Added.

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

24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp
Source/WebKit/NetworkProcess/AdClickAttributionManager.h
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/Shared/WebsiteData/WebsiteData.cpp
Source/WebKit/Shared/WebsiteData/WebsiteDataType.h
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 520f60e..75e5e06 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-23  John Wilander  <wilander@apple.com>
+
+        Remove Ad Click Attribution data when removing website data
+        https://bugs.webkit.org/show_bug.cgi?id=197215
+        <rdar://problem/47668988>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/adClickAttribution/clear-through-website-data-removal-expected.txt: Added.
+        * http/tests/adClickAttribution/clear-through-website-data-removal.html: Added.
+
 2019-04-23  Devin Rousso  <drousso@apple.com>
 
         ContentSecurityPolicy::logToConsole should include line/column number and source location
diff --git a/LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal-expected.txt b/LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal-expected.txt
new file mode 100644 (file)
index 0000000..e2ee6a9
--- /dev/null
@@ -0,0 +1,5 @@
+Tests that both unconverted and converted attributions are cleared on website data removal.
+
+
+
+No stored Ad Click Attribution data.
diff --git a/LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal.html b/LayoutTests/http/tests/adClickAttribution/clear-through-website-data-removal.html
new file mode 100644 (file)
index 0000000..79766c1
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AdClickAttributionEnabled=true ] -->
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src="/js-test-resources/ui-helper.js"></script>
+    <script src="resources/util.js"></script>
+</head>
+<body onload="setTimeout(runTest, 0)">
+<div id="description">Tests that both unconverted and converted attributions are cleared on website data removal.</div>
+<a id="targetLink">Link</a><br>
+<div id="output"></div>
+<script>
+    const path = "/adClickAttribution/clear-through-website-data-removal.html";
+    const configuration = [
+        {
+            href: "http://localhost:8000" + path + "?stepTwo",
+            adcampaignid: "3",
+            addestination: "http://localhost:8000"
+        },
+        {
+            href: "http://127.0.0.1:8000" + path + "?stepThree",
+            adcampaignid: "4",
+            addestination: "http://127.0.0.1:8000"
+        }
+    ];
+
+    prepareTest();
+
+    function configureLink(index) {
+        let linkElement = document.getElementById("targetLink");
+        linkElement.setAttribute("href", configuration[index].href);
+        linkElement.setAttribute("adcampaignid", configuration[index].adcampaignid);
+        linkElement.setAttribute("addestination", configuration[index].addestination);
+    }
+
+    function activateElement(elementID) {
+        var element = document.getElementById(elementID);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function () {
+            },
+            function () {
+                document.getElementById("output").innerText = "FAIL Promise rejected.";
+                tearDownAndFinish();
+            }
+        );
+    }
+
+    function runTest() {
+        if (window.testRunner) {
+            if (window.location.search === "") {
+                // First ad click 127.0.0.1 –> localhost.
+                configureLink(0);
+                activateElement("targetLink");
+            } else if (window.location.search === "?stepTwo") {
+                // Convert the first ad click with priority 4, then do a reverse ad click.
+                let imageElement = document.createElement("img");
+                imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12&priority=04";
+                imageElement.id = "pixel";
+                imageElement.onerror = function(e) {
+                    // Second ad click localhost –> 127.0.0.1.
+                    configureLink(1);
+                    activateElement("targetLink");
+                };
+                document.body.appendChild(imageElement);
+            } else if (window.location.search === "?stepThree") {
+                testRunner.clearAdClickAttributionsThroughWebsiteDataRemoval();
+                testRunner.dumpAdClickAttribution();
+                document.body.removeChild(document.getElementById("targetLink"));
+                tearDownAndFinish();
+            } else {
+                document.getElementById("output").innerText = "FAIL Unknown window.location.search == " + window.location.search + ".";
+                tearDownAndFinish();
+            }
+        } else {
+            document.getElementById("output").innerText = "FAIL No testRunner.";
+        }
+    }
+</script>
+</body>
+</html>
index 5bfb388..054d770 100644 (file)
@@ -1,3 +1,55 @@
+2019-04-23  John Wilander  <wilander@apple.com>
+
+        Remove Ad Click Attribution data when removing website data
+        https://bugs.webkit.org/show_bug.cgi?id=197215
+        <rdar://problem/47668988>
+
+        Reviewed by Chris Dumez.
+
+        This patch adds a new WebsiteDataType called AdClickAttributions and flags
+        it as owned by the network process.
+
+        The new website data type is added to the Cocoa API layer for
+        website data records management.
+
+        When either of the two WebsiteDataStore::removeData() functions calls
+        NetworkProcess::deleteWebsiteData() or
+        NetworkProcess::deleteWebsiteDataForOrigins() over IPC, the network
+        process now calls into AdClickAttributionManager::clear() and
+        AdClickAttributionManager::clearForRegistrableDomain() respectively,
+        if the website datatypes include WebsiteDataType::AdClickAttributions.
+
+        The patch removes a couple of completion handlers in NetworkSession function
+        calls are because those are not asynchronous.
+
+        * NetworkProcess/AdClickAttributionManager.cpp:
+        (WebKit::AdClickAttributionManager::clear):
+        (WebKit::AdClickAttributionManager::clearForRegistrableDomain):
+        (WebKit::AdClickAttributionManager::toString const):
+        * NetworkProcess/AdClickAttributionManager.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::deleteWebsiteData):
+        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
+        (WebKit::NetworkProcess::clearAdClickAttribution):
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::clearAdClickAttribution):
+        (WebKit::NetworkSession::clearAdClickAttributionForRegistrableDomain):
+        * NetworkProcess/NetworkSession.h:
+        * Shared/WebsiteData/WebsiteData.cpp:
+        (WebKit::WebsiteData::ownerProcess):
+        * Shared/WebsiteData/WebsiteDataType.h:
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
+        (dataTypesToString):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
+        (WebKit::toWebsiteDataType):
+        (WebKit::toWKWebsiteDataTypes):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (+[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate]):
+
 2019-04-23  Tim Horton  <timothy_horton@apple.com>
 
         Return annotated text checking strings via UIWKDocumentContext
index c799799..b6ed422 100644 (file)
@@ -169,12 +169,22 @@ void AdClickAttributionManager::firePendingConversionRequests()
         startTimer(nextTimeToFire);
 }
 
-void AdClickAttributionManager::clear(CompletionHandler<void()>&& completionHandler)
+void AdClickAttributionManager::clear()
 {
     m_firePendingConversionRequestsTimer.stop();
     m_unconvertedAdClickAttributionMap.clear();
     m_convertedAdClickAttributionMap.clear();
-    completionHandler();
+}
+
+void AdClickAttributionManager::clearForRegistrableDomain(const RegistrableDomain& domain)
+{
+    m_unconvertedAdClickAttributionMap.removeIf([&domain](auto& keyAndValue) {
+        return keyAndValue.key.first.registrableDomain == domain || keyAndValue.key.second.registrableDomain == domain;
+    });
+
+    m_convertedAdClickAttributionMap.removeIf([&domain](auto& keyAndValue) {
+        return keyAndValue.key.first.registrableDomain == domain || keyAndValue.key.second.registrableDomain == domain;
+    });
 }
 
 void AdClickAttributionManager::toString(CompletionHandler<void(String)>&& completionHandler) const
@@ -197,6 +207,8 @@ void AdClickAttributionManager::toString(CompletionHandler<void(String)>&& compl
 
     unsigned convertedAttributionNumber = 0;
     for (auto& attribution : m_convertedAdClickAttributionMap.values()) {
+        if (unconvertedAttributionNumber)
+            builder.append('\n');
         if (!convertedAttributionNumber)
             builder.appendLiteral("Converted Ad Click Attributions:\n");
         else
index 0b24cab..7ddd1fa 100644 (file)
@@ -57,7 +57,8 @@ public:
 
     void storeUnconverted(AdClickAttribution&&);
     void convert(const Source&, const Destination&, Conversion&&);
-    void clear(CompletionHandler<void()>&&);
+    void clear();
+    void clearForRegistrableDomain(const RegistrableDomain&);
     void toString(CompletionHandler<void(String)>&&) const;
     void setPingLoadFunction(Function<void(NetworkResourceLoadParameters&&, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&&)>&& pingLoadFunction) { m_pingLoadFunction = WTFMove(pingLoadFunction); }
     void setOverrideTimerForTesting(bool value) { m_isRunningTest = value; }
index fabc9ea..28078f4 100644 (file)
@@ -1425,6 +1425,11 @@ void NetworkProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<Websi
 
     if (websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases) || websiteDataTypes.contains(WebsiteDataType::DOMCache))
         clearStorageQuota(sessionID);
+
+    if (websiteDataTypes.contains(WebsiteDataType::AdClickAttributions)) {
+        if (auto* networkSession = this->networkSession(sessionID))
+            networkSession->clearAdClickAttribution();
+    }
 }
 
 static void clearDiskCacheEntries(NetworkCache::Cache* cache, const Vector<SecurityOriginData>& origins, CompletionHandler<void()>&& completionHandler)
@@ -1465,6 +1470,13 @@ void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, Optio
     }
 #endif
 
+    if (websiteDataTypes.contains(WebsiteDataType::AdClickAttributions)) {
+        if (auto* networkSession = this->networkSession(sessionID)) {
+            for (auto& originData : originDatas)
+                networkSession->clearAdClickAttributionForRegistrableDomain(RegistrableDomain::uncheckedCreateFromHost(originData.host));
+        }
+    }
+    
     auto clearTasksHandler = WTF::CallbackAggregator::create([this, callbackID] {
         parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
     });
@@ -2515,7 +2527,7 @@ void NetworkProcess::dumpAdClickAttribution(PAL::SessionID sessionID, Completion
 void NetworkProcess::clearAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
 {
     if (auto* session = networkSession(sessionID))
-        return session->clearAdClickAttribution(WTFMove(completionHandler));
+        session->clearAdClickAttribution();
     
     completionHandler();
 }
index f706213..337ad91 100644 (file)
@@ -158,9 +158,14 @@ void NetworkSession::dumpAdClickAttribution(CompletionHandler<void(String)>&& co
     m_adClickAttribution->toString(WTFMove(completionHandler));
 }
 
-void NetworkSession::clearAdClickAttribution(CompletionHandler<void()>&& completionHandler)
+void NetworkSession::clearAdClickAttribution()
 {
-    m_adClickAttribution->clear(WTFMove(completionHandler));
+    m_adClickAttribution->clear();
+}
+
+void NetworkSession::clearAdClickAttributionForRegistrableDomain(WebCore::RegistrableDomain&& domain)
+{
+    m_adClickAttribution->clearForRegistrableDomain(WTFMove(domain));
 }
 
 void NetworkSession::setAdClickAttributionOverrideTimerForTesting(bool value)
index 56ea2a0..4141349 100644 (file)
@@ -82,7 +82,8 @@ public:
     void storeAdClickAttribution(WebCore::AdClickAttribution&&);
     void convertAdClickAttribution(const WebCore::AdClickAttribution::Source&, const WebCore::AdClickAttribution::Destination&, WebCore::AdClickAttribution::Conversion&&);
     void dumpAdClickAttribution(CompletionHandler<void(String)>&&);
-    void clearAdClickAttribution(CompletionHandler<void()>&&);
+    void clearAdClickAttribution();
+    void clearAdClickAttributionForRegistrableDomain(WebCore::RegistrableDomain&&);
     void setAdClickAttributionOverrideTimerForTesting(bool value);
     void setAdClickAttributionConversionURLForTesting(URL&&);
 
index 060b6ec..5191cce 100644 (file)
@@ -128,6 +128,8 @@ WebsiteDataProcessType WebsiteData::ownerProcess(WebsiteDataType dataType)
         return WebsiteDataProcessType::Network;
     case WebsiteDataType::DeviceIdHashSalt:
         return WebsiteDataProcessType::UI;
+    case WebsiteDataType::AdClickAttributions:
+        return WebsiteDataProcessType::Network;
     }
 
     RELEASE_ASSERT_NOT_REACHED();
index 601bb44..2006805 100644 (file)
@@ -50,6 +50,7 @@ enum class WebsiteDataType {
 #endif
     DOMCache = 1 << 15,
     DeviceIdHashSalt = 1 << 16,
+    AdClickAttributions = 1 << 17,
 };
 
 };
index bc9a576..2dad564 100644 (file)
@@ -658,3 +658,12 @@ void WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(WKWebsiteDataStoreR
     WebKit::toImpl(dataStoreRef)->websiteDataStore().setMockWebAuthenticationConfiguration(WTFMove(configuration));
 #endif
 }
+
+void WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction callback)
+{
+    OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::AdClickAttributions;
+    WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, WallTime::fromRawSeconds(0), [context, callback] {
+        callback(context);
+    });
+}
+
index 5390a22..c76eb2d 100644 (file)
@@ -131,6 +131,9 @@ WK_EXPORT void WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(WKWebsite
 
 WK_EXPORT void WKWebsiteDataStoreClearAllDeviceOrientationPermissions(WKWebsiteDataStoreRef dataStoreRef);
 
+typedef void (*WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction callback);
+
 #ifdef __cplusplus
 }
 #endif
index 61a971a..e579673 100644 (file)
@@ -48,6 +48,7 @@ NSString * const _WKWebsiteDataTypeHSTSCache = @"_WKWebsiteDataTypeHSTSCache";
 NSString * const _WKWebsiteDataTypeSearchFieldRecentSearches = @"_WKWebsiteDataTypeSearchFieldRecentSearches";
 NSString * const _WKWebsiteDataTypeResourceLoadStatistics = @"_WKWebsiteDataTypeResourceLoadStatistics";
 NSString * const _WKWebsiteDataTypeCredentials = @"_WKWebsiteDataTypeCredentials";
+NSString * const _WKWebsiteDataTypeAdClickAttributions = @"_WKWebsiteDataTypeAdClickAttributions";
 
 #if PLATFORM(MAC)
 NSString * const _WKWebsiteDataTypePlugInData = @"_WKWebsiteDataTypePlugInData";
@@ -100,6 +101,8 @@ static NSString *dataTypesToString(NSSet *dataTypes)
         [array addObject:@"Resource Load Statistics"];
     if ([dataTypes containsObject:_WKWebsiteDataTypeCredentials])
         [array addObject:@"Credentials"];
+    if ([dataTypes containsObject:_WKWebsiteDataTypeAdClickAttributions])
+        [array addObject:@"Ad Click Attributions"];
 
     return [array componentsJoinedByString:@", "];
 }
index 7d23945..56da893 100644 (file)
@@ -74,6 +74,8 @@ static inline Optional<WebsiteDataType> toWebsiteDataType(NSString *websiteDataT
         return WebsiteDataType::ResourceLoadStatistics;
     if ([websiteDataType isEqualToString:_WKWebsiteDataTypeCredentials])
         return WebsiteDataType::Credentials;
+    if ([websiteDataType isEqualToString:_WKWebsiteDataTypeAdClickAttributions])
+        return WebsiteDataType::AdClickAttributions;
     return WTF::nullopt;
 }
 
@@ -129,6 +131,8 @@ static inline RetainPtr<NSSet> toWKWebsiteDataTypes(OptionSet<WebKit::WebsiteDat
         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeResourceLoadStatistics];
     if (websiteDataTypes.contains(WebsiteDataType::Credentials))
         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeCredentials];
+    if (websiteDataTypes.contains(WebsiteDataType::AdClickAttributions))
+        [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeAdClickAttributions];
 
     return wkWebsiteDataTypes;
 }
index f11e480..ebe5c60 100644 (file)
@@ -34,6 +34,7 @@ WK_EXTERN NSString * const _WKWebsiteDataTypeMediaKeys WK_API_AVAILABLE(macos(10
 WK_EXTERN NSString * const _WKWebsiteDataTypeSearchFieldRecentSearches WK_API_AVAILABLE(macos(10.12), ios(10.0));
 WK_EXTERN NSString * const _WKWebsiteDataTypeResourceLoadStatistics WK_API_AVAILABLE(macos(10.12), ios(10.0));
 WK_EXTERN NSString * const _WKWebsiteDataTypeCredentials WK_API_AVAILABLE(macos(10.13), ios(11.0));
+WK_EXTERN NSString * const _WKWebsiteDataTypeAdClickAttributions WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 
 #if !TARGET_OS_IPHONE
index 26e1182..7dd4119 100644 (file)
@@ -202,7 +202,7 @@ static Vector<WebKit::WebsiteDataRecord> toWebsiteDataRecords(NSArray *dataRecor
     static dispatch_once_t onceToken;
     static NSSet *allWebsiteDataTypes;
     dispatch_once(&onceToken, ^ {
-        auto *privateTypes = @[_WKWebsiteDataTypeHSTSCache, _WKWebsiteDataTypeMediaKeys, _WKWebsiteDataTypeSearchFieldRecentSearches, _WKWebsiteDataTypeResourceLoadStatistics, _WKWebsiteDataTypeCredentials
+        auto *privateTypes = @[_WKWebsiteDataTypeHSTSCache, _WKWebsiteDataTypeMediaKeys, _WKWebsiteDataTypeSearchFieldRecentSearches, _WKWebsiteDataTypeResourceLoadStatistics, _WKWebsiteDataTypeCredentials, _WKWebsiteDataTypeAdClickAttributions
 #if !TARGET_OS_IPHONE
         , _WKWebsiteDataTypePlugInData
 #endif
index e1cf310..4f02e64 100644 (file)
@@ -1,3 +1,25 @@
+2019-04-23  John Wilander  <wilander@apple.com>
+
+        Remove Ad Click Attribution data when removing website data
+        https://bugs.webkit.org/show_bug.cgi?id=197215
+        <rdar://problem/47668988>
+
+        Reviewed by Chris Dumez.
+
+        This patch adds test infrastructure to delete Ad Click Attribution data
+        through WebsiteDataStore::removeData().
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::clearAdClickAttribution):
+        (WTR::TestRunner::clearAdClickAttributionsThroughWebsiteDataRemoval):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::clearAdClickAttributionsThroughWebsiteDataRemoval):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2019-04-23  Jonathan Bedard  <jbedard@apple.com>
 
         webkitpy: Kill unresponsive worker processes
index 3cb877c..f58f07f 100644 (file)
@@ -386,6 +386,7 @@ interface TestRunner {
 
     // Ad Click Attribution
     void clearAdClickAttribution();
+    void clearAdClickAttributionsThroughWebsiteDataRemoval();
     void setAdClickAttributionOverrideTimerForTesting(boolean value);
     void setAdClickAttributionConversionURLForTesting(DOMString url);
 };
index 00aac4d..bee9daf 100644 (file)
@@ -2876,6 +2876,12 @@ void TestRunner::clearAdClickAttribution()
     WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, nullptr);
 }
 
+void TestRunner::clearAdClickAttributionsThroughWebsiteDataRemoval()
+{
+    auto messageName = adoptWK(WKStringCreateWithUTF8CString("ClearAdClickAttributionsThroughWebsiteDataRemoval"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
+}
+
 void TestRunner::setAdClickAttributionOverrideTimerForTesting(bool value)
 {
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetAdClickAttributionOverrideTimerForTesting"));
index 0daec00..269c69b 100644 (file)
@@ -500,6 +500,7 @@ public:
     // Ad Click Attribution.
     void dumpAdClickAttribution();
     void clearAdClickAttribution();
+    void clearAdClickAttributionsThroughWebsiteDataRemoval();
     void setAdClickAttributionOverrideTimerForTesting(bool value);
     void setAdClickAttributionConversionURLForTesting(JSStringRef);
 
index 196792f..b811e59 100644 (file)
@@ -3605,6 +3605,14 @@ void TestController::clearAdClickAttribution()
     runUntil(callbackContext.done, noTimeout);
 }
 
+void TestController::clearAdClickAttributionsThroughWebsiteDataRemoval()
+{
+    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+    AdClickAttributionVoidCallbackContext callbackContext(*this);
+    WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(dataStore, &callbackContext, adClickAttributionVoidCallback);
+    runUntil(callbackContext.done, noTimeout);
+}
+
 void TestController::setAdClickAttributionOverrideTimerForTesting(bool value)
 {
     AdClickAttributionVoidCallbackContext callbackContext(*this);
index d7df524..f269b39 100644 (file)
@@ -314,6 +314,7 @@ public:
 
     String dumpAdClickAttribution();
     void clearAdClickAttribution();
+    void clearAdClickAttributionsThroughWebsiteDataRemoval();
     void setAdClickAttributionOverrideTimerForTesting(bool value);
     void setAdClickAttributionConversionURLForTesting(WKURLRef);
 
index bcfd009..862b9a5 100644 (file)
@@ -1643,7 +1643,12 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         TestController::singleton().clearAdClickAttribution();
         return nullptr;
     }
-    
+
+    if (WKStringIsEqualToUTF8CString(messageName, "ClearAdClickAttributionsThroughWebsiteDataRemoval")) {
+        TestController::singleton().clearAdClickAttributionsThroughWebsiteDataRemoval();
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetAdClickAttributionOverrideTimerForTesting")) {
         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
         WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);