<!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>[202089] 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/202089">202089</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-06-15 07:12:16 -0700 (Wed, 15 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Vary:Cookie validation doesn't work in private browsing
https://bugs.webkit.org/show_bug.cgi?id=158616
Source/WebCore:

&lt;rdar://problem/26755067&gt;

Reviewed by Andreas Kling.

There wasn't a way to get cookie based on SessionID from WebCore.

* platform/CookiesStrategy.h:

    Add a cookie retrival function that takes SessionID instead of NetworkStorageSession.

* platform/network/CacheValidation.cpp:
(WebCore::headerValueForVary):

    Use it.

(WebCore::verifyVaryingRequestHeaders):

Source/WebKit/mac:

&lt;rdar://problem/26755067&gt;

Reviewed by Andreas Kling.

* WebCoreSupport/WebFrameNetworkingContext.h:
(WebFrameNetworkingContext::create):
* WebCoreSupport/WebFrameNetworkingContext.mm:
(privateSession):
(WebFrameNetworkingContext::ensurePrivateBrowsingSession):

    Expose the private browsing session.

(WebFrameNetworkingContext::destroyPrivateBrowsingSession):
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::cookieRequestHeaderFieldValue):

    Implement SessionID version of the function.

(WebPlatformStrategies::getRawCookies):

Source/WebKit2:

&lt;rdar://problem/26755067&gt;

Reviewed by Andreas Kling.

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):

    Implement SessionID version of the function.

* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

LayoutTests:

Reviewed by Darin Adler.

* http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt:
* http/tests/cache/disk-cache/disk-cache-vary-cookie.html:

