Title: [274453] trunk
Revision
274453
Author
[email protected]
Date
2021-03-15 16:44:21 -0700 (Mon, 15 Mar 2021)

Log Message

PCM: Split attributionReportURL() into attributionReportSourceURL() and attributionReportAttributeOnURL()
https://bugs.webkit.org/show_bug.cgi?id=223210
<rdar://problem/75442246>

Reviewed by Brent Fulgham.

This patch splits WebCore::PrivateClickMeasurement::attributionReportURL() into
Source/WebCore:

PrivateClickMeasurement::attributionReportSourceURL() and
PrivateClickMeasurement::attributionReportAttributeOnURL() to
facilitate sending attribution reports to both the click source and destination.

No new tests. This patch doesn't change functionality and the functionality is
covered by existing tests.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):
    Changed the assertion to check both the attribution URLs.
* loader/PrivateClickMeasurement.cpp:
(WebCore::attributionReportURL):
    Static convenience function to share code between
    PrivateClickMeasurement::attributionReportSourceURL() and
    PrivateClickMeasurement::attributionReportAttributeOnURL().
(WebCore::PrivateClickMeasurement::attributionReportSourceURL const):
    Generates the well-known location for the click source.
(WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL const):
    Generates the well-known location for the click destination.
(WebCore::PrivateClickMeasurement::attributionReportURL const): Deleted.
    No mostly exists as a static convenience function (see above).
* loader/PrivateClickMeasurement.h:

Source/WebKit:

WebCore::PrivateClickMeasurement::attributionReportSourceURL() and
WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL() to
facilitate sending attribution reports to both the click source and destination.

* NetworkProcess/PrivateClickMeasurementManager.cpp:
(WebKit::PrivateClickMeasurementManager::storeUnattributed):
    Removed a reference to ads in a log statement.
(WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl):
    Now uses  WebCore::PrivateClickMeasurement::attributionReportSourceURL().

Tools:

WebCore::PrivateClickMeasurement::attributionReportSourceURL() and
WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL() to
facilitate sending attribution reports to both the click source and destination.

* TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp:
(TestWebKitAPI::TEST):
    Updated to use the new functions and also not repeat tests of static
    data.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274452 => 274453)


--- trunk/Source/WebCore/ChangeLog	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebCore/ChangeLog	2021-03-15 23:44:21 UTC (rev 274453)
@@ -1,3 +1,35 @@
+2021-03-15  John Wilander  <[email protected]>
+
+        PCM: Split attributionReportURL() into attributionReportSourceURL() and attributionReportAttributeOnURL()
+        https://bugs.webkit.org/show_bug.cgi?id=223210
+        <rdar://problem/75442246>
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits WebCore::PrivateClickMeasurement::attributionReportURL() into
+        PrivateClickMeasurement::attributionReportSourceURL() and
+        PrivateClickMeasurement::attributionReportAttributeOnURL() to
+        facilitate sending attribution reports to both the click source and destination.
+
+        No new tests. This patch doesn't change functionality and the functionality is
+        covered by existing tests.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+            Changed the assertion to check both the attribution URLs.
+        * loader/PrivateClickMeasurement.cpp:
+        (WebCore::attributionReportURL):
+            Static convenience function to share code between
+            PrivateClickMeasurement::attributionReportSourceURL() and
+            PrivateClickMeasurement::attributionReportAttributeOnURL().
+        (WebCore::PrivateClickMeasurement::attributionReportSourceURL const):
+            Generates the well-known location for the click source.
+        (WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL const):
+            Generates the well-known location for the click destination.
+        (WebCore::PrivateClickMeasurement::attributionReportURL const): Deleted.
+            No mostly exists as a static convenience function (see above).
+        * loader/PrivateClickMeasurement.h:
+
 2021-03-15  Wenson Hsieh  <[email protected]>
 
         Image overlay creation should be idempotent

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (274452 => 274453)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-03-15 23:44:21 UTC (rev 274453)
@@ -525,9 +525,9 @@
         newFrameOpenerPolicy = NewFrameOpenerPolicy::Suppress;
 
     auto privateClickMeasurement = parsePrivateClickMeasurement();
-    // A matching conversion event needs to happen before the complete private click measurement
-    // URL can be created. Thus, it should be empty for now.
-    ASSERT(!privateClickMeasurement || privateClickMeasurement->attributionReportURL().isNull());
+    // A matching triggering event needs to happen before an attribution report can be sent.
+    // Thus, URLs should be empty for now.
+    ASSERT(!privateClickMeasurement || (privateClickMeasurement->attributionReportSourceURL().isNull() && privateClickMeasurement->attributionReportAttributeOnURL().isNull()));
     
     frame->loader().changeLocation(completedURL, effectiveTarget, &event, referrerPolicy, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo, WTFMove(privateClickMeasurement));
 

