Title: [282884] trunk
Revision
282884
Author
commit-qu...@webkit.org
Date
2021-09-22 14:32:16 -0700 (Wed, 22 Sep 2021)

Log Message

PCM should include the bundle ID of the app from which it originated
https://bugs.webkit.org/show_bug.cgi?id=230576
<rdar://83065221>

Patch by Alex Christensen <achristen...@webkit.org> on 2021-09-22
Reviewed by Kate Cheney.

Source/WebCore:

This adds infrastructure to store the bundle ID of the application.
In another patch I'm going to use that to prevent PCMs from one app from overwriting PCMs from another app during attribution.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parsePrivateClickMeasurement const):
* loader/PrivateClickMeasurement.cpp:
(WebCore::PrivateClickMeasurement::isolatedCopy const):
* loader/PrivateClickMeasurement.h:
(WebCore::PrivateClickMeasurement::PrivateClickMeasurement):
(WebCore::PrivateClickMeasurement::attributionTriggerData const):
(WebCore::PrivateClickMeasurement::sourceApplicationBundleID const):
(WebCore::PrivateClickMeasurement::encode const):
(WebCore::PrivateClickMeasurement::decode):
(WebCore::PrivateClickMeasurement::attributionTriggerData): Deleted.

Source/WebKit:

* NetworkProcess/DatabaseUtilities.cpp:
(WebKit::DatabaseUtilities::buildPrivateClickMeasurementFromDatabase const):
(WebKit::DatabaseUtilities::buildPrivateClickMeasurementFromDatabase): Deleted.
* NetworkProcess/DatabaseUtilities.h:
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
(WebKit::PCM::Database::Database):
(WebKit::PCM::Database::insertPrivateClickMeasurement):
(WebKit::PCM::Database::privateClickMeasurementToStringForTesting const):
(WebKit::PCM::Database::attributionToStringForTesting const):
(WebKit::PCM::Database::addBundleIDColumnIfNecessary):
(WebKit::PCM::Database::columnsForTable):
(WebKit::PCM::Database::addMissingColumnToTable):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:applicationBundleID:]):
(-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]): Deleted.
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _setEphemeralUIEventAttribution:]):
(-[WKWebView _setEphemeralUIEventAttribution:forApplicationWithBundleID:]):

Tools:

* TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm:
(pollUntilPCMIsMigrated):

LayoutTests:

* http/tests/contentextensions/block-private-click-measurement-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt:
* http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt:
* http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt:
* http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt:
* http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt:
* http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt:
* http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt:
* http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt:
* http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt:
* http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282883 => 282884)


--- trunk/LayoutTests/ChangeLog	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/ChangeLog	2021-09-22 21:32:16 UTC (rev 282884)
@@ -1,3 +1,27 @@
+2021-09-22  Alex Christensen  <achristen...@webkit.org>
+
+        PCM should include the bundle ID of the app from which it originated
+        https://bugs.webkit.org/show_bug.cgi?id=230576
+        <rdar://83065221>
+
+        Reviewed by Kate Cheney.
+
+        * http/tests/contentextensions/block-private-click-measurement-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt:
+        * http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt:
+        * http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt:
+        * http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt:
+        * http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt:
+        * http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt:
+        * http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt:
+        * http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt:
+        * http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt:
+        * http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt:
+
 2021-09-22  Gabriel Nava Marino  <gnavamar...@apple.com>
 
         RenderListMarker::imageChanged RenderBox image handling

Modified: trunk/LayoutTests/http/tests/contentextensions/block-private-click-measurement-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/contentextensions/block-private-click-measurement-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/contentextensions/block-private-click-measurement-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -15,3 +15,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -7,3 +7,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -12,3 +12,4 @@
 Attribution trigger data: 12
 Attribution priority: 0
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 0
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 3
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 3
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 0
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -13,3 +13,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -13,3 +13,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -13,3 +13,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 4
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 4
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 4
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -9,3 +9,4 @@
 Attribution trigger data: 12
 Attribution priority: 4
 Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt (282883 => 282884)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -7,3 +7,4 @@
 Attribute on site: localhost
 Source ID: 3
 No attribution trigger data.
+Application bundle identifier: com.apple.WebKit.WebKitTestRunner

Copied: trunk/LayoutTests/platform/ios/http/tests/contentextensions/block-private-click-measurement-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/contentextensions/block-private-click-measurement-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/contentextensions/block-private-click-measurement-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/contentextensions/block-private-click-measurement-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,18 @@
+CONSOLE MESSAGE: Blocked by content extension
+CONSOLE MESSAGE: Cannot load image https://127.0.0.1:8443/privateClickMeasurement/resources/redirectToConversion.py?conversionData=12 due to access control checks.
+Tests that private click measurement redirects to well-known location don't trigger a conversion if they are blocked by content blockers.
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Attribution not received - timed out.
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-cross-site-image-redirect-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,10 @@
+Tests that triggering of private click measurement attributions through cross-site redirects do not work.
+
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,15 @@
+CONSOLE MESSAGE: [Private Click Measurement] Conversion was not accepted because the URL path contained unrecognized parts.
+CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
+CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:8443/.well-known/private-click-measurement/trigger-attribution/whatever due to access control checks.
+Tests triggering of private click measurement attributions with fetch on pagehide.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 0
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-ephemeral-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests triggering of ephemeral private click measurement attributions.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 0
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-in-new-window-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests triggering of private click measurement attributions in a new window.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 3
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-with-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests triggering of private click measurement attributions with priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 3
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/attribution-conversion-through-image-redirect-without-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests triggering of private click measurement attributions without priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 0
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/conversion-disabled-in-ephemeral-session-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,16 @@
+Tests that stored attributions cannot be converted in an ephemeral session.
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Attribution not received - timed out.
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-null-content-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,16 @@
+Tests that the presence of a source nonce triggers a token signing request.
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Token signing request not received - timed out.
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/private-click-measurement-with-source-nonce-wrong-content-type-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,16 @@
+Tests that the presence of a source nonce triggers a token signing request.
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Token signing request not received - timed out.
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-higher-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests that a second attribution with higher priority replaces an older with lower priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 4
+Attribution trigger data: 12
+Attribution priority: 4
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-attribution-converted-with-lower-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests that a second attribution with lower priority does not replace an older with higher priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 4
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-higher-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests that the attribution is updated if it gets a second attribution with higher priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 4
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/second-conversion-with-lower-priority-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,12 @@
+Tests that the attribution is not updated if it gets a second attribution with lower priority.
+
+
+Attributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+Attribution trigger data: 12
+Attribution priority: 4
+Attribution earliest time to send: Within 24-48 hours
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Copied: trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt (from rev 282883, trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt) (0 => 282884)


--- trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/http/tests/privateClickMeasurement/store-private-click-measurement-expected.txt	2021-09-22 21:32:16 UTC (rev 282884)
@@ -0,0 +1,10 @@
+Tests storage of private click measurement.
+
+
+Unattributed Private Click Measurements:
+WebCore::PrivateClickMeasurement 1
+Source site: 127.0.0.1
+Attribute on site: localhost
+Source ID: 3
+No attribution trigger data.
+Application bundle identifier: org.webkit.WebKitTestRunnerApp

Modified: trunk/Source/WebCore/ChangeLog (282883 => 282884)


--- trunk/Source/WebCore/ChangeLog	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebCore/ChangeLog	2021-09-22 21:32:16 UTC (rev 282884)
@@ -1,3 +1,26 @@
+2021-09-22  Alex Christensen  <achristen...@webkit.org>
+
+        PCM should include the bundle ID of the app from which it originated
+        https://bugs.webkit.org/show_bug.cgi?id=230576
+        <rdar://83065221>
+
+        Reviewed by Kate Cheney.
+
+        This adds infrastructure to store the bundle ID of the application.
+        In another patch I'm going to use that to prevent PCMs from one app from overwriting PCMs from another app during attribution.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::parsePrivateClickMeasurement const):
+        * loader/PrivateClickMeasurement.cpp:
+        (WebCore::PrivateClickMeasurement::isolatedCopy const):
+        * loader/PrivateClickMeasurement.h:
+        (WebCore::PrivateClickMeasurement::PrivateClickMeasurement):
+        (WebCore::PrivateClickMeasurement::attributionTriggerData const):
+        (WebCore::PrivateClickMeasurement::sourceApplicationBundleID const):
+        (WebCore::PrivateClickMeasurement::encode const):
+        (WebCore::PrivateClickMeasurement::decode):
+        (WebCore::PrivateClickMeasurement::attributionTriggerData): Deleted.
+
 2021-09-22  Chris Dumez  <cdu...@apple.com>
 
         Drop makeRef() and use Ref { } instead

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (282883 => 282884)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-09-22 21:32:16 UTC (rev 282884)
@@ -47,6 +47,7 @@
 #include "RegistrableDomain.h"
 #include "RenderImage.h"
 #include "ResourceRequest.h"
+#include "RuntimeApplicationChecks.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGImage.h"
 #include "ScriptController.h"
@@ -449,7 +450,12 @@
         return std::nullopt;
     }
 
-    auto privateClickMeasurement = PrivateClickMeasurement { SourceID(attributionSourceID.value()), SourceSite(WTFMove(documentRegistrableDomain)), AttributionDestinationSite(destinationURL) };
+#if PLATFORM(COCOA)
+    auto bundleID = applicationBundleIdentifier();
+#else
+    String bundleID;
+#endif
+    auto privateClickMeasurement = PrivateClickMeasurement { SourceID(attributionSourceID.value()), SourceSite(WTFMove(documentRegistrableDomain)), AttributionDestinationSite(destinationURL), bundleID };
 
     auto attributionSourceNonceAttr = attributeWithoutSynchronization(attributionsourcenonceAttr);
     if (!attributionSourceNonceAttr.isEmpty()) {

Modified: trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp (282883 => 282884)


--- trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp	2021-09-22 21:32:16 UTC (rev 282884)
@@ -101,6 +101,7 @@
     copy.m_ephemeralSourceNonce = crossThreadCopy(m_ephemeralSourceNonce);
     copy.m_sourceUnlinkableToken = m_sourceUnlinkableToken.isolatedCopy();
     copy.m_sourceSecretToken = crossThreadCopy(m_sourceSecretToken);
+    copy.m_sourceApplicationBundleID = m_sourceApplicationBundleID.isolatedCopy();
     return copy;
 }
 

Modified: trunk/Source/WebCore/loader/PrivateClickMeasurement.h (282883 => 282884)


--- trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-09-22 21:32:16 UTC (rev 282884)
@@ -312,7 +312,7 @@
     };
 
     PrivateClickMeasurement() = default;
