Title: [272422] trunk
Revision
272422
Author
[email protected]
Date
2021-02-05 10:27:56 -0800 (Fri, 05 Feb 2021)

Log Message

Make sure click attribution is processed in case of redirected kept alive loads
https://bugs.webkit.org/show_bug.cgi?id=221453
<rdar://problem/70896640>

Reviewed by John Wilander.

Source/WebCore:

Test: http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::addSubresourceLoader):
Update assertion to cope with keep alive fetches which are similar to beacon/ping loads.

Source/WebKit:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
Move the click attribution processing before kept alive check.

LayoutTests:

* http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt: Added.
* http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html: Added.
* http/tests/privateClickMeasurement/resources/redirectToConversion.php:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272421 => 272422)


--- trunk/LayoutTests/ChangeLog	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/LayoutTests/ChangeLog	2021-02-05 18:27:56 UTC (rev 272422)
@@ -1,3 +1,15 @@
+2021-02-05  Youenn Fablet  <[email protected]>
+
+        Make sure click attribution is processed in case of redirected kept alive loads
+        https://bugs.webkit.org/show_bug.cgi?id=221453
+        <rdar://problem/70896640>
+
+        Reviewed by John Wilander.
+
+        * http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt: Added.
+        * http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html: Added.
+        * http/tests/privateClickMeasurement/resources/redirectToConversion.php:
+
 2021-02-05  Chris Dumez  <[email protected]>
 
         REGRESSION (r272392): [ MacOS ] webaudio/audioworklet-addModule-failure.html is flakey timing out

Added: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt (0 => 272422)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive-expected.txt	2021-02-05 18:27:56 UTC (rev 272422)
@@ -0,0 +1,14 @@
+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

Added: trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html (0 => 272422)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html	2021-02-05 18:27:56 UTC (rev 272422)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="UTF-8">
+    <script src=""
+    <script src=""
+</head>
+<body _onload_="runTest()">
+<div id="description">Tests triggering of private click measurement attributions with fetch on pagehide.</div>
+<a id="targetLink" href="" attributionsourceid="3" attributeon="http://localhost:8000">Link</a><br>
+<div id="output"></div>
+<script>
+    prepareTest();
+
+    function activateElement(elementID) {
+        var element = document.getElementById(elementID);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function () {
+            },
+            function () {
+                document.getElementById("output").innerText = "FAIL Promise rejected.";
+                tearDownAndFinish();
+            }
+        );
+    }
+
+    function triggerFetch(conversionData) {
+        return fetch("https://127.0.0.1:8443/privateClickMeasurement/resources/redirectToConversion.php?conversionData="+ conversionData + "&delay_ms=100", { keepalive: true });
+    }
+
+    function runTest() {
+        if (window.location.search === "?stepTwo") {
+            // Start private click attribution fetch but navigate away before the fetch redirection happens.
+            triggerFetch(12);
+            document.location.href = ""
+            return;
+        }
+        if (window.location.search === "?stepThree") {
+            document.body.removeChild(document.getElementById("targetLink"));
+            // Do an invalid private click attribution fetch to ensure the previous correct click attribution fetch will be finished.
+            triggerFetch("whatever").catch(() => {
+                if (window.testRunner)
+                    testRunner.dumpPrivateClickMeasurement();
+                tearDownAndFinish();
+            });
+            return;
+        }
+        activateElement("targetLink");
+    }
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/privateClickMeasurement/resources/redirectToConversion.php (272421 => 272422)


--- trunk/LayoutTests/http/tests/privateClickMeasurement/resources/redirectToConversion.php	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/LayoutTests/http/tests/privateClickMeasurement/resources/redirectToConversion.php	2021-02-05 18:27:56 UTC (rev 272422)
@@ -1,6 +1,11 @@
 <?php
+if (isset($_GET["delay_ms"])) {
+    usleep($_GET["delay_ms"] * 1000);
+}
 header("HTTP/1.1 302 Found");
 header("Cache-Control: no-cache, no-store, must-revalidate");