Exapand the existing test to cover memory cache and private browsing.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevarycookieexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevarycookiehtml">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformCookiesStrategyh">trunk/Source/WebCore/platform/CookiesStrategy.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkCacheValidationcpp">trunk/Source/WebCore/platform/network/CacheValidation.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameNetworkingContexth">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameNetworkingContextmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebPlatformStrategiesh">trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebPlatformStrategiesmm">trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebFrameNetworkingContextcpp">trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebFrameNetworkingContexth">trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiesh">trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/LayoutTests/ChangeLog        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+
+        Reviewed by Darin Adler.
+
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt:
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
+
+        Exapand the existing test to cover memory cache and private browsing.
+
</ins><span class="cx"> 2016-06-14  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Honor bidi unicode codepoints
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevarycookieexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -1,8 +1,9 @@
</span><del>-Test that Vary: Cookie in response is handled by the disk cache.
</del><ins>+Test that Vary: Cookie in response is handled by caches.
</ins><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+Testing disk cache
</ins><span class="cx"> Setting cookie and loading
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> response source: Network
</span><span class="lines">@@ -31,6 +32,64 @@
</span><span class="cx"> response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><ins>+Testing memory cache
+Setting cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Changing cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Testing memory cache in private browsing
+Setting cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Changing cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevarycookiehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -3,32 +3,48 @@
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> 
</span><del>-var tests =
-[
-  { responseHeaders: {'Cache-control': 'max-age=100'} },
-  { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
-];
</del><span class="cx"> 
</span><del>-description(&quot;Test that Vary: Cookie in response is handled by the disk cache.&quot;);
</del><ins>+description(&quot;Test that Vary: Cookie in response is handled by caches.&quot;);
</ins><span class="cx"> 
</span><del>-debug(&quot;Setting cookie and loading&quot;);
-document.cookie = &quot;cookie=value&quot;;
-loadResources(tests, function () {
-    printResults(tests);
-    debug(&quot;Loading again&quot;);
-    loadResources(tests, function () {
</del><ins>+function testCookies(testDiskCache, completionHandler)
+{
+    var tests = [
+      { responseHeaders: {'Cache-control': 'max-age=100'} },
+      { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
+    ];
+
+    var options = { &quot;ClearMemoryCache&quot; : testDiskCache };
+    debug(&quot;Setting cookie and loading&quot;);
+    document.cookie = &quot;cookie=&quot; + Math.floor((Math.random() * 1000000000000));
+    loadResourcesWithOptions(tests, options, function () {
</ins><span class="cx">         printResults(tests);
</span><del>-        debug(&quot;Changing cookie and loading&quot;);
-        document.cookie = &quot;cookie=othervalue&quot;;
-        loadResources(tests, function () {
</del><ins>+        debug(&quot;Loading again&quot;);
+        loadResourcesWithOptions(tests, options, function () {
</ins><span class="cx">             printResults(tests);
</span><del>-            debug(&quot;Loading again&quot;);
-            loadResources(tests, function () {
-               printResults(tests);
-               finishJSTest();
</del><ins>+            debug(&quot;Changing cookie and loading&quot;);
+            document.cookie = &quot;cookie&quot; + Math.floor((Math.random() * 1000000000000));
+            loadResourcesWithOptions(tests, options, function () {
+                printResults(tests);
+                debug(&quot;Loading again&quot;);
+                loadResourcesWithOptions(tests, options, function () {
+                   printResults(tests);
+                   completionHandler();
+                });
</ins><span class="cx">             });
</span><span class="cx">         });
</span><span class="cx">     });
</span><ins>+}
+
+debug(&quot;Testing disk cache&quot;);
+testCookies(true, function () {
+    debug(&quot;Testing memory cache&quot;);
+    testCookies(false, function () {
+        debug(&quot;Testing memory cache in private browsing&quot;);
+        testRunner.setPrivateBrowsingEnabled(true);
+        testCookies(false, function () {
+            finishJSTest();
+        });
+    });
</ins><span class="cx"> });
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebCore/ChangeLog        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-06-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        &lt;rdar://problem/26755067&gt;
+
+        Reviewed by Andreas Kling.
+
+        There wasn't a way to get cookie based on SessionID from WebCore.
+
+        * platform/CookiesStrategy.h:
+
+            Add a cookie retrival function that takes SessionID instead of NetworkStorageSession.
+
+        * platform/network/CacheValidation.cpp:
+        (WebCore::headerValueForVary):
+
+            Use it.
+
+        (WebCore::verifyVaryingRequestHeaders):
+
</ins><span class="cx"> 2016-06-15  Per Arne Vollan  &lt;pvollan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] The test accessibility/selected-text-range-aria-elements.html is failing.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformCookiesStrategyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/CookiesStrategy.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/CookiesStrategy.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebCore/platform/CookiesStrategy.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef CookiesStrategy_h
</span><span class="cx"> #define CookiesStrategy_h
</span><span class="cx"> 
</span><ins>+#include &quot;SessionID.h&quot;
</ins><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -43,6 +44,7 @@
</span><span class="cx">     virtual void setCookiesFromDOM(const NetworkStorageSession&amp;, const URL&amp; firstParty, const URL&amp;, const String&amp; cookieString) = 0;
</span><span class="cx">     virtual bool cookiesEnabled(const NetworkStorageSession&amp;, const URL&amp; firstParty, const URL&amp;) = 0;
</span><span class="cx">     virtual String cookieRequestHeaderFieldValue(const NetworkStorageSession&amp;, const URL&amp; firstParty, const URL&amp;) = 0;
</span><ins>+    virtual String cookieRequestHeaderFieldValue(SessionID, const URL&amp; firstParty, const URL&amp;) = 0;
</ins><span class="cx">     virtual bool getRawCookies(const NetworkStorageSession&amp;, const URL&amp; firstParty, const URL&amp;, Vector&lt;Cookie&gt;&amp;) = 0;
</span><span class="cx">     virtual void deleteCookie(const NetworkStorageSession&amp;, const URL&amp;, const String&amp; cookieName) = 0;
</span><span class="cx">     virtual void addCookie(const NetworkStorageSession&amp;, const URL&amp;, const Cookie&amp;) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkCacheValidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/CacheValidation.cpp        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -338,15 +338,12 @@
</span><span class="cx">     // We could fetch the cookie when making the request but that seems overkill as the case is very rare and it
</span><span class="cx">     // is a blocking operation. This should be sufficient to cover reasonable cases.
</span><span class="cx">     if (headerName == httpHeaderNameString(HTTPHeaderName::Cookie)) {
</span><del>-        if (sessionID != SessionID::defaultSessionID()) {
-            // FIXME: Don't know how to get the cookie. There should be a global way to get NetworkStorageSession from sessionID.
-            return &quot;&quot;;
-        }
-        auto&amp; session = NetworkStorageSession::defaultStorageSession();
</del><span class="cx">         auto* cookieStrategy = platformStrategies() ? platformStrategies()-&gt;cookiesStrategy() : nullptr;
</span><del>-        if (!cookieStrategy)
-            return cookieRequestHeaderFieldValue(session, request.firstPartyForCookies(), request.url());
-        return cookieStrategy-&gt;cookieRequestHeaderFieldValue(session, request.firstPartyForCookies(), request.url());
</del><ins>+        if (!cookieStrategy) {
+            ASSERT(sessionID == SessionID::defaultSessionID());
+            return cookieRequestHeaderFieldValue(NetworkStorageSession::defaultStorageSession(), request.firstPartyForCookies(), request.url());
+        }
+        return cookieStrategy-&gt;cookieRequestHeaderFieldValue(sessionID, request.firstPartyForCookies(), request.url());
</ins><span class="cx">     }
</span><span class="cx">     return request.httpHeaderField(headerName);
</span><span class="cx"> }
</span><span class="lines">@@ -374,10 +371,6 @@
</span><span class="cx">         // FIXME: Vary: * in response would ideally trigger a cache delete instead of a store.
</span><span class="cx">         if (varyingRequestHeader.first == &quot;*&quot;)
</span><span class="cx">             return false;
</span><del>-        if (sessionID != SessionID::defaultSessionID() &amp;&amp; varyingRequestHeader.first == httpHeaderNameString(HTTPHeaderName::Cookie)) {
-            // FIXME: See the comment in headerValueForVary.
-            return false;
-        }
</del><span class="cx">         String headerValue = headerValueForVary(request, varyingRequestHeader.first, sessionID);
</span><span class="cx">         if (headerValue != varyingRequestHeader.second)
</span><span class="cx">             return false;
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-06-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        &lt;rdar://problem/26755067&gt;
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebFrameNetworkingContext.h:
+        (WebFrameNetworkingContext::create):
+        * WebCoreSupport/WebFrameNetworkingContext.mm:
+        (privateSession):
+        (WebFrameNetworkingContext::ensurePrivateBrowsingSession):
+
+            Expose the private browsing session.
+
+        (WebFrameNetworkingContext::destroyPrivateBrowsingSession):
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::cookieRequestHeaderFieldValue):
+
+            Implement SessionID version of the function.
+
+        (WebPlatformStrategies::getRawCookies):
+
</ins><span class="cx"> 2016-06-13  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add WebSocketProvider stub
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameNetworkingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">         return adoptRef(new WebFrameNetworkingContext(frame));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static void ensurePrivateBrowsingSession();
</del><ins>+    static WebCore::NetworkStorageSession&amp; ensurePrivateBrowsingSession();
</ins><span class="cx">     static void destroyPrivateBrowsingSession();
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameNetworkingContextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -50,14 +50,16 @@
</span><span class="cx">     return session;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
</del><ins>+NetworkStorageSession&amp; WebFrameNetworkingContext::ensurePrivateBrowsingSession()
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx"> 
</span><span class="cx">     if (privateSession())
</span><del>-        return;
</del><ins>+        return *privateSession();
</ins><span class="cx"> 
</span><span class="cx">     privateSession() = NetworkStorageSession::createPrivateBrowsingSession(SessionID::legacyPrivateSessionID(), [[NSBundle mainBundle] bundleIdentifier]);
</span><ins>+
+    return *privateSession();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebPlatformStrategiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">     void setCookiesFromDOM(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, const String&amp;) override;
</span><span class="cx">     bool cookiesEnabled(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</span><span class="cx">     String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</span><ins>+    String cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</ins><span class="cx">     bool getRawCookies(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, Vector&lt;WebCore::Cookie&gt;&amp;) override;
</span><span class="cx">     void deleteCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const String&amp;) override;
</span><span class="cx">     void addCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const WebCore::Cookie&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebPlatformStrategiesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -102,6 +102,12 @@
</span><span class="cx">     return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String WebPlatformStrategies::cookieRequestHeaderFieldValue(SessionID sessionID, const URL&amp; firstParty, const URL&amp; url)
+{
+    auto&amp; session = sessionID.isEphemeral() ? WebFrameNetworkingContext::ensurePrivateBrowsingSession() : NetworkStorageSession::defaultStorageSession();
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
+}
+
</ins><span class="cx"> bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession&amp; session, const URL&amp; firstParty, const URL&amp; url, Vector&lt;Cookie&gt;&amp; rawCookies)
</span><span class="cx"> {
</span><span class="cx">     return WebCore::getRawCookies(session, firstParty, url, rawCookies);
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebFrameNetworkingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -71,13 +71,13 @@
</span><span class="cx">     identifierBase() = base;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
</del><ins>+NetworkStorageSession&amp; WebFrameNetworkingContext::ensurePrivateBrowsingSession()
</ins><span class="cx"> {
</span><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx"> 
</span><span class="cx">     if (privateSession())
</span><del>-        return;
</del><ins>+        return *privateSession();
</ins><span class="cx"> 
</span><span class="cx">     String base;
</span><span class="cx">     if (identifierBase().isNull()) {
</span><span class="lines">@@ -88,7 +88,9 @@
</span><span class="cx">         base = identifierBase();
</span><span class="cx"> 
</span><span class="cx">     privateSession() = NetworkStorageSession::createPrivateBrowsingSession(SessionID::legacyPrivateSessionID(), base);
</span><ins>+
</ins><span class="cx"> #endif
</span><ins>+    return *privateSession();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebFrameNetworkingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     static void setCookieAcceptPolicyForAllContexts(WebKitCookieStorageAcceptPolicy);
</span><span class="cx"> #endif
</span><span class="cx">     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&amp;);
</span><del>-    static void ensurePrivateBrowsingSession();
</del><ins>+    static WebCore::NetworkStorageSession&amp; ensurePrivateBrowsingSession();
</ins><span class="cx">     static void destroyPrivateBrowsingSession();
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -94,6 +94,12 @@
</span><span class="cx">     return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String WebPlatformStrategies::cookieRequestHeaderFieldValue(WebCore::SessionID sessionID, const URL&amp; firstParty, const URL&amp; url)
+{
+    auto&amp; session = sessionID.isEphemeral() ? WebFrameNetworkingContext::ensurePrivateBrowsingSession() : NetworkStorageSession::defaultStorageSession();
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
+}
+
</ins><span class="cx"> bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession&amp; session, const URL&amp; firstParty, const URL&amp; url, Vector&lt;Cookie&gt;&amp; rawCookies)
</span><span class="cx"> {
</span><span class="cx">     return WebCore::getRawCookies(session, firstParty, url, rawCookies);
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, const String&amp;);
</span><span class="cx">     virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;);
</span><span class="cx">     virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;);
</span><ins>+    virtual String cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;);
</ins><span class="cx">     virtual bool getRawCookies(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, Vector&lt;WebCore::Cookie&gt;&amp;);
</span><span class="cx">     virtual void deleteCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const String&amp;);
</span><span class="cx">     virtual void addCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const WebCore::Cookie&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-06-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        &lt;rdar://problem/26755067&gt;
+
+        Reviewed by Andreas Kling.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):
+
+            Implement SessionID version of the function.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
</ins><span class="cx"> 2016-06-14  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Avoid constructing a AuthenticationChallenge unnecessarily in the NetworkLoad constructor
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -137,8 +137,13 @@
</span><span class="cx"> 
</span><span class="cx"> String WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession&amp; session, const URL&amp; firstParty, const URL&amp; url)
</span><span class="cx"> {
</span><ins>+    return cookieRequestHeaderFieldValue(SessionTracker::sessionID(session), firstParty, url);
+}
+
+String WebPlatformStrategies::cookieRequestHeaderFieldValue(SessionID sessionID, const URL&amp; firstParty, const URL&amp; url)
+{
</ins><span class="cx">     String result;
</span><del>-    if (!WebProcess::singleton().networkConnection()-&gt;connection()-&gt;sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(SessionTracker::sessionID(session), firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
</del><ins>+    if (!WebProcess::singleton().networkConnection()-&gt;connection()-&gt;sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(sessionID, firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
</ins><span class="cx">         return String();
</span><span class="cx">     return result;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (202088 => 202089)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 09:55:18 UTC (rev 202088)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-06-15 14:12:16 UTC (rev 202089)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx">     void setCookiesFromDOM(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, const String&amp;) override;
</span><span class="cx">     bool cookiesEnabled(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</span><span class="cx">     String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</span><ins>+    String cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;) override;
</ins><span class="cx">     bool getRawCookies(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp; firstParty, const WebCore::URL&amp;, Vector&lt;WebCore::Cookie&gt;&amp;) override;
</span><span class="cx">     void deleteCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const String&amp;) override;
</span><span class="cx">     void addCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const WebCore::Cookie&amp;) override;
</span></span></pre>
</div>
</div>

</body>
</html>