-    PrivateClickMeasurement(SourceID sourceID, const SourceSite& sourceSite, const AttributionDestinationSite& destinationSite, String&& sourceDescription = { }, String&& purchaser = { }, WallTime timeOfAdClick = WallTime::now(), PrivateClickMeasurementAttributionEphemeral isEphemeral = PrivateClickMeasurementAttributionEphemeral::No)
+    PrivateClickMeasurement(SourceID sourceID, const SourceSite& sourceSite, const AttributionDestinationSite& destinationSite, const String& sourceApplicationBundleID, String&& sourceDescription = { }, String&& purchaser = { }, WallTime timeOfAdClick = WallTime::now(), PrivateClickMeasurementAttributionEphemeral isEphemeral = PrivateClickMeasurementAttributionEphemeral::No)
         : m_sourceID { sourceID }
         , m_sourceSite { sourceSite }
         , m_destinationSite { destinationSite }
@@ -320,6 +320,7 @@
         , m_purchaser { WTFMove(purchaser) }
         , m_timeOfAdClick { timeOfAdClick }
         , m_isEphemeral { isEphemeral }
+        , m_sourceApplicationBundleID { sourceApplicationBundleID }
     {
     }
 
@@ -337,8 +338,9 @@
     AttributionTimeToSendData timesToSend() const { return m_timesToSend; };
     void setTimesToSend(AttributionTimeToSendData data) { m_timesToSend = data; }
     const SourceID& sourceID() const { return m_sourceID; }
-    std::optional<AttributionTriggerData> attributionTriggerData() { return m_attributionTriggerData; }
+    const std::optional<AttributionTriggerData>& attributionTriggerData() const { return m_attributionTriggerData; }
     void setAttribution(AttributionTriggerData&& attributionTriggerData) { m_attributionTriggerData = WTFMove(attributionTriggerData); }
+    const String& sourceApplicationBundleID() const { return m_sourceApplicationBundleID; }
 
     const String& sourceDescription() const { return m_sourceDescription; }
     const String& purchaser() const { return m_purchaser; }
@@ -417,6 +419,7 @@
     std::optional<EphemeralSourceNonce> m_ephemeralSourceNonce;
     SourceUnlinkableToken m_sourceUnlinkableToken;
     std::optional<SourceSecretToken> m_sourceSecretToken;
+    String m_sourceApplicationBundleID;
 };
 
 template<class Encoder>
@@ -431,6 +434,7 @@
         << m_ephemeralSourceNonce
         << m_isEphemeral
         << m_attributionTriggerData
+        << m_sourceApplicationBundleID
         << m_timesToSend;
 }
 
@@ -481,7 +485,12 @@
     decoder >> attributionTriggerData;
     if (!attributionTriggerData)
         return std::nullopt;
-    
+
+    std::optional<String> sourceApplicationBundleID;
+    decoder >> sourceApplicationBundleID;
+    if (!sourceApplicationBundleID)
+        return std::nullopt;
+
     std::optional<AttributionTimeToSendData> timesToSend;
     decoder >> timesToSend;
     if (!timesToSend)
@@ -491,6 +500,7 @@
         SourceID { WTFMove(*sourceID) },
         SourceSite { WTFMove(*sourceRegistrableDomain) },
         AttributionDestinationSite { WTFMove(*destinationRegistrableDomain) },
+        WTFMove(*sourceApplicationBundleID),
         WTFMove(*sourceDescription),
         WTFMove(*purchaser),
         WTFMove(*timeOfAdClick),

Modified: trunk/Source/WebKit/ChangeLog (282883 => 282884)


--- trunk/Source/WebKit/ChangeLog	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/ChangeLog	2021-09-22 21:32:16 UTC (rev 282884)
@@ -1,5 +1,35 @@
 2021-09-22  Alex Christensen  <achristen...@webkit.org>
 
+        PCM should include the bundle ID of the app from which it originated
+        https://bugs.webkit.org/show_bug.cgi?id=230576
+        <rdar://83065221>
+
+        Reviewed by Kate Cheney.
+
+        * NetworkProcess/DatabaseUtilities.cpp:
+        (WebKit::DatabaseUtilities::buildPrivateClickMeasurementFromDatabase const):
+        (WebKit::DatabaseUtilities::buildPrivateClickMeasurementFromDatabase): Deleted.
+        * NetworkProcess/DatabaseUtilities.h:
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
+        (WebKit::PCM::Database::Database):
+        (WebKit::PCM::Database::insertPrivateClickMeasurement):
+        (WebKit::PCM::Database::privateClickMeasurementToStringForTesting const):
+        (WebKit::PCM::Database::attributionToStringForTesting const):
+        (WebKit::PCM::Database::addBundleIDColumnIfNecessary):
+        (WebKit::PCM::Database::columnsForTable):
+        (WebKit::PCM::Database::addMissingColumnToTable):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+        (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:applicationBundleID:]):
+        (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]): Deleted.
+        * UIProcess/API/ios/WKWebViewIOS.mm:
+        (-[WKWebView _setEphemeralUIEventAttribution:]):
+        (-[WKWebView _setEphemeralUIEventAttribution:forApplicationWithBundleID:]):
+
+2021-09-22  Alex Christensen  <achristen...@webkit.org>
+
         Move PCMDaemon to WebKit.framework and rename it to AdAttributionDaemon
         https://bugs.webkit.org/show_bug.cgi?id=230516
 

Modified: trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp (282883 => 282884)


--- trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp	2021-09-22 21:32:16 UTC (rev 282884)
@@ -137,7 +137,7 @@
         m_database.interrupt();
 }
 
