<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244475] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244475">244475</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2019-04-19 17:00:26 -0700 (Fri, 19 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Disable Ad Click Attribution in ephemeral sessions and make sure conversion requests use an ephemeral, stateless session
https://bugs.webkit.org/show_bug.cgi?id=197108
<rdar://problem/49918702>

Patch by John Wilander <wilander@apple.com> on 2019-04-19
Reviewed by Alex Christensen.

Source/WebCore:

Tests: http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
       http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAdClickAttribution const):
    Early return for ephemeral sessions.
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::shouldUseCredentialStorage):
    Now returns false for StoredCredentialsPolicy:EphemeralStatelessCookieless.
* platform/network/StoredCredentialsPolicy.h:
    Added enum value EphemeralStatelessCookieless.

Source/WebKit:

This patch introduces a new NSURLSession in WebKit::NetworkSessionCocoa called
m_ephemeralStatelessCookielessSession. As its name implies, it's ephemeral,
stateless, and has a NSHTTPCookieAcceptPolicyNever cookie policy.

The new session can be invoked with the new enum value of
WebCore::StoredCredentialsPolicy called EphemeralStatelessCookieless.

WebKit::AdClickAttributionManager::fireConversionRequest() makes use of
the new session for its conversion requests.

This patch also makes sure that Ad Click Attributions cannot be stored in
ephemeral sessions and already stored attributions cannot be converted in
ephemeral sessions.

* NetworkProcess/AdClickAttributionManager.cpp:
(WebKit::AdClickAttributionManager::fireConversionRequest):
(WebKit::AdClickAttributionManager::toString const):
* NetworkProcess/NetworkLoadChecker.h:
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::willSendRedirectedRequest):
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
    Calls NetworkSessionCocoa::initializeEphemeralStatelessCookielessSession() lazily.
(WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
* NetworkProcess/cocoa/NetworkSessionCocoa.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::initializeEphemeralStatelessCookielessSession):
(WebKit::NetworkSessionCocoa::invalidateAndCancel):
* Shared/WebCoreArgumentCoders.h:

LayoutTests:

Except for the details below, this patch introduces the utility functions
prepareTest() and tearDownAndFinish() and all applicable tests now make use
of them.

* http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html:
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html:
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html:
* http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt: Added.
* http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html: Copied from LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html.
* http/tests/adClickAttribution/resources/conversionReport.php:
    Now tries to set a cookie in the response.
* http/tests/adClickAttribution/resources/util.js: Added.
(prepareTest):
(tearDownAndFinish):
* http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html:
* http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html:
* http/tests/adClickAttribution/second-conversion-with-higher-priority.html:
* http/tests/adClickAttribution/second-conversion-with-lower-priority.html:
* http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt:
* http/tests/adClickAttribution/send-attribution-conversion-request.html:
* http/tests/adClickAttribution/store-ad-click-attribution.html:
    Now sets a cookie which is checked for it in the conversion report.