Modified: trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp (274452 => 274453)


--- trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp	2021-03-15 23:44:21 UTC (rev 274453)
@@ -116,14 +116,11 @@
     return m_attributionTriggerData->priority > other.m_attributionTriggerData->priority;
 }
 
-URL PrivateClickMeasurement::attributionReportURL() const
+static URL attributionReportURL(const RegistrableDomain& registrableDomain)
 {
-    if (!isValid())
-        return URL();
-
     StringBuilder builder;
     builder.appendLiteral("https://");
-    builder.append(m_sourceSite.registrableDomain.string());
+    builder.append(registrableDomain.string());
     builder.appendLiteral(privateClickMeasurementReportAttributionPath);
 
     URL url { URL(), builder.toString() };
@@ -133,6 +130,22 @@
     return URL();
 }
 
+URL PrivateClickMeasurement::attributionReportSourceURL() const
+{
+    if (!isValid())
+        return URL();
+
+    return attributionReportURL(m_sourceSite.registrableDomain);
+}
+
+URL PrivateClickMeasurement::attributionReportAttributeOnURL() const
+{
+    if (!isValid())
+        return URL();
+
+    return attributionReportURL(m_attributeOnSite.registrableDomain);
+}
+
 Ref<JSON::Object> PrivateClickMeasurement::attributionReportJSON() const
 {
     auto reportDetails = JSON::Object::create();

Modified: trunk/Source/WebCore/loader/PrivateClickMeasurement.h (274452 => 274453)


--- trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-03-15 23:44:21 UTC (rev 274453)
@@ -262,7 +262,8 @@
     WEBCORE_EXPORT static Expected<AttributionTriggerData, String> parseAttributionRequest(const URL& redirectURL);
     WEBCORE_EXPORT Optional<Seconds> attributeAndGetEarliestTimeToSend(AttributionTriggerData&&);
     WEBCORE_EXPORT bool hasHigherPriorityThan(const PrivateClickMeasurement&) const;
-    WEBCORE_EXPORT URL attributionReportURL() const;
+    WEBCORE_EXPORT URL attributionReportSourceURL() const;
+    WEBCORE_EXPORT URL attributionReportAttributeOnURL() const;
     WEBCORE_EXPORT Ref<JSON::Object> attributionReportJSON() const;
     const SourceSite& sourceSite() const { return m_sourceSite; };
     const AttributeOnSite& attributeOnSite() const { return m_attributeOnSite; };

Modified: trunk/Source/WebKit/ChangeLog (274452 => 274453)


--- trunk/Source/WebKit/ChangeLog	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebKit/ChangeLog	2021-03-15 23:44:21 UTC (rev 274453)
@@ -1,3 +1,22 @@
+2021-03-15  John Wilander  <[email protected]>
+
+        PCM: Split attributionReportURL() into attributionReportSourceURL() and attributionReportAttributeOnURL()
+        https://bugs.webkit.org/show_bug.cgi?id=223210
+        <rdar://problem/75442246>
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits WebCore::PrivateClickMeasurement::attributionReportURL() into
+        WebCore::PrivateClickMeasurement::attributionReportSourceURL() and
+        WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL() to
+        facilitate sending attribution reports to both the click source and destination.
+
+        * NetworkProcess/PrivateClickMeasurementManager.cpp:
+        (WebKit::PrivateClickMeasurementManager::storeUnattributed):
+            Removed a reference to ads in a log statement.
+        (WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl):
+            Now uses  WebCore::PrivateClickMeasurement::attributionReportSourceURL().
+
 2021-03-15  Per Arne Vollan  <[email protected]>
 
         Enforce subcommand filtering

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp (274452 => 274453)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp	2021-03-15 23:44:21 UTC (rev 274453)
@@ -97,7 +97,7 @@
         });
     }
 