-WebCore::PrivateClickMeasurement DatabaseUtilities::buildPrivateClickMeasurementFromDatabase(WebCore::SQLiteStatement& statement, PrivateClickMeasurementAttributionType attributionType)
+WebCore::PrivateClickMeasurement DatabaseUtilities::buildPrivateClickMeasurementFromDatabase(WebCore::SQLiteStatement& statement, PrivateClickMeasurementAttributionType attributionType) const
 {
     ASSERT(!RunLoop::isMain());
     auto sourceSiteDomain = getDomainStringFromDomainID(statement.columnInt(0));
@@ -147,9 +147,19 @@
     auto token = attributionType == PrivateClickMeasurementAttributionType::Attributed ? statement.columnText(7) : statement.columnText(4);
     auto signature = attributionType == PrivateClickMeasurementAttributionType::Attributed ? statement.columnText(8) : statement.columnText(5);
     auto keyID = attributionType == PrivateClickMeasurementAttributionType::Attributed ? statement.columnText(9) : statement.columnText(6);
+    auto bundleID = attributionType == PrivateClickMeasurementAttributionType::Attributed ? statement.columnText(11) : statement.columnText(7);
 
-    WebCore::PrivateClickMeasurement attribution(WebCore::PrivateClickMeasurement::SourceID(sourceID), WebCore::PrivateClickMeasurement::SourceSite(WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString(sourceSiteDomain)), WebCore::PrivateClickMeasurement::AttributionDestinationSite(WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString(destinationSiteDomain)), { }, { }, WallTime::fromRawSeconds(timeOfAdClick));
+    // Safari was the only application that used PCM when it was stored with ResourceLoadStatistics.
+#if PLATFORM(MAC)
+    constexpr auto safariBundleID = "com.apple.Safari"_s;
+#else
+    constexpr auto safariBundleID = "com.apple.mobilesafari"_s;
+#endif
+    if (bundleID.isEmpty())
+        bundleID = safariBundleID;
 
+    WebCore::PrivateClickMeasurement attribution(WebCore::PrivateClickMeasurement::SourceID(sourceID), WebCore::PrivateClickMeasurement::SourceSite(WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString(sourceSiteDomain)), WebCore::PrivateClickMeasurement::AttributionDestinationSite(WebCore::RegistrableDomain::uncheckedCreateFromRegistrableDomainString(destinationSiteDomain)), bundleID, { }, { }, WallTime::fromRawSeconds(timeOfAdClick));
+
     if (attributionType == PrivateClickMeasurementAttributionType::Attributed) {
         auto attributionTriggerData = statement.columnInt(3);
         auto priority = statement.columnInt(4);

Modified: trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.h (282883 => 282884)


--- trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.h	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.h	2021-09-22 21:32:16 UTC (rev 282884)
@@ -55,7 +55,7 @@
     virtual void destroyStatements() = 0;
     virtual String getDomainStringFromDomainID(unsigned) const = 0;
 
-    WebCore::PrivateClickMeasurement buildPrivateClickMeasurementFromDatabase(WebCore::SQLiteStatement&, PrivateClickMeasurementAttributionType);
+    WebCore::PrivateClickMeasurement buildPrivateClickMeasurementFromDatabase(WebCore::SQLiteStatement&, PrivateClickMeasurementAttributionType) const;
 
     const String m_storageFilePath;
     mutable WebCore::SQLiteDatabase m_database;

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp (282883 => 282884)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp	2021-09-22 21:32:16 UTC (rev 282884)
@@ -40,9 +40,9 @@
 
 constexpr auto setUnattributedPrivateClickMeasurementAsExpiredQuery = "UPDATE UnattributedPrivateClickMeasurement SET timeOfAdClick = -1.0"_s;
 constexpr auto insertUnattributedPrivateClickMeasurementQuery = "INSERT OR REPLACE INTO UnattributedPrivateClickMeasurement (sourceSiteDomainID, destinationSiteDomainID, "
-    "sourceID, timeOfAdClick, token, signature, keyID) VALUES (?, ?, ?, ?, ?, ?, ?)"_s;
+    "sourceID, timeOfAdClick, token, signature, keyID, sourceApplicationBundleID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"_s;
 constexpr auto insertAttributedPrivateClickMeasurementQuery = "INSERT OR REPLACE INTO AttributedPrivateClickMeasurement (sourceSiteDomainID, destinationSiteDomainID, "
-    "sourceID, attributionTriggerData, priority, timeOfAdClick, earliestTimeToSendToSource, token, signature, keyID, earliestTimeToSendToDestination) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s;
+    "sourceID, attributionTriggerData, priority, timeOfAdClick, earliestTimeToSendToSource, token, signature, keyID, earliestTimeToSendToDestination, sourceApplicationBundleID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s;
 constexpr auto findUnattributedQuery = "SELECT * FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
 constexpr auto findAttributedQuery = "SELECT * FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
 constexpr auto removeUnattributedQuery = "DELETE FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
@@ -59,13 +59,13 @@
 constexpr auto domainStringFromDomainIDQuery = "SELECT registrableDomain FROM PCMObservedDomains WHERE domainID = ?"_s;
 constexpr auto createUnattributedPrivateClickMeasurement = "CREATE TABLE UnattributedPrivateClickMeasurement ("
     "sourceSiteDomainID INTEGER NOT NULL, destinationSiteDomainID INTEGER NOT NULL, sourceID INTEGER NOT NULL, "
-    "timeOfAdClick REAL NOT NULL, token TEXT, signature TEXT, keyID TEXT, FOREIGN KEY(sourceSiteDomainID) "
+    "timeOfAdClick REAL NOT NULL, token TEXT, signature TEXT, keyID TEXT, sourceApplicationBundleID TEXT, FOREIGN KEY(sourceSiteDomainID) "
     "REFERENCES PCMObservedDomains(domainID) ON DELETE CASCADE, FOREIGN KEY(destinationSiteDomainID) REFERENCES "
     "PCMObservedDomains(domainID) ON DELETE CASCADE)"_s;
 constexpr auto createAttributedPrivateClickMeasurement = "CREATE TABLE AttributedPrivateClickMeasurement ("
     "sourceSiteDomainID INTEGER NOT NULL, destinationSiteDomainID INTEGER NOT NULL, sourceID INTEGER NOT NULL, "
     "attributionTriggerData INTEGER NOT NULL, priority INTEGER NOT NULL, timeOfAdClick REAL NOT NULL, "
-    "earliestTimeToSendToSource REAL, token TEXT, signature TEXT, keyID TEXT, earliestTimeToSendToDestination REAL, "
+    "earliestTimeToSendToSource REAL, token TEXT, signature TEXT, keyID TEXT, earliestTimeToSendToDestination REAL, sourceApplicationBundleID TEXT, "
     "FOREIGN KEY(sourceSiteDomainID) REFERENCES PCMObservedDomains(domainID) ON DELETE CASCADE, FOREIGN KEY(destinationSiteDomainID) REFERENCES "
     "PCMObservedDomains(domainID) ON DELETE CASCADE)"_s;
 constexpr auto createUniqueIndexUnattributedPrivateClickMeasurement = "CREATE UNIQUE INDEX IF NOT EXISTS UnattributedPrivateClickMeasurement_sourceSiteDomainID_destinationSiteDomainID on UnattributedPrivateClickMeasurement ( sourceSiteDomainID, destinationSiteDomainID )"_s;
@@ -88,6 +88,7 @@
     ASSERT(!RunLoop::isMain());
     openDatabaseAndCreateSchemaIfNecessary();
     enableForeignKeys();
+    addBundleIDColumnIfNecessary();
     allDatabases().add(this);
 }
 
@@ -166,6 +167,7 @@
             || statement->bindText(9, sourceUnlinkableToken ? sourceUnlinkableToken->signatureBase64URL : emptyString()) != SQLITE_OK
             || statement->bindText(10, sourceUnlinkableToken ? sourceUnlinkableToken->keyIDBase64URL : emptyString()) != SQLITE_OK
             || statement->bindDouble(11, destinationEarliestTimeToSend) != SQLITE_OK
+            || statement->bindText(12, attribution.sourceApplicationBundleID()) != SQLITE_OK
             || statement->step() != SQLITE_DONE) {
             RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::insertPrivateClickMeasurement insertAttributedPrivateClickMeasurementQuery, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
             ASSERT_NOT_REACHED();
@@ -184,6 +186,7 @@
         || statement->bindText(5, sourceUnlinkableToken ? sourceUnlinkableToken->tokenBase64URL : emptyString()) != SQLITE_OK
         || statement->bindText(6, sourceUnlinkableToken ? sourceUnlinkableToken->signatureBase64URL : emptyString()) != SQLITE_OK
         || statement->bindText(7, sourceUnlinkableToken ? sourceUnlinkableToken->keyIDBase64URL : emptyString()) != SQLITE_OK
+        || statement->bindText(8, attribution.sourceApplicationBundleID()) != SQLITE_OK
         || statement->step() != SQLITE_DONE) {
         RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::insertPrivateClickMeasurement insertUnattributedPrivateClickMeasurementQuery, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
         ASSERT_NOT_REACHED();
@@ -364,7 +367,7 @@
     while (unattributedScopedStatement->step() == SQLITE_ROW) {
         const char* prefix = unattributedNumber ? "" : "Unattributed Private Click Measurements:";
         builder.append(prefix, "\nWebCore::PrivateClickMeasurement ", ++unattributedNumber, '\n',
-            attributionToStringForTesting(*unattributedScopedStatement.get(), PrivateClickMeasurementAttributionType::Unattributed));
+            attributionToStringForTesting(buildPrivateClickMeasurementFromDatabase(*unattributedScopedStatement.get(), PrivateClickMeasurementAttributionType::Unattributed)));
     }
 
     auto attributedScopedStatement = this->scopedStatement(m_allAttributedPrivateClickMeasurementStatement, allAttributedPrivateClickMeasurementQuery, "privateClickMeasurementToStringForTesting"_s);