+header("Access-Control-Allow-Origin: *");
+header("Access-Control-Allow-Methods: GET");
 if (isset($_GET["conversionData"]) && isset($_GET["priority"])) {
   header("Location: /.well-known/private-click-measurement/trigger-attribution/" . $_GET["conversionData"] . "/" . $_GET["priority"]);
 } else if (isset($_GET["conversionData"])) {

Modified: trunk/Source/WebCore/ChangeLog (272421 => 272422)


--- trunk/Source/WebCore/ChangeLog	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/Source/WebCore/ChangeLog	2021-02-05 18:27:56 UTC (rev 272422)
@@ -1,3 +1,17 @@
+2021-02-05  Youenn Fablet  <[email protected]>
+
+        Make sure click attribution is processed in case of redirected kept alive loads
+        https://bugs.webkit.org/show_bug.cgi?id=221453
+        <rdar://problem/70896640>
+
+        Reviewed by John Wilander.
+
+        Test: http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::addSubresourceLoader):
+        Update assertion to cope with keep alive fetches which are similar to beacon/ping loads.
+
 2021-02-04  Darin Adler  <[email protected]>
 
         StyleImage refinement to follow up recent changes

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (272421 => 272422)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-02-05 18:27:56 UTC (rev 272422)
@@ -1820,7 +1820,7 @@
         case Document::AboutToEnterBackForwardCache: {
             // A page about to enter the BackForwardCache should only be able to start ping loads.
             auto* cachedResource = MemoryCache::singleton().resourceForRequest(loader->request(), loader->frameLoader()->frame().page()->sessionID());
-            ASSERT(cachedResource && CachedResource::shouldUsePingLoad(cachedResource->type()));
+            ASSERT(cachedResource && (CachedResource::shouldUsePingLoad(cachedResource->type()) || cachedResource->options().keepAlive));
             break;
         }
         case Document::InBackForwardCache:

Modified: trunk/Source/WebKit/ChangeLog (272421 => 272422)


--- trunk/Source/WebKit/ChangeLog	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/Source/WebKit/ChangeLog	2021-02-05 18:27:56 UTC (rev 272422)
@@ -1,3 +1,15 @@
+2021-02-05  Youenn Fablet  <[email protected]>
+
+        Make sure click attribution is processed in case of redirected kept alive loads
+        https://bugs.webkit.org/show_bug.cgi?id=221453
+        <rdar://problem/70896640>
+
+        Reviewed by John Wilander.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
+        Move the click attribution processing before kept alive check.
+
 2021-02-05  Per Arne Vollan  <[email protected]>
 
         Remove access to IOMobileFramebufferUserClient

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (272421 => 272422)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-02-05 18:12:24 UTC (rev 272421)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-02-05 18:27:56 UTC (rev 272422)
@@ -879,15 +879,15 @@
     RELEASE_LOG_IF_ALLOWED("continueWillSendRedirectedRequest: (m_isKeptAlive=%d, hasAdClickConversion=%d)", m_isKeptAlive, !!privateClickMeasurementAttributionTriggerData);
     ASSERT(!isSynchronous());
 
+    NetworkSession* networkSession = nullptr;
+    if (privateClickMeasurementAttributionTriggerData && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
+        networkSession->handlePrivateClickMeasurementConversion(WTFMove(*privateClickMeasurementAttributionTriggerData), request.url(), redirectRequest);
+
     if (m_isKeptAlive) {
         continueWillSendRequest(WTFMove(redirectRequest), false);
         return;
     }
 
-    NetworkSession* networkSession = nullptr;
-    if (privateClickMeasurementAttributionTriggerData && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
-        networkSession->handlePrivateClickMeasurementConversion(WTFMove(*privateClickMeasurementAttributionTriggerData), request.url(), redirectRequest);
-
     // We send the request body separately because the ResourceRequest body normally does not get encoded when sent over IPC, as an optimization.
     // However, we really need the body here because a redirect cross-site may cause a process-swap and the request to start again in a new WebContent process.
     send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, IPC::FormDataReference { redirectRequest.httpBody() }, sanitizeResponseIfPossible(WTFMove(redirectResponse), ResourceResponse::SanitizationType::Redirection)));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to