-    m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Storing an ad click."_s);
+    m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Storing a click."_s);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
@@ -324,7 +324,7 @@
 
 void PrivateClickMeasurementManager::fireConversionRequestImpl(const PrivateClickMeasurement& attribution)
 {
-    auto attributionURL = m_attributionReportBaseURLForTesting ? *m_attributionReportBaseURLForTesting : attribution.attributionReportURL();
+    auto attributionURL = m_attributionReportBaseURLForTesting ? *m_attributionReportBaseURLForTesting : attribution.attributionReportSourceURL();
     if (attributionURL.isEmpty() || !attributionURL.isValid())
         return;
 

Modified: trunk/Tools/ChangeLog (274452 => 274453)


--- trunk/Tools/ChangeLog	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Tools/ChangeLog	2021-03-15 23:44:21 UTC (rev 274453)
@@ -1,3 +1,21 @@
+2021-03-15  John Wilander  <[email protected]>
+
+        PCM: Split attributionReportURL() into attributionReportSourceURL() and attributionReportAttributeOnURL()
+        https://bugs.webkit.org/show_bug.cgi?id=223210
+        <rdar://problem/75442246>
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits WebCore::PrivateClickMeasurement::attributionReportURL() into
+        WebCore::PrivateClickMeasurement::attributionReportSourceURL() and
+        WebCore::PrivateClickMeasurement::attributionReportAttributeOnURL() to
+        facilitate sending attribution reports to both the click source and destination.
+
+        * TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp:
+        (TestWebKitAPI::TEST):
+            Updated to use the new functions and also not repeat tests of static
+            data.
+
 2021-03-15  Aakash Jain  <[email protected]>
 
         Delete unused build-launcher-dmg script

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp (274452 => 274453)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp	2021-03-15 23:41:59 UTC (rev 274452)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp	2021-03-15 23:44:21 UTC (rev 274453)
@@ -42,15 +42,22 @@
 
 // Positive test cases.
 
+TEST(PrivateClickMeasurement, WellKnownURLs)
+{
+    PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
+    attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(min6BitValue, PrivateClickMeasurement::Priority(min6BitValue)));
+
+    auto attributionSourceURL = attribution.attributionReportSourceURL();
+    ASSERT_EQ(attributionSourceURL.string(), "https://webkit.org/.well-known/private-click-measurement/report-attribution/");
+    auto attributionAttributeOnURL = attribution.attributionReportAttributeOnURL();
+    ASSERT_EQ(attributionAttributeOnURL.string(), "https://example.com/.well-known/private-click-measurement/report-attribution/");
+}
+
 TEST(PrivateClickMeasurement, ValidMinValues)
 {
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(min6BitValue), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(min6BitValue, PrivateClickMeasurement::Priority(min6BitValue)));
 
-    auto attributionURL = attribution.attributionReportURL();
-    
-    ASSERT_EQ(attributionURL.string(), "https://webkit.org/.well-known/private-click-measurement/report-attribution/");
-
     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}");
 }
 
@@ -59,10 +66,6 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID((uint32_t)192), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData((uint32_t)9, PrivateClickMeasurement::Priority((uint32_t)22)));
 
-    auto attributionURL = attribution.attributionReportURL();
-    
-    ASSERT_EQ(attributionURL.string(), "https://webkit.org/.well-known/private-click-measurement/report-attribution/");
-
     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,10 +74,6 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
-    auto attributionURL = attribution.attributionReportURL();
-    
-    ASSERT_EQ(attributionURL.string(), "https://webkit.org/.well-known/private-click-measurement/report-attribution/");
-
     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}");
 }
 
@@ -137,7 +136,8 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
 }
 
 TEST(PrivateClickMeasurement, InvalidSourceHost)
@@ -145,7 +145,8 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { emptyURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
 }
 
 TEST(PrivateClickMeasurement, InvalidDestinationHost)
@@ -153,7 +154,8 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy + 1), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { emptyURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
 }
 
 TEST(PrivateClickMeasurement, AttributionTriggerData)
@@ -161,7 +163,8 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData((PrivateClickMeasurement::AttributionTriggerData::MaxEntropy + 1), PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy)));
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
 }
 
 TEST(PrivateClickMeasurement, InvalidPriority)
@@ -169,7 +172,8 @@
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
     attribution.attributeAndGetEarliestTimeToSend(PrivateClickMeasurement::AttributionTriggerData(PrivateClickMeasurement::AttributionTriggerData::MaxEntropy, PrivateClickMeasurement::Priority(PrivateClickMeasurement::Priority::MaxEntropy + 1)));
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
 }
 
 TEST(PrivateClickMeasurement, InvalidMissingConversion)
@@ -176,7 +180,8 @@
 {
     PrivateClickMeasurement attribution { PrivateClickMeasurement::SourceID(PrivateClickMeasurement::SourceID::MaxEntropy), PrivateClickMeasurement::SourceSite { webKitURL }, PrivateClickMeasurement::AttributeOnSite { exampleURL } };
 
-    ASSERT_TRUE(attribution.attributionReportURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportSourceURL().isEmpty());
+    ASSERT_TRUE(attribution.attributionReportAttributeOnURL().isEmpty());
     ASSERT_FALSE(attribution.earliestTimeToSend());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to