@@ -380,39 +383,36 @@
         if (!attributedNumber)
             builder.append(unattributedNumber ? "\n" : "", "Attributed Private Click Measurements:");
         builder.append("\nWebCore::PrivateClickMeasurement ", ++attributedNumber + unattributedNumber, '\n',
-            attributionToStringForTesting(*attributedScopedStatement.get(), PrivateClickMeasurementAttributionType::Attributed));
+            attributionToStringForTesting(buildPrivateClickMeasurementFromDatabase(*attributedScopedStatement.get(), PrivateClickMeasurementAttributionType::Attributed)));
     }
     return builder.toString();
 }
 
-String Database::attributionToStringForTesting(WebCore::SQLiteStatement& statement, PrivateClickMeasurementAttributionType attributionType) const
+String Database::attributionToStringForTesting(const WebCore::PrivateClickMeasurement& pcm) const
 {
     ASSERT(!RunLoop::isMain());
-    auto sourceSiteDomain = getDomainStringFromDomainID(statement.columnInt(0));
-    auto destinationSiteDomain = getDomainStringFromDomainID(statement.columnInt(1));
-    auto sourceID = statement.columnInt(2);
+    auto sourceSiteDomain = pcm.sourceSite().registrableDomain;
+    auto destinationSiteDomain = pcm.destinationSite().registrableDomain;
+    auto sourceID = pcm.sourceID().id;
 
     StringBuilder builder;
     builder.append("Source site: ", sourceSiteDomain, "\nAttribute on site: ", destinationSiteDomain, "\nSource ID: ", sourceID);
 
-    if (attributionType == PrivateClickMeasurementAttributionType::Attributed) {
-        auto attributionTriggerData = statement.columnInt(3);
-        auto priority = statement.columnInt(4);
-        auto earliestTimeToSend = statement.columnInt(6);
+    if (auto& triggerData = pcm.attributionTriggerData()) {
+        auto attributionTriggerData = triggerData->data;
+        auto priority = triggerData->priority;
+        auto earliestTimeToSend = pcm.timesToSend().sourceEarliestTimeToSend;
 
-        if (attributionTriggerData != -1) {
-            builder.append("\nAttribution trigger data: ", attributionTriggerData, "\nAttribution priority: ", priority, "\nAttribution earliest time to send: ");
-            if (earliestTimeToSend == -1)
-                builder.append("Not set");
-            else {
-                auto secondsUntilSend = WallTime::fromRawSeconds(earliestTimeToSend) - WallTime::now();
-                builder.append((secondsUntilSend >= 24_h && secondsUntilSend <= 48_h) ? "Within 24-48 hours" : "Outside 24-48 hours");
-            }
-        } else
-            builder.append("\nNo attribution trigger data.");
+        builder.append("\nAttribution trigger data: ", attributionTriggerData, "\nAttribution priority: ", priority, "\nAttribution earliest time to send: ");
+        if (!earliestTimeToSend)
+            builder.append("Not set");
+        else {
+            auto secondsUntilSend = *earliestTimeToSend - WallTime::now();
+            builder.append((secondsUntilSend >= 24_h && secondsUntilSend <= 48_h) ? "Within 24-48 hours" : "Outside 24-48 hours");
+        }
     } else
         builder.append("\nNo attribution trigger data.");
-    builder.append('\n');
+    builder.append("\nApplication bundle identifier: ", pcm.sourceApplicationBundleID(), '\n');
 
     return builder.toString();
 }
@@ -660,6 +660,54 @@
     m_insertObservedDomainStatement = nullptr;
 }
 
