<!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>[206855] 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/206855">206855</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-06 01:30:01 -0700 (Thu, 06 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WK2] 304 revalidation on the network process does not update the validated response
https://bugs.webkit.org/show_bug.cgi?id=162973

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2016-10-06
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/basic/conditional-get-expected.txt: Added.
* web-platform-tests/fetch/api/basic/conditional-get.html: Added.
* web-platform-tests/fetch/api/resources/cache.py: Added.

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.cpp: Updating cache entry with the revalidated one.

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt:
Rebasing expectation as memory cache revalidation is no longer needed now that the disk cache is updating the response passed to the memory cache.
The disk cache is doing revalidation on the second load. It receives the updated response with longer validity.
As the extended validity response is now passed to the memory cache, the memory cache revalidation no longer happens.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcacherevalidationnewexpireheaderexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicconditionalgetexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicconditionalgethtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcescachepy">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206854 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/ChangeLog        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-10-06  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt:
+        Rebasing expectation as memory cache revalidation is no longer needed now that the disk cache is updating the response passed to the memory cache.
+        The disk cache is doing revalidation on the second load. It receives the updated response with longer validity.
+        As the extended validity response is now passed to the memory cache, the memory cache revalidation no longer happens.
+
</ins><span class="cx"> 2016-10-06  Nan Wang  &lt;n_wang@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         AX:[Mac] Unable to edit text input, textarea fields in iframe using VO naivgation
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcacherevalidationnewexpireheaderexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt (206854 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt        2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-revalidation-new-expire-header-expected.txt        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -12,12 +12,12 @@
</span><span class="cx"> --------Testing loads through memory cache (XHR behavior)--------
</span><span class="cx"> response headers: {&quot;Expires&quot;:&quot;now(0)&quot;,&quot;ETag&quot;:&quot;match&quot;}
</span><span class="cx"> response's 'Expires' header is overriden by future date in 304 response
</span><del>-response source: Memory cache after validation
</del><ins>+response source: Memory cache
</ins><span class="cx"> 
</span><span class="cx"> --------Testing loads through memory cache (subresource behavior)--------
</span><span class="cx"> response headers: {&quot;Expires&quot;:&quot;now(0)&quot;,&quot;ETag&quot;:&quot;match&quot;}
</span><span class="cx"> response's 'Expires' header is overriden by future date in 304 response
</span><del>-response source: Memory cache after validation
</del><ins>+response source: Memory cache
</ins><span class="cx"> 
</span><span class="cx"> 304 response included an 'Expires' header in the future, so we should not need to revalidate this time.
</span><span class="cx"> --------Testing loads from disk cache--------
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206854 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-10-06  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/fetch/api/basic/conditional-get-expected.txt: Added.
+        * web-platform-tests/fetch/api/basic/conditional-get.html: Added.
+        * web-platform-tests/fetch/api/resources/cache.py: Added.
+
</ins><span class="cx"> 2016-10-05  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Import v1 custom elements tests from W3C
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicconditionalgetexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt (0 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get-expected.txt        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Testing conditional GET with ETags 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicconditionalgethtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html (0 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/conditional-get.html        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Request ETag&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#request&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/common/utils.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+    promise_test(function() {
+      var cacheBuster = token(); // ensures first request is uncached
+      var url = &quot;../resources/cache.py?v=&quot; + cacheBuster;
+      var etag;
+
+      // make the first request
+      return fetch(url).then(function(response) {
+        // ensure we're getting the regular, uncached response
+        assert_equals(response.status, 200);
+        assert_equals(response.headers.get(&quot;X-HTTP-STATUS&quot;), null)
+
+        return response.text(); // consuming the body, just to be safe
+      }).then(function(body) {
+        // make a second request
+        return fetch(url);
+      }).then(function(response) {
+        // while the server responds with 304 if our browser sent the correct
+        // If-None-Match request header, at the JavaScript level this surfaces
+        // as 200
+        assert_equals(response.status, 200);
+        assert_equals(response.headers.get(&quot;X-HTTP-STATUS&quot;), &quot;304&quot;)
+
+        etag = response.headers.get(&quot;ETag&quot;)
+
+        return response.text(); // consuming the body, just to be safe
+      }).then(function(body) {
+        // make a third request, explicitly setting If-None-Match request header
+        var headers = { &quot;If-None-Match&quot;: etag }
+        return fetch(url, { headers: headers })
+      }).then(function(response) {
+        // 304 now surfaces thanks to the explicit If-None-Match request header
+        assert_equals(response.status, 304);
+      });
+    }, &quot;Testing conditional GET with ETags&quot;);
+
+    done();
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcescachepy"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py (0 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/cache.py        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+ETAG = '&quot;123abc&quot;'
+CONTENT_TYPE = &quot;text/plain&quot;
+CONTENT = &quot;lorem ipsum dolor sit amet&quot;
+
+
+def main(request, response):
+    # let caching kick in if possible (conditional GET)
+    etag = request.headers.get(&quot;If-None-Match&quot;, None)
+    if etag == ETAG:
+        response.headers.set(&quot;X-HTTP-STATUS&quot;, 304)
+        response.status = (304, &quot;Not Modified&quot;)
+        return &quot;&quot;
+
+    # cache miss, so respond with the actual content
+    response.status = (200, &quot;OK&quot;)
+    response.headers.set(&quot;ETag&quot;, ETAG)
+    response.headers.set(&quot;Content-Type&quot;, CONTENT_TYPE)
+    return CONTENT
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (206854 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-10-06  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        [WK2] 304 revalidation on the network process does not update the validated response
+        https://bugs.webkit.org/show_bug.cgi?id=162973
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/NetworkResourceLoader.cpp: Updating cache entry with the revalidated one.
+
</ins><span class="cx"> 2016-10-05  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Introduce InputEvent bindings in preparation for the input events spec
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (206854 => 206855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp        2016-10-06 08:03:43 UTC (rev 206854)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp        2016-10-06 08:30:01 UTC (rev 206855)
</span><span class="lines">@@ -325,9 +325,8 @@
</span><span class="cx">     if (m_cacheEntryForValidation) {
</span><span class="cx">         bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified
</span><span class="cx">         if (validationSucceeded) {
</span><del>-            NetworkCache::singleton().update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response);
-            // If the request was conditional then this revalidation was not triggered by the network cache and we pass the
-            // 304 response to WebCore.
</del><ins>+            m_cacheEntryForValidation = NetworkCache::singleton().update(originalRequest(), { m_parameters.webPageID, m_parameters.webFrameID }, *m_cacheEntryForValidation, m_response);
+            // If the request was conditional then this revalidation was not triggered by the network cache and we pass the 304 response to WebCore.
</ins><span class="cx">             if (originalRequest().isConditional())
</span><span class="cx">                 m_cacheEntryForValidation = nullptr;
</span><span class="cx">         } else
</span></span></pre>
</div>
</div>

</body>
</html>