* http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt: Added.
* http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html: Copied from LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughcrosssiteimageredirecthtml">trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughimageredirectwithpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughimageredirectwithoutpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionresourcesconversionReportphp">trunk/LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsecondattributionconvertedwithhigherpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsecondattributionconvertedwithlowerpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsecondconversionwithhigherpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-higher-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsecondconversionwithlowerpriorityhtml">trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-lower-priority.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsendattributionconversionrequestexpectedtxt">trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionsendattributionconversionrequesthtml">trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionstoreadclickattributionhtml">trunk/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAnchorElementcpp">trunk/Source/WebCore/html/HTMLAnchorElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkStoredCredentialsPolicyh">trunk/Source/WebCore/platform/network/StoredCredentialsPolicy.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessAdClickAttributionManagercpp">trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkLoadCheckerh">trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkProcessh">trunk/Source/WebKit/NetworkProcess/NetworkProcess.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkProcessmessagesin">trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkResourceLoadercpp">trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoamm">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoah">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoamm">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitSharedWebCoreArgumentCodersh">trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionconversiondisabledinephemeralsessionexpectedtxt">trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionconversiondisabledinephemeralsessionhtml">trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionresourcesutiljs">trunk/LayoutTests/http/tests/adClickAttribution/resources/util.js</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionstoredisabledinephemeralsessionexpectedtxt">trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsadClickAttributionstoredisabledinephemeralsessionhtml">trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/ChangeLog 2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2019-04-19  John Wilander  <wilander@apple.com>
+
+        Disable Ad Click Attribution in ephemeral sessions and make sure conversion requests use an ephemeral, stateless session
+        https://bugs.webkit.org/show_bug.cgi?id=197108
+        <rdar://problem/49918702>
+
+        Reviewed by Alex Christensen.
+
+        Except for the details below, this patch introduces the utility functions
+        prepareTest() and tearDownAndFinish() and all applicable tests now make use
+        of them.
+
+        * http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html:
+        * http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html:
+        * http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html:
+        * http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt: Added.
+        * http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html: Copied from LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html.
+        * http/tests/adClickAttribution/resources/conversionReport.php:
+            Now tries to set a cookie in the response.
+        * http/tests/adClickAttribution/resources/util.js: Added.
+        (prepareTest):
+        (tearDownAndFinish):
+        * http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html:
+        * http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html:
+        * http/tests/adClickAttribution/second-conversion-with-higher-priority.html:
+        * http/tests/adClickAttribution/second-conversion-with-lower-priority.html:
+        * http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt:
+        * http/tests/adClickAttribution/send-attribution-conversion-request.html:
+        * http/tests/adClickAttribution/store-ad-click-attribution.html:
+            Now sets a cookie which is checked for it in the conversion report.
+        * http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt: Added.
+        * http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html: Copied from LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html.
+
</ins><span class="cx"> 2019-04-19  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Standardize the `<meta name="color-scheme">` separator.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughcrosssiteimageredirecthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html    2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests that triggering of ad click attribution conversions through cross-site redirects do not work.</div>
</span><span class="lines">@@ -10,11 +11,7 @@
</span><span class="cx"> <a id="targetLink" href="http://localhost:8000/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
</span><span class="cx"> <div id="output"></div>
</span><span class="cx"> <script>
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
</del><ins>+    prepareTest();
</ins><span class="cx"> 
</span><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="lines">@@ -25,7 +22,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -40,7 +37,7 @@
</span><span class="cx">                     testRunner.dumpAdClickAttribution();
</span><span class="cx">                     document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                     document.body.removeChild(document.getElementById("pixel"));
</span><del>-                    testRunner.notifyDone();
</del><ins>+                    tearDownAndFinish();
</ins><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughimageredirectwithpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html 2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests triggering of ad click attribution conversions with priority.</div>
</span><span class="lines">@@ -10,11 +11,7 @@
</span><span class="cx"> <a id="targetLink" href="http://localhost:8000/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
</span><span class="cx"> <div id="output"></div>
</span><span class="cx"> <script>
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
</del><ins>+    prepareTest();
</ins><span class="cx"> 
</span><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="lines">@@ -25,7 +22,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -40,7 +37,7 @@
</span><span class="cx">                     testRunner.dumpAdClickAttribution();
</span><span class="cx">                     document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                     document.body.removeChild(document.getElementById("pixel"));
</span><del>-                    testRunner.notifyDone();
</del><ins>+                    tearDownAndFinish();
</ins><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionattributionconversionthroughimageredirectwithoutpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html      2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html 2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests triggering of ad click attribution conversions without priority.</div>
</span><span class="lines">@@ -10,11 +11,7 @@
</span><span class="cx"> <a id="targetLink" href="http://localhost:8000/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
</span><span class="cx"> <div id="output"></div>
</span><span class="cx"> <script>
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
</del><ins>+    prepareTest();
</ins><span class="cx"> 
</span><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="lines">@@ -25,7 +22,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -40,7 +37,7 @@
</span><span class="cx">                     testRunner.dumpAdClickAttribution();
</span><span class="cx">                     document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                     document.body.removeChild(document.getElementById("pixel"));
</span><del>-                    testRunner.notifyDone();
</del><ins>+                    tearDownAndFinish();
</ins><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionconversiondisabledinephemeralsessionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt (0 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt                            (rev 0)
+++ trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session-expected.txt       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Tests that stored attributions cannot be converted in an ephemeral session.
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Conversion not received - timed out.
+
+Unconverted Ad Click Attributions:
+WebCore::AdClickAttribution 1
+Source: 127.0.0.1
+Destination: localhost
+Campaign ID: 3
+No conversion data.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionconversiondisabledinephemeralsessionhtmlfromrev244474trunkLayoutTestshttptestsadClickAttributionsendattributionconversionrequesthtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html (from rev 244474, trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html) (0 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html                            (rev 0)
+++ trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AdClickAttributionEnabled=true ] -->
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src="/js-test-resources/ui-helper.js"></script>
+    <script src="resources/util.js"></script>
+</head>
+<body onload="setTimeout(runTest, 0)">
+<div id="description">Tests that stored attributions cannot be converted in an ephemeral session.</div>
+<a id="targetLink" href="http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.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);
+
+    prepareTest();
+
+    if (window.testRunner)
+        testRunner.setAdClickAttributionConversionURLForTesting("http://127.0.0.1:8000/adClickAttribution/resources/conversionReport.php?nonce=" + nonce);
+
+    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 appendIframe(url, onloadCallback) {
+        let iframeElement = document.createElement("iframe");
+        iframeElement.src = url;
+        if (onloadCallback)
+            iframeElement.onload = onloadCallback;
+        document.body.appendChild(iframeElement);
+    }
+
+    function appendConversionDataIframeAndFinish() {
+        testRunner.dumpAdClickAttribution();
+        document.body.removeChild(document.getElementById("targetLink"));
+        document.body.removeChild(document.getElementById("pixel"));
+
+        appendIframe("http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?timeout_ms=1000&nonce=" + nonce, function() {
+            tearDownAndFinish();
+        });
+    }
+
+    function runTest() {
+        if (window.testRunner) {
+            if (window.location.search === "?stepTwo") {
+                testRunner.setPrivateBrowsingEnabled(true);
+                let imageElement = document.createElement("img");
+                imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12&nonce=" + nonce;
+                imageElement.id = "pixel";
+                imageElement.onerror = function() {
+                    appendConversionDataIframeAndFinish();
+                };
+                document.body.appendChild(imageElement);
+            } else {
+                document.cookie = "cookieSetAsFirstParty=1; path=/";
+                activateElement("targetLink");
+            }
+        } else {
+            document.getElementById("output").innerText = "FAIL No testRunner.";
+        }
+    }
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionresourcesconversionReportphp"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php   2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/resources/conversionReport.php      2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -24,4 +24,8 @@
</span><span class="cx"> }
</span><span class="cx"> fclose($conversionFile);
</span><span class="cx"> rename($conversionFilePath . ".tmp", $conversionFilePath);
</span><ins>+
+header("HTTP/1.1 200 OK");
+setcookie("cookieSetInConversionReport", "1", 0, "/");
+
</ins><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionresourcesutiljs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/adClickAttribution/resources/util.js (0 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/resources/util.js                                (rev 0)
+++ trunk/LayoutTests/http/tests/adClickAttribution/resources/util.js   2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+function prepareTest() {
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpChildFramesAsText();
+        testRunner.dumpAsText();
+        testRunner.setAllowsAnySSLCertificate(true);
+    }
+}
+
+function tearDownAndFinish() {
+    if (window.testRunner) {
+        testRunner.setAllowsAnySSLCertificate(false);
+        testRunner.setAdClickAttributionOverrideTimerForTesting(false);
+        testRunner.setAdClickAttributionConversionURLForTesting("");
+        testRunner.setPrivateBrowsingEnabled(false);
+        testRunner.notifyDone();
+    }
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsecondattributionconvertedwithhigherpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html   2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html      2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests that a second attribution conversion with higher priority replaces an older with lower priority.</div>
</span><span class="lines">@@ -24,6 +25,8 @@
</span><span class="cx">         }
</span><span class="cx">     ];
</span><span class="cx"> 
</span><ins>+    prepareTest();
+
</ins><span class="cx">     function configureLink(index) {
</span><span class="cx">         let linkElement = document.getElementById("targetLink");
</span><span class="cx">         linkElement.setAttribute("href", configuration[index].href);
</span><span class="lines">@@ -31,12 +34,6 @@
</span><span class="cx">         linkElement.setAttribute("addestination", configuration[index].addestination);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
-
</del><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="cx">         var centerX = element.offsetLeft + element.offsetWidth / 2;
</span><span class="lines">@@ -46,7 +43,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -79,12 +76,12 @@
</span><span class="cx">                     testRunner.dumpAdClickAttribution();
</span><span class="cx">                     document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                     document.body.removeChild(document.getElementById("pixel"));
</span><del>-                    testRunner.notifyDone();
</del><ins>+                    tearDownAndFinish();
</ins><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Unknown window.location.search == " + window.location.search + ".";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         } else {
</span><span class="cx">             document.getElementById("output").innerText = "FAIL No testRunner.";
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsecondattributionconvertedwithlowerpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html    2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests that a second attribution conversion with lower priority does not replace an older with higher priority.</div>
</span><span class="lines">@@ -24,6 +25,8 @@
</span><span class="cx">         }
</span><span class="cx">     ];
</span><span class="cx"> 
</span><ins>+    prepareTest();
+
</ins><span class="cx">     function configureLink(index) {
</span><span class="cx">         let linkElement = document.getElementById("targetLink");
</span><span class="cx">         linkElement.setAttribute("href", configuration[index].href);
</span><span class="lines">@@ -31,12 +34,6 @@
</span><span class="cx">         linkElement.setAttribute("addestination", configuration[index].addestination);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
-
</del><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="cx">         var centerX = element.offsetLeft + element.offsetWidth / 2;
</span><span class="lines">@@ -46,7 +43,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -79,12 +76,12 @@
</span><span class="cx">                     testRunner.dumpAdClickAttribution();
</span><span class="cx">                     document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                     document.body.removeChild(document.getElementById("pixel"));
</span><del>-                    testRunner.notifyDone();
</del><ins>+                    tearDownAndFinish();
</ins><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Unknown window.location.search == " + window.location.search + ".";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         } else {
</span><span class="cx">             document.getElementById("output").innerText = "FAIL No testRunner.";
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsecondconversionwithhigherpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-higher-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-higher-priority.html      2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-higher-priority.html 2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests that the attribution is updated if it gets a second conversion with higher priority.</div>
</span><span class="lines">@@ -19,6 +20,8 @@
</span><span class="cx">         }
</span><span class="cx">     ];
</span><span class="cx"> 
</span><ins>+    prepareTest();
+
</ins><span class="cx">     function configureLink(index) {
</span><span class="cx">         let linkElement = document.getElementById("targetLink");
</span><span class="cx">         linkElement.setAttribute("href", configuration[index].href);
</span><span class="lines">@@ -26,12 +29,6 @@
</span><span class="cx">         linkElement.setAttribute("addestination", configuration[index].addestination);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
-
</del><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="cx">         var centerX = element.offsetLeft + element.offsetWidth / 2;
</span><span class="lines">@@ -41,7 +38,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -72,12 +69,12 @@
</span><span class="cx">                         testRunner.dumpAdClickAttribution();
</span><span class="cx">                         document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                         document.body.removeChild(document.getElementById("pixel"));
</span><del>-                        testRunner.notifyDone();
</del><ins>+                        tearDownAndFinish();
</ins><span class="cx">                     });
</span><span class="cx">                 });
</span><span class="cx">             } else {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Unknown window.location.search == " + window.location.search + ".";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         } else {
</span><span class="cx">             document.getElementById("output").innerText = "FAIL No testRunner.";
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsecondconversionwithlowerpriorityhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-lower-priority.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-lower-priority.html       2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/second-conversion-with-lower-priority.html  2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests that the attribution is not updated if it gets a second conversion with lower priority.</div>
</span><span class="lines">@@ -19,6 +20,8 @@
</span><span class="cx">         }
</span><span class="cx">     ];
</span><span class="cx"> 
</span><ins>+    prepareTest();
+
</ins><span class="cx">     function configureLink(index) {
</span><span class="cx">         let linkElement = document.getElementById("targetLink");
</span><span class="cx">         linkElement.setAttribute("href", configuration[index].href);
</span><span class="lines">@@ -26,12 +29,6 @@
</span><span class="cx">         linkElement.setAttribute("addestination", configuration[index].addestination);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
-    }
-
</del><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="cx">         var centerX = element.offsetLeft + element.offsetWidth / 2;
</span><span class="lines">@@ -41,7 +38,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -72,7 +69,7 @@
</span><span class="cx">                         testRunner.dumpAdClickAttribution();
</span><span class="cx">                         document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">                         document.body.removeChild(document.getElementById("pixel"));
</span><del>-                        testRunner.notifyDone();
</del><ins>+                        tearDownAndFinish();
</ins><span class="cx">                     });
</span><span class="cx">                 });
</span><span class="cx">             } else {
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsendattributionconversionrequestexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt 2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request-expected.txt    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-Tests sending of ad click attribution requests after a conversion.
</del><ins>+Tests sending of ad click attribution requests after a conversion. Also tests that cookies are not sent in those requests and cookies are not accepted in the responses.
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -5,9 +5,20 @@
</span><span class="cx"> --------
</span><span class="cx"> Frame: '<!--frame1-->'
</span><span class="cx"> --------
</span><ins>+Cookies are: cookieSetAsFirstParty = 1
+
+--------
+Frame: '<!--frame2-->'
+--------
</ins><span class="cx"> Conversion received.
</span><span class="cx"> HTTP_HOST: 127.0.0.1:8000
</span><span class="cx"> REQUEST_URI: /adClickAttribution/resources/conversionReport.php?conversion=12&campaign=3
</span><span class="cx"> No cookies in conversion request.
</span><span class="cx"> 
</span><ins>+
+--------
+Frame: '<!--frame3-->'
+--------
+Cookies are: cookieSetAsFirstParty = 1
+
</ins><span class="cx"> No stored Ad Click Attribution data.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionsendattributionconversionrequesthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html 2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,9 +4,10 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><del>-<div id="description">Tests sending of ad click attribution requests after a conversion.</div>
</del><ins>+<div id="description">Tests sending of ad click attribution requests after a conversion. Also tests that cookies are not sent in those requests and cookies are not accepted in the responses.</div>
</ins><span class="cx"> <a id="targetLink" href="http://localhost:8000/adClickAttribution/send-attribution-conversion-request.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
</span><span class="cx"> <div id="output"></div>
</span><span class="cx"> <script>
</span><span class="lines">@@ -14,12 +15,11 @@
</span><span class="cx">     const highEntropyBits = currentTimeMillis - (Math.floor(currentTimeMillis / 1000000) * 1000000);
</span><span class="cx">     const nonce = highEntropyBits + "" + Math.floor(Math.random() * 100);
</span><span class="cx"> 
</span><ins>+    prepareTest();
+
</ins><span class="cx">     if (window.testRunner) {
</span><del>-        testRunner.waitUntilDone();
-        testRunner.dumpChildFramesAsText();
-        testRunner.setAllowsAnySSLCertificate(true);
</del><ins>+        testRunner.setAdClickAttributionOverrideTimerForTesting(true);
</ins><span class="cx">         testRunner.setAdClickAttributionConversionURLForTesting("http://127.0.0.1:8000/adClickAttribution/resources/conversionReport.php?nonce=" + nonce);
</span><del>-        testRunner.setAdClickAttributionOverrideTimerForTesting(true);
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function activateElement(elementID) {
</span><span class="lines">@@ -31,19 +31,30 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    function appendIframe(url, onloadCallback) {
+        let iframeElement = document.createElement("iframe");
+        iframeElement.src = url;
+        if (onloadCallback)
+            iframeElement.onload = onloadCallback;
+        document.body.appendChild(iframeElement);
+    }
+
</ins><span class="cx">     function appendConversionDataIframeAndFinish() {
</span><span class="cx">         testRunner.dumpAdClickAttribution();
</span><span class="cx">         document.body.removeChild(document.getElementById("targetLink"));
</span><span class="cx">         document.body.removeChild(document.getElementById("pixel"));
</span><span class="cx"> 
</span><del>-        let iframeElement = document.createElement("iframe");
-        iframeElement.src = "http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?endTest=true&timeout_ms=2000&nonce=" + nonce;
-        document.body.appendChild(iframeElement);
</del><ins>+        appendIframe("http://127.0.0.1:8000/cookies/resources/echo-cookies.php");
+        appendIframe("http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?timeout_ms=2000&nonce=" + nonce, function() {
+            appendIframe("http://127.0.0.1:8000/cookies/resources/echo-cookies.php", function() {
+                tearDownAndFinish();
+            });
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function runTest() {
</span><span class="lines">@@ -57,6 +68,7 @@
</span><span class="cx">                 };
</span><span class="cx">                 document.body.appendChild(imageElement);
</span><span class="cx">             } else {
</span><ins>+                document.cookie = "cookieSetAsFirstParty=1; path=/";
</ins><span class="cx">                 activateElement("targetLink");
</span><span class="cx">             }
</span><span class="cx">         } else {
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionstoreadclickattributionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html  2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html     2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">     <meta charset="UTF-8">
</span><span class="cx">     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</span><span class="cx">     <script src="/js-test-resources/ui-helper.js"></script>
</span><ins>+    <script src="resources/util.js"></script>
</ins><span class="cx"> </head>
</span><span class="cx"> <body onload="setTimeout(runTest, 0)">
</span><span class="cx"> <div id="description">Tests storage of ad click attribution.</div>
</span><span class="lines">@@ -10,10 +11,7 @@
</span><span class="cx"> <a id="targetLink" href="http://localhost:8000/adClickAttribution/store-ad-click-attribution.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
</span><span class="cx"> <div id="output"></div>
</span><span class="cx"> <script>
</span><del>-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-    }
</del><ins>+    prepareTest();
</ins><span class="cx"> 
</span><span class="cx">     function activateElement(elementID) {
</span><span class="cx">         var element = document.getElementById(elementID);
</span><span class="lines">@@ -24,7 +22,7 @@
</span><span class="cx">             },
</span><span class="cx">             function () {
</span><span class="cx">                 document.getElementById("output").innerText = "FAIL Promise rejected.";
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             }
</span><span class="cx">         );
</span><span class="cx">     }
</span><span class="lines">@@ -34,7 +32,7 @@
</span><span class="cx">             if (window.location.search === "?stepTwo") {
</span><span class="cx">                 testRunner.dumpAdClickAttribution();
</span><span class="cx">                 document.body.removeChild(document.getElementById("targetLink"));
</span><del>-                testRunner.notifyDone();
</del><ins>+                tearDownAndFinish();
</ins><span class="cx">             } else {
</span><span class="cx">                 activateElement("targetLink");
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionstoredisabledinephemeralsessionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt (0 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt                         (rev 0)
+++ trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session-expected.txt    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+Tests that storage of ad click attribution is disabled in ephemeral sessions.
+
+
+
+No stored Ad Click Attribution data.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsadClickAttributionstoredisabledinephemeralsessionhtmlfromrev244474trunkLayoutTestshttptestsadClickAttributionstoreadclickattributionhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html (from rev 244474, trunk/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html) (0 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html                         (rev 0)
+++ trunk/LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AdClickAttributionEnabled=true ] -->
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src="/js-test-resources/ui-helper.js"></script>
+    <script src="resources/util.js"></script>
+</head>
+<body onload="setTimeout(runTest, 0)">
+<div id="description">Tests that storage of ad click attribution is disabled in ephemeral sessions.</div>
+<a id="targetLink" href="http://localhost:8000/adClickAttribution/store-disabled-in-ephemeral-session.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br>
+<div id="output"></div>
+<script>
+    prepareTest();
+
+    if (window.testRunner)
+        testRunner.setPrivateBrowsingEnabled(true);
+
+    function activateElement(elementID) {
+        var element = document.getElementById(elementID);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function () {
+            },
+            function () {
+                document.getElementById("output").innerText = "FAIL Promise rejected.";
+                tearDownAndFinish();
+            }
+        );
+    }
+
+    function runTest() {
+        if (window.testRunner) {
+            if (window.location.search === "?stepTwo") {
+                testRunner.dumpAdClickAttribution();
+                document.body.removeChild(document.getElementById("targetLink"));
+                tearDownAndFinish();
+            } else {
+                activateElement("targetLink");
+            }
+        } else {
+            document.getElementById("output").innerText = "FAIL No testRunner.";
+        }
+    }
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebCore/ChangeLog      2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2019-04-19  John Wilander  <wilander@apple.com>
+
+        Disable Ad Click Attribution in ephemeral sessions and make sure conversion requests use an ephemeral, stateless session
+        https://bugs.webkit.org/show_bug.cgi?id=197108
+        <rdar://problem/49918702>
+
+        Reviewed by Alex Christensen.
+
+        Tests: http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
+               http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::parseAdClickAttribution const):
+            Early return for ephemeral sessions.
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::shouldUseCredentialStorage):
+            Now returns false for StoredCredentialsPolicy:EphemeralStatelessCookieless.
+        * platform/network/StoredCredentialsPolicy.h:
+            Added enum value EphemeralStatelessCookieless.
+
</ins><span class="cx"> 2019-04-19  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Standardize the <meta name="color-scheme"> separator.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAnchorElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp  2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp     2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -405,7 +405,9 @@
</span><span class="cx">     using Source = AdClickAttribution::Source;
</span><span class="cx">     using Destination = AdClickAttribution::Destination;
</span><span class="cx"> 
</span><del>-    if (!RuntimeEnabledFeatures::sharedFeatures().adClickAttributionEnabled() || !UserGestureIndicator::processingUserGesture())
</del><ins>+    if (document().sessionID().isEphemeral()
+        || !RuntimeEnabledFeatures::sharedFeatures().adClickAttributionEnabled()
+        || !UserGestureIndicator::processingUserGesture())
</ins><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><span class="cx">     if (!hasAttributeWithoutSynchronization(adcampaignidAttr) && !hasAttributeWithoutSynchronization(addestinationAttr))
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp   2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp      2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -717,7 +717,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool ResourceLoader::shouldUseCredentialStorage()
</span><span class="cx"> {
</span><del>-    if (m_options.storedCredentialsPolicy == StoredCredentialsPolicy::DoNotUse)
</del><ins>+    if (m_options.storedCredentialsPolicy != StoredCredentialsPolicy::Use)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     Ref<ResourceLoader> protectedThis(*this);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkStoredCredentialsPolicyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/StoredCredentialsPolicy.h (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/StoredCredentialsPolicy.h  2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebCore/platform/network/StoredCredentialsPolicy.h     2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -27,9 +27,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-enum class StoredCredentialsPolicy : bool {
</del><ins>+enum class StoredCredentialsPolicy : uint8_t {
</ins><span class="cx">     DoNotUse,
</span><span class="cx">     Use,
</span><ins>+    EphemeralStatelessCookieless
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/ChangeLog       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2019-04-19  John Wilander  <wilander@apple.com>
+
+        Disable Ad Click Attribution in ephemeral sessions and make sure conversion requests use an ephemeral, stateless session
+        https://bugs.webkit.org/show_bug.cgi?id=197108
+        <rdar://problem/49918702>
+
+        Reviewed by Alex Christensen.
+
+        This patch introduces a new NSURLSession in WebKit::NetworkSessionCocoa called
+        m_ephemeralStatelessCookielessSession. As its name implies, it's ephemeral, 
+        stateless, and has a NSHTTPCookieAcceptPolicyNever cookie policy.
+
+        The new session can be invoked with the new enum value of
+        WebCore::StoredCredentialsPolicy called EphemeralStatelessCookieless.
+
+        WebKit::AdClickAttributionManager::fireConversionRequest() makes use of
+        the new session for its conversion requests.
+
+        This patch also makes sure that Ad Click Attributions cannot be stored in
+        ephemeral sessions and already stored attributions cannot be converted in
+        ephemeral sessions.
+
+        * NetworkProcess/AdClickAttributionManager.cpp:
+        (WebKit::AdClickAttributionManager::fireConversionRequest):
+        (WebKit::AdClickAttributionManager::toString const):
+        * NetworkProcess/NetworkLoadChecker.h:
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+            Calls NetworkSessionCocoa::initializeEphemeralStatelessCookielessSession() lazily.
+        (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
+        (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::initializeEphemeralStatelessCookielessSession):
+        (WebKit::NetworkSessionCocoa::invalidateAndCancel):
+        * Shared/WebCoreArgumentCoders.h:
+
</ins><span class="cx"> 2019-04-19  Daniel Bates  <dabates@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Use RetainPtr and rename +autocorrectionRectsWithRects:lastRect: to +autocorrectionRectsWithFirstCGRect:lastCGRect:
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessAdClickAttributionManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp 2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -119,9 +119,8 @@
</span><span class="cx">     loadParameters.request = request;
</span><span class="cx">     loadParameters.sourceOrigin = SecurityOrigin::create(conversionReferrerURL);
</span><span class="cx">     loadParameters.parentPID = presentingApplicationPID();
</span><del>-    // FIXME: Switch to the use of an ephemeral, stateless session.
</del><span class="cx">     loadParameters.sessionID = PAL::SessionID::defaultSessionID();
</span><del>-    loadParameters.storedCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
</del><ins>+    loadParameters.storedCredentialsPolicy = StoredCredentialsPolicy::EphemeralStatelessCookieless;
</ins><span class="cx">     loadParameters.options = options;
</span><span class="cx">     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = true;
</span><span class="cx">     loadParameters.shouldRestrictHTTPResponseAccess = false;
</span><span class="lines">@@ -181,7 +180,7 @@
</span><span class="cx"> void AdClickAttributionManager::toString(CompletionHandler<void(String)>&& completionHandler) const
</span><span class="cx"> {
</span><span class="cx">     if (m_unconvertedAdClickAttributionMap.isEmpty() && m_convertedAdClickAttributionMap.isEmpty())
</span><del>-        return completionHandler("No stored Ad Click Attribution data.\n"_s);
</del><ins>+        return completionHandler("\nNo stored Ad Click Attribution data.\n"_s);
</ins><span class="cx"> 
</span><span class="cx">     unsigned unconvertedAttributionNumber = 0;
</span><span class="cx">     StringBuilder builder;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkLoadCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h  2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h     2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> struct ContentSecurityPolicyClient;
</span><span class="cx"> class SecurityOrigin;
</span><span class="cx"> enum class PreflightPolicy : uint8_t;
</span><del>-enum class StoredCredentialsPolicy : bool;
</del><ins>+enum class StoredCredentialsPolicy : uint8_t;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h      2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx"> class ResourceError;
</span><span class="cx"> class SWServer;
</span><span class="cx"> enum class IncludeHttpOnlyCookies : bool;
</span><del>-enum class StoredCredentialsPolicy : bool;
</del><ins>+enum class StoredCredentialsPolicy : uint8_t;
</ins><span class="cx"> struct ClientOrigin;
</span><span class="cx"> struct MessageWithMessagePorts;
</span><span class="cx"> struct SecurityOriginData;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in    2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in       2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx">     CancelPrepareToSuspend()
</span><span class="cx">     ProcessDidResume()
</span><span class="cx"> 
</span><del>-    PreconnectTo(URL url, enum:bool WebCore::StoredCredentialsPolicy storedCredentialsPolicy);
</del><ins>+    PreconnectTo(URL url, enum:uint8_t WebCore::StoredCredentialsPolicy storedCredentialsPolicy);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><span class="cx">     ClearPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp     2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp        2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -586,13 +586,15 @@
</span><span class="cx">     ++m_redirectCount;
</span><span class="cx"> 
</span><span class="cx">     auto& redirectURL = redirectRequest.url();
</span><del>-    if (auto adClickConversion = AdClickAttribution::parseConversionRequest(redirectURL)) {
-        RegistrableDomain redirectDomain { redirectURL };
-        auto& firstPartyURL = redirectRequest.firstPartyForCookies();
-        NetworkSession* networkSession;
-        // The redirect has to be done by the same registrable domain and it has to be a third-party request.
-        if (redirectDomain.matches(request.url()) && !redirectDomain.matches(firstPartyURL) && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
-            networkSession->convertAdClickAttribution(AdClickAttribution::Source { WTFMove(redirectDomain) }, AdClickAttribution::Destination { firstPartyURL }, WTFMove(*adClickConversion));
</del><ins>+    if (!sessionID().isEphemeral()) {
+        if (auto adClickConversion = AdClickAttribution::parseConversionRequest(redirectURL)) {
+            RegistrableDomain redirectDomain { redirectURL };
+            auto& firstPartyURL = redirectRequest.firstPartyForCookies();
+            NetworkSession* networkSession = nullptr;
+            // The redirect has to be done by the same registrable domain and it has to be a third-party request.
+            if (redirectDomain.matches(request.url()) && !redirectDomain.matches(firstPartyURL) && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
+                networkSession->convertAdClickAttribution(AdClickAttribution::Source { WTFMove(redirectDomain) }, AdClickAttribution::Destination { firstPartyURL }, WTFMove(*adClickConversion));
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     auto maxAgeCap = validateCacheEntryForMaxAgeCapValidation(request, redirectRequest, redirectResponse);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm    2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool shouldBlockCookies = false;
</span><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><del>-    shouldBlockCookies = session.networkStorageSession().shouldBlockCookies(request, frameID, pageID);
</del><ins>+    shouldBlockCookies = storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless || session.networkStorageSession().shouldBlockCookies(request, frameID, pageID);
</ins><span class="cx"> #endif
</span><span class="cx">     restrictRequestReferrerToOriginIfNeeded(request, shouldBlockCookies);
</span><span class="cx"> 
</span><span class="lines">@@ -201,16 +201,27 @@
</span><span class="cx">     applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(nsRequest, shouldContentSniff == WebCore::ContentSniffingPolicy::SniffContent && !url.isLocalFile(), shouldContentEncodingSniff == WebCore::ContentEncodingSniffingPolicy::Sniff);
</span><span class="cx"> 
</span><span class="cx">     auto& cocoaSession = static_cast<NetworkSessionCocoa&>(m_session.get());
</span><del>-    if (storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::Use) {
</del><ins>+    switch (storedCredentialsPolicy) {
+    case WebCore::StoredCredentialsPolicy::Use:
</ins><span class="cx">         m_task = [cocoaSession.m_sessionWithCredentialStorage dataTaskWithRequest:nsRequest];
</span><span class="cx">         ASSERT(!cocoaSession.m_dataTaskMapWithCredentials.contains([m_task taskIdentifier]));
</span><span class="cx">         cocoaSession.m_dataTaskMapWithCredentials.add([m_task taskIdentifier], this);
</span><span class="cx">         LOG(NetworkSession, "%llu Creating stateful NetworkDataTask with URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
</span><del>-    } else {
</del><ins>+        break;
+    case WebCore::StoredCredentialsPolicy::DoNotUse:
</ins><span class="cx">         m_task = [cocoaSession.m_statelessSession dataTaskWithRequest:nsRequest];
</span><span class="cx">         ASSERT(!cocoaSession.m_dataTaskMapWithoutState.contains([m_task taskIdentifier]));
</span><span class="cx">         cocoaSession.m_dataTaskMapWithoutState.add([m_task taskIdentifier], this);
</span><span class="cx">         LOG(NetworkSession, "%llu Creating stateless NetworkDataTask with URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
</span><ins>+        break;
+    case WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless:
+        if (!cocoaSession.m_ephemeralStatelessCookielessSession)
+            cocoaSession.initializeEphemeralStatelessCookielessSession();
+        m_task = [cocoaSession.m_ephemeralStatelessCookielessSession dataTaskWithRequest:nsRequest];
+        ASSERT(!cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.contains([m_task taskIdentifier]));
+        cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.add([m_task taskIdentifier], this);
+        LOG(NetworkSession, "%llu Creating ephemeral, stateless, cookieless NetworkDataTask with URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
+        break;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (shouldPreconnectOnly == PreconnectOnly::Yes) {
</span><span class="lines">@@ -250,12 +261,19 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto& cocoaSession = static_cast<NetworkSessionCocoa&>(m_session.get());
</span><del>-    if (m_storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::Use) {
</del><ins>+    switch (m_storedCredentialsPolicy) {
+    case WebCore::StoredCredentialsPolicy::Use:
</ins><span class="cx">         ASSERT(cocoaSession.m_dataTaskMapWithCredentials.get([m_task taskIdentifier]) == this);
</span><span class="cx">         cocoaSession.m_dataTaskMapWithCredentials.remove([m_task taskIdentifier]);
</span><del>-    } else {
</del><ins>+        break;
+    case WebCore::StoredCredentialsPolicy::DoNotUse:
</ins><span class="cx">         ASSERT(cocoaSession.m_dataTaskMapWithoutState.get([m_task taskIdentifier]) == this);
</span><span class="cx">         cocoaSession.m_dataTaskMapWithoutState.remove([m_task taskIdentifier]);
</span><ins>+        break;
+    case WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless:
+        ASSERT(cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.get([m_task taskIdentifier]) == this);
+        cocoaSession.m_dataTaskMapEphemeralStatelessCookieless.remove([m_task taskIdentifier]);
+        break;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -345,7 +363,7 @@
</span><span class="cx">         request.setFirstPartyForCookies(request.url());
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><del>-    bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);
</del><ins>+    bool shouldBlockCookies = m_storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless || m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);
</ins><span class="cx"> #if !RELEASE_LOG_DISABLED
</span><span class="cx">     if (m_session->shouldLogCookieInformation())
</span><span class="cx">         RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::willPerformHTTPRedirection::logCookieInformation: pageID = %llu, frameID = %llu, taskID = %lu: %s cookies for redirect URL %s", this, m_pageID, m_frameID, (unsigned long)[m_task taskIdentifier], (shouldBlockCookies ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h   2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h      2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx">     static Ref<NetworkSession> create(NetworkProcess&, NetworkSessionCreationParameters&&);
</span><span class="cx">     ~NetworkSessionCocoa();
</span><span class="cx"> 
</span><ins>+    void initializeEphemeralStatelessCookielessSession();
+
</ins><span class="cx">     const String& sourceApplicationBundleIdentifier() const;
</span><span class="cx">     const String& sourceApplicationSecondaryIdentifier() const;
</span><span class="cx">     // Must be called before any NetworkSession has been created.
</span><span class="lines">@@ -77,6 +79,7 @@
</span><span class="cx"> 
</span><span class="cx">     HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapWithCredentials;
</span><span class="cx">     HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapWithoutState;
</span><ins>+    HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapEphemeralStatelessCookieless;
</ins><span class="cx">     HashMap<NetworkDataTaskCocoa::TaskIdentifier, DownloadID> m_downloadMap;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr<NSURLSession> m_sessionWithCredentialStorage;
</span><span class="lines">@@ -83,6 +86,8 @@
</span><span class="cx">     RetainPtr<WKNetworkSessionDelegate> m_sessionWithCredentialStorageDelegate;
</span><span class="cx">     RetainPtr<NSURLSession> m_statelessSession;
</span><span class="cx">     RetainPtr<WKNetworkSessionDelegate> m_statelessSessionDelegate;
</span><ins>+    RetainPtr<NSURLSession> m_ephemeralStatelessCookielessSession;
+    RetainPtr<WKNetworkSessionDelegate> m_ephemeralStatelessCookielessSessionDelegate;
</ins><span class="cx"> 
</span><span class="cx">     String m_boundInterfaceIdentifier;
</span><span class="cx">     String m_sourceApplicationBundleIdentifier;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm  2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm     2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -998,6 +998,28 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkSessionCocoa::initializeEphemeralStatelessCookielessSession()
+{
+    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
+    NSURLSessionConfiguration *existingConfiguration = m_statelessSession.get().configuration;
+
+    configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyNever;
+    configuration.URLCredentialStorage = nil;
+    configuration.URLCache = nil;
+    configuration.allowsCellularAccess = existingConfiguration.allowsCellularAccess;
+    configuration.connectionProxyDictionary = existingConfiguration.connectionProxyDictionary;
+
+    configuration._shouldSkipPreferredClientCertificateLookup = YES;
+    configuration._sourceApplicationAuditTokenData = existingConfiguration._sourceApplicationAuditTokenData;
+    configuration._sourceApplicationSecondaryIdentifier = existingConfiguration._sourceApplicationSecondaryIdentifier;
+#if PLATFORM(IOS_FAMILY)
+    configuration._CTDataConnectionServiceType = existingConfiguration._CTDataConnectionServiceType;
+#endif
+
+    m_ephemeralStatelessCookielessSessionDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:false]);
+    m_ephemeralStatelessCookielessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_ephemeralStatelessCookielessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
+}
+
</ins><span class="cx"> void NetworkSessionCocoa::invalidateAndCancel()
</span><span class="cx"> {
</span><span class="cx">     NetworkSession::invalidateAndCancel();
</span><span class="lines">@@ -1004,8 +1026,10 @@
</span><span class="cx"> 
</span><span class="cx">     [m_sessionWithCredentialStorage invalidateAndCancel];
</span><span class="cx">     [m_statelessSession invalidateAndCancel];
</span><ins>+    [m_ephemeralStatelessCookielessSession invalidateAndCancel];
</ins><span class="cx">     [m_sessionWithCredentialStorageDelegate sessionInvalidated];
</span><span class="cx">     [m_statelessSessionDelegate sessionInvalidated];
</span><ins>+    [m_ephemeralStatelessCookielessSessionDelegate sessionInvalidated];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkSessionCocoa::clearCredentials()
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebCoreArgumentCodersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (244474 => 244475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h       2019-04-19 23:49:09 UTC (rev 244474)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h  2019-04-20 00:00:26 UTC (rev 244475)
</span><span class="lines">@@ -854,6 +854,15 @@
</span><span class="cx">     >;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template<> struct EnumTraits<WebCore::StoredCredentialsPolicy> {
+    using values = EnumValues<
+        WebCore::StoredCredentialsPolicy,
+        WebCore::StoredCredentialsPolicy::DoNotUse,
+        WebCore::StoredCredentialsPolicy::Use,
+        WebCore::StoredCredentialsPolicy::EphemeralStatelessCookieless
+    >;
+};
+
</ins><span class="cx"> #if USE(CURL)
</span><span class="cx"> template <> struct EnumTraits<WebCore::CurlProxySettings::Mode> {
</span><span class="cx">     using values = EnumValues<
</span></span></pre>
</div>
</div>

</body>
</html>