+void Database::addBundleIDColumnIfNecessary()
+{
+    // FIXME: Remove this at the end of 2021. No public release was made with the schema missing sourceApplicationBundleID, so this is only needed to migrate internal users who updated in September 2021.
+    String attributedTableName("AttributedPrivateClickMeasurement");
+    String unattributedTableName("UnattributedPrivateClickMeasurement"_s);
+    String sourceApplicationBundleIDColumnName("sourceApplicationBundleID"_s);
+    auto checkColumns = [&] (const String& tableName) {
+        auto columns = columnsForTable(tableName);
+        if (!columns.size() || columns.last() != sourceApplicationBundleIDColumnName)
+            addMissingColumnToTable(tableName, sourceApplicationBundleIDColumnName);
+    };
+    checkColumns(attributedTableName);
+    checkColumns(unattributedTableName);
+}
+
+Vector<String> Database::columnsForTable(const String& tableName)
+{
+    auto statement = m_database.prepareStatementSlow(makeString("PRAGMA table_info(", tableName, ")"));
+
+    if (!statement) {
+        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::columnsForTable Unable to prepare statement to fetch schema for table, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
+        ASSERT_NOT_REACHED();
+        return { };
+    }
+
+    Vector<String> columns;
+    while (statement->step() == SQLITE_ROW) {
+        auto name = statement->columnText(1);
+        columns.append(name);
+    }
+
+    return columns;
+}
+
+void Database::addMissingColumnToTable(const String& tableName, const String& columnName)
+{
+    auto statement = m_database.prepareStatementSlow(makeString("ALTER TABLE ", tableName, " ADD COLUMN ", columnName));
+    if (!statement) {
+        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::addMissingColumnToTable Unable to prepare statement to add missing columns to table, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    if (statement->step() != SQLITE_DONE) {
+        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::addMissingColumnToTable error executing statement to add missing columns to table, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
+        ASSERT_NOT_REACHED();
+    }
+}
+
 } // namespace PCM
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h (282883 => 282884)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h	2021-09-22 21:32:16 UTC (rev 282884)
@@ -68,7 +68,7 @@
     void destroyStatements() final;
     std::pair<std::optional<UnattributedPrivateClickMeasurement>, std::optional<AttributedPrivateClickMeasurement>> findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&);
     void removeUnattributed(WebCore::PrivateClickMeasurement&);
-    String attributionToStringForTesting(WebCore::SQLiteStatement&, PrivateClickMeasurementAttributionType) const;
+    String attributionToStringForTesting(const WebCore::PrivateClickMeasurement&) const;
     void markReportAsSentToDestination(SourceDomainID, DestinationDomainID);
     void markReportAsSentToSource(SourceDomainID, DestinationDomainID);
     std::pair<std::optional<SourceEarliestTimeToSend>, std::optional<DestinationEarliestTimeToSend>> earliestTimesToSend(const WebCore::PrivateClickMeasurement&);
@@ -76,6 +76,10 @@
     std::optional<DomainID> domainID(const WebCore::RegistrableDomain&);
     String getDomainStringFromDomainID(DomainID) const final;
 
