Add a query string nonce to LayoutTests/http/tests/adClickAttribution/send-attributio...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 04:24:23 +0000 (04:24 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 04:24:23 +0000 (04:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196955

Source/WebCore:

Unreviewed test gardening. The WebCore change is only in a dedicated
test function.

No new tests. Existing test updated.

* loader/AdClickAttribution.cpp:
(WebCore::AdClickAttribution::urlForTesting const):
    Now preserves the query string in the test URL.

LayoutTests:

Unreviewed test gardening.

* http/tests/adClickAttribution/resources/conversionFilePath.php:
* http/tests/adClickAttribution/resources/conversionReport.php:
* http/tests/adClickAttribution/resources/getConversionData.php:
* http/tests/adClickAttribution/send-attribution-conversion-request.html:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/adClickAttribution/resources/conversionFilePath.php
LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php
LayoutTests/http/tests/adClickAttribution/resources/getConversionData.php
LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html
Source/WebCore/ChangeLog
Source/WebCore/loader/AdClickAttribution.cpp

index 08060ca..f6a765a 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-15  John Wilander  <wilander@apple.com>
+
+        Add a query string nonce to LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html to address flakiness
+        https://bugs.webkit.org/show_bug.cgi?id=196955
+
+        Unreviewed test gardening.
+
+        * http/tests/adClickAttribution/resources/conversionFilePath.php:
+        * http/tests/adClickAttribution/resources/conversionReport.php:
+        * http/tests/adClickAttribution/resources/getConversionData.php:
+        * http/tests/adClickAttribution/send-attribution-conversion-request.html:
+
 2019-04-15  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: fake value descriptors for promises add a catch handler, preventing "rejectionhandled" events from being fired
index a553cf9..ba11240 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 require_once '../../resources/portabilityLayer.php';
 
-$conversionFilePath = sys_get_temp_dir() . "/adClickConversion.txt";
-
+if (isset($_GET["nonce"]))
+    $conversionFileName = "/adClickConversion" . $_GET["nonce"] . ".txt";
+else
+    $conversionFileName = "/adClickConversion.txt";
+$conversionFilePath = sys_get_temp_dir() . $conversionFileName;
 ?>
index bf3f787..3fbd8fb 100644 (file)
@@ -5,9 +5,16 @@ $conversionFile = fopen($conversionFilePath . ".tmp", 'w');
 $httpHeaders = $_SERVER;
 $cookiesFound = false;
 foreach ($httpHeaders as $name => $value) {
-    if ($name === "HTTP_HOST" || $name === "REQUEST_URI")
+    if ($name === "HTTP_HOST") {
         fwrite($conversionFile, "$name: $value\n");
-    else if ($name === "HTTP_COOKIE") {
+    } else if ($name === "REQUEST_URI") {
+        $positionOfNonce = strpos($value, "&nonce=");
+        if ($positionOfNonce === false)
+            $outputURL = $value;
+        else
+            $outputURL = substr($value, 0, $positionOfNonce);
+        fwrite($conversionFile, "$name: $outputURL\n");
+    } else if ($name === "HTTP_COOKIE") {
         fwrite($conversionFile, "Cookies in conversion request: $value\n");
         $cookiesFound = true;
     }
index 2996fa0..99af8d8 100644 (file)
@@ -36,7 +36,7 @@ if ($conversionFileFound) {
     fclose($conversionFile);
     unlink($conversionFilePath);
 } else {
-    echo "Conversion not received - timed out.";
+    echo "Conversion not received - timed out.<br>";
 }
 
 if (isset($_GET['endTest'])) {
index 3a0b80f..d9b29a3 100644 (file)
 <a id="targetLink" href="http://localhost:8000/adClickAttribution/send-attribution-conversion-request.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
 <div id="output"></div>
 <script>
+    const currentTimeMillis = (new Date()).getTime();
+    const highEntropyBits = currentTimeMillis - (Math.floor(currentTimeMillis / 1000000) * 1000000);
+    const nonce = highEntropyBits + "" + Math.floor(Math.random() * 100);
+
     if (window.testRunner) {
         testRunner.waitUntilDone();
         testRunner.dumpChildFramesAsText();
         testRunner.setAllowsAnySSLCertificate(true);
         testRunner.setAdClickAttributionOverrideTimerForTesting(true);
-        testRunner.setAdClickAttributionConversionURLForTesting("http://127.0.0.1:8000/adClickAttribution/resources/conversionReport.php");
     }
 
     function activateElement(elementID) {
         document.body.removeChild(document.getElementById("pixel"));
 
         let iframeElement = document.createElement("iframe");
-        iframeElement.src = "http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?endTest=true&timeout_ms=2000";
+        iframeElement.src = "http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?endTest=true&timeout_ms=2000&nonce=" + nonce;
         document.body.appendChild(iframeElement);
     }
 
     function runTest() {
         if (window.testRunner) {
             if (window.location.search === "?stepTwo") {
+                testRunner.setAdClickAttributionConversionURLForTesting("http://127.0.0.1:8000/adClickAttribution/resources/conversionReport.php?nonce=" + nonce);
                 let imageElement = document.createElement("img");
                 imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12";
                 imageElement.id = "pixel";
index e9c8591..cbc275c 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-15  John Wilander  <wilander@apple.com>
+
+        Add a query string nonce to LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html to address flakiness
+        https://bugs.webkit.org/show_bug.cgi?id=196955
+
+        Unreviewed test gardening. The WebCore change is only in a dedicated
+        test function.
+
+        No new tests. Existing test updated.
+
+        * loader/AdClickAttribution.cpp:
+        (WebCore::AdClickAttribution::urlForTesting const):
+            Now preserves the query string in the test URL.
+
 2019-04-15  Chris Dumez  <cdumez@apple.com>
 
         URL set by document.open() is not communicated to the UIProcess
index 5264567..f16c94c 100644 (file)
@@ -141,6 +141,10 @@ URL AdClickAttribution::urlForTesting(const URL& baseURL) const
     builder.appendNumber(m_conversion.value().data);
     builder.appendLiteral("&campaign=");
     builder.appendNumber(m_campaign.id);
+    if (baseURL.hasQuery()) {
+        builder.append('&');
+        builder.append(baseURL.query());
+    }
     return URL(baseURL, builder.toString());
 }