+    void addBundleIDColumnIfNecessary();
+    Vector<String> columnsForTable(const String& tableName);
+    void addMissingColumnToTable(const String& tableName, const String& columnName);
+
     using Statement = std::unique_ptr<WebCore::SQLiteStatement>;
     mutable Statement m_setUnattributedPrivateClickMeasurementAsExpiredStatement;
     mutable Statement m_findUnattributedStatement;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (282883 => 282884)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-09-22 21:32:16 UTC (rev 282884)
@@ -420,6 +420,7 @@
 #if !TARGET_OS_TV && !TARGET_OS_WATCH
 @property (nonatomic, copy, setter=_setUIEventAttribution:) UIEventAttribution *_uiEventAttribution WK_API_AVAILABLE(ios(15.0));
 @property (nonatomic, copy, setter=_setEphemeralUIEventAttribution:) UIEventAttribution *_ephemeralUIEventAttribution WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_setEphemeralUIEventAttribution:(UIEventAttribution *)attribution forApplicationWithBundleID:(NSString *)bundleID WK_API_AVAILABLE(ios(WK_IOS_TBA));
 #endif
 
 @property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(ios(10.0));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (282883 => 282884)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2021-09-22 21:32:16 UTC (rev 282884)
@@ -44,7 +44,7 @@
 
 @interface WKWebView (WKTesting)
 
-- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(nullable NSString *)nonce WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(nullable NSString *)nonce applicationBundleID:(NSString *)bundleID WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin;
 - (CGFloat)_pageScale;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (282883 => 282884)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2021-09-22 21:32:16 UTC (rev 282884)
@@ -55,12 +55,13 @@
 
 @implementation WKWebView (WKTesting)
 
-- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(NSString *)nonce
+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(NSString *)nonce applicationBundleID:(NSString *)bundleID
 {
     WebCore::PrivateClickMeasurement measurement(
         WebCore::PrivateClickMeasurement::SourceID(sourceID),
         WebCore::PrivateClickMeasurement::SourceSite(reportEndpoint),
         WebCore::PrivateClickMeasurement::AttributionDestinationSite(destination),
+        bundleID,
         sourceDescription,
         purchaser
     );

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (282883 => 282884)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2021-09-22 21:32:16 UTC (rev 282884)
@@ -57,6 +57,7 @@
 #import <WebCore/IOSurface.h>
 #import <WebCore/LocalCurrentTraitCollection.h>
 #import <WebCore/MIMETypeRegistry.h>
+#import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/VersionChecks.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <pal/spi/ios/GraphicsServicesSPI.h>
@@ -2631,6 +2632,7 @@
             WebCore::PrivateClickMeasurement::SourceID(attribution.sourceIdentifier),
             WebCore::PrivateClickMeasurement::SourceSite(attribution.reportEndpoint),
             WebCore::PrivateClickMeasurement::AttributionDestinationSite(attribution.destinationURL),
+            WebCore::applicationBundleIdentifier(),
             attribution.sourceDescription,
             attribution.purchaser
         );
@@ -2656,6 +2658,12 @@
 
 - (void)_setEphemeralUIEventAttribution:(UIEventAttribution *)attribution
 {
+    // FIXME: Deprecate and remove this version without a bundle ID.
+    [self _setEphemeralUIEventAttribution:attribution forApplicationWithBundleID:@"com.apple.mobilesafari"];
+}
+
+- (void)_setEphemeralUIEventAttribution:(UIEventAttribution *)attribution forApplicationWithBundleID:(NSString *)bundleID
+{
 #if HAVE(UI_EVENT_ATTRIBUTION)
     if (attribution) {
         WebCore::PrivateClickMeasurement measurement(
@@ -2662,6 +2670,7 @@
             WebCore::PrivateClickMeasurement::SourceID(attribution.sourceIdentifier),
             WebCore::PrivateClickMeasurement::SourceSite(attribution.reportEndpoint),
             WebCore::PrivateClickMeasurement::AttributionDestinationSite(attribution.destinationURL),
+            bundleID,
             attribution.sourceDescription,
             attribution.purchaser,
             WallTime::now(),

Modified: trunk/Tools/ChangeLog (282883 => 282884)


--- trunk/Tools/ChangeLog	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Tools/ChangeLog	2021-09-22 21:32:16 UTC (rev 282884)
@@ -1,5 +1,20 @@
 2021-09-22  Alex Christensen  <achristen...@webkit.org>
 
+        PCM should include the bundle ID of the app from which it originated
+        https://bugs.webkit.org/show_bug.cgi?id=230576
+        <rdar://83065221>
+
+        Reviewed by Kate Cheney.
+
+        * TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm:
+        (pollUntilPCMIsMigrated):
+
+2021-09-22  Alex Christensen  <achristen...@webkit.org>
+
         Move PCMDaemon to WebKit.framework and rename it to AdAttributionDaemon
         https://bugs.webkit.org/show_bug.cgi?id=230516
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp (282883 => 282884)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp	2021-09-22 21:32:16 UTC (rev 282884)
@@ -44,7 +44,7 @@
 
 TEST(PrivateClickMeasurement, WellKnownURLs)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(min6BitValue, PrivateClickMeasurement::Priority(min6BitValue)));
 
     auto attributionSourceURL = attribution.attributionReportSourceURL();
@@ -55,7 +55,7 @@
 
 TEST(PrivateClickMeasurement, ValidMinValues)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(min6BitValue, PrivateClickMeasurement::Priority(min6BitValue)));
 
     ASSERT_EQ(attribution.attributionReportJSON()->toJSONString(), "{\"source_engagement_type\":\"click\",\"source_site\":\"webkit.org\",\"source_id\":0,\"attributed_on_site\":\"example.com\",\"trigger_data\":0,\"version\":2}");
@@ -63,7 +63,7 @@
 
 TEST(PrivateClickMeasurement, ValidMidValues)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID((uint32_t)192), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID((uint32_t)192), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData((uint32_t)9, PrivateClickMeasurement::Priority((uint32_t)22)));
 
     ASSERT_EQ(attribution.attributionReportJSON()->toJSONString(), "{\"source_engagement_type\":\"click\",\"source_site\":\"webkit.org\",\"source_id\":192,\"attributed_on_site\":\"example.com\",\"trigger_data\":9,\"version\":2}");
@@ -71,7 +71,7 @@
 
 TEST(PrivateClickMeasurement, ValidMaxValues)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
     ASSERT_EQ(attribution.attributionReportJSON()->toJSONString(), "{\"source_engagement_type\":\"click\",\"source_site\":\"webkit.org\",\"source_id\":255,\"attributed_on_site\":\"example.com\",\"trigger_data\":15,\"version\":2}");
@@ -79,7 +79,7 @@
 
 TEST(PrivateClickMeasurement, EarliestTimeToSendAttributionMinimumDelay)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     auto now = WallTime::now();
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
     auto earliestTimeToSend = attribution.timesToSend();
@@ -134,7 +134,7 @@
 
 TEST(PrivateClickMeasurement, InvalidSourceID)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
@@ -143,7 +143,7 @@
 
 TEST(PrivateClickMeasurement, InvalidSourceHost)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { emptyURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { emptyURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
@@ -152,7 +152,7 @@
 
 TEST(PrivateClickMeasurement, InvalidDestinationHost)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { emptyURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { emptyURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
@@ -161,7 +161,7 @@
 
 TEST(PrivateClickMeasurement, AttributionTriggerData)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData((PrivateClickMeasurement::AttributionTriggerData::MaxEntropy + 1), PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
@@ -170,7 +170,7 @@
 
 TEST(PrivateClickMeasurement, InvalidPriority)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy + 1)));
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
@@ -179,7 +179,7 @@
 
 TEST(PrivateClickMeasurement, InvalidMissingConversion)
 {
-    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL } };
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributionDestinationSite { exampleURL }, "test.bundle.identifier" };
 
     ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
     ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm (282883 => 282884)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm	2021-09-22 21:32:16 UTC (rev 282884)
@@ -297,7 +297,7 @@
 
     auto webView = adoptNS([WKWebView new]);
     webView.get().navigationDelegate = delegateAllowingAllTLS();
-    [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:serverURL optionalNonce:@"ABCDEFabcdef0123456789"];
+    [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:serverURL optionalNonce:@"ABCDEFabcdef0123456789" applicationBundleID:@"test.bundle.id"];
     [[webView configuration].websiteDataStore _setResourceLoadStatisticsEnabled:YES];
     [[webView configuration].websiteDataStore _trustServerForLocalPCMTesting:secTrustFromCertificateChain(@[(id)testCertificate().get()]).get()];
 
@@ -318,7 +318,7 @@
 TEST(EventAttribution, Basic)
 {
     runBasicEventAttributionTest(nil, [](WKWebView *webView, const HTTPServer& server) {
-        [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil];
+        [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
     });
 }
 
@@ -340,7 +340,7 @@
         auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
         viewConfiguration.get().websiteDataStore = dataStore.get();
         runBasicEventAttributionTest(viewConfiguration.get(), [](WKWebView *webView, const HTTPServer& server) {
-            [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil];
+            [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
         });
         originalNetworkProcessPid = [dataStore _networkProcessIdentifier];
         EXPECT_GT(originalNetworkProcessPid, 0);
@@ -472,7 +472,7 @@
     auto viewConfiguration = adoptNS([WKWebViewConfiguration new]);
     viewConfiguration.get().websiteDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]).get();
     runBasicEventAttributionTest(viewConfiguration.get(), [](WKWebView *webView, const HTTPServer& server) {
-        [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil];
+        [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
     });
 
     system("killall TestPCMDaemon -9");

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm (282883 => 282884)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm	2021-09-22 21:05:52 UTC (rev 282883)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm	2021-09-22 21:32:16 UTC (rev 282884)
@@ -188,6 +188,11 @@
         "Attribute on site: www.webkit.org\n"
         "Source ID: 43\n"
         "No attribution trigger data.\n"
+#if PLATFORM(MAC)
+        "Application bundle identifier: com.apple.Safari\n"
+#else
+        "Application bundle identifier: com.apple.mobilesafari\n"
+#endif
         "\n"
         "Attributed Private Click Measurements:\n"
         "WebCore::PrivateClickMeasurement 2\n"
@@ -196,7 +201,13 @@
         "Source ID: 42\n"
         "Attribution trigger data: 14\n"
         "Attribution priority: 7\n"
-        "Attribution earliest time to send: Outside 24-48 hours\n";
+        "Attribution earliest time to send: Outside 24-48 hours\n"
+#if PLATFORM(MAC)
+        "Application bundle identifier: com.apple.Safari\n"
+#else
+        "Application bundle identifier: com.apple.mobilesafari\n"
+#endif
+        "";
 
     while (![dumpedPCM(webView) isEqualToString:expectedMigratedPCMDatabase])
         usleep(10000);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to