<!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>[199521] 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/199521">199521</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-04-13 17:14:05 -0700 (Wed, 13 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>We should not speculatively revalidate cached redirects
https://bugs.webkit.org/show_bug.cgi?id=156548
&lt;rdar://problem/25583886&gt;

Reviewed by Darin Adler.

Source/WebKit2:

Stop speculatively revalidating cached redirects. This matches matches
the behavior in NetworkCache's makeUseDecision() which reuses cached
redirects only if they do not need revalidation.

This was breaking fonts.css loading on stripe.com because the
SpeculativeLoadManager would wrongly speculatively revalidate the
redirect and then serve a 302 response the NetworkResourceLoader
when the actual request came in. This would cause us to not follow
the redirect.

* NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
(WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest):
Abort the speculative load if it hits a redirect. This is the safe thing
to do in this case, as we are supposed to do a hand-shake with WebCore
in such case.

(WebKit::NetworkCache::SpeculativeLoad::didReceiveResponse):
Let successful validations fall through instead of calling didComplete()
early. This matches what is not in NetworkResourceLoader. This way,
didFinishLoading() ends up getting called for both successful and
unsuccessful (i.e. did not return a 302 status code) network validation.

(WebKit::NetworkCache::SpeculativeLoad::didFinishLoading):
- Stop dealing with redirects as we abort the load as soon as we hit a
  redirect now.
- Stop asserting that m_cacheEntryForValidation is null now that this
  is called for successful validations as well.

(WebKit::NetworkCache::SpeculativeLoad::abort):
New method that aborts the network loads, calls the completion handler
and clean up. It is called in the case we hit a redirect while
revalidating.

* NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
Drop m_redirectChainCacheStatus member as we no longer deal with
redirects.

* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::SpeculativeLoadManager::retrieveEntryFromStorage):
If the resource needs revalidation AND is a cached redirect, then do not
use it. This matches what is done in NetworkCache's makeUseDecision().

Tools:

Re-enable speculative loading in the context of layout tests. This was
turned off by mistake when speculative loading was turned into a
setting recently.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::generatePageConfiguration):

LayoutTests:

Add layout test to make sure that speculative loading does not break
redirects. This replicates the issue seen with fonts.css on stripe.com.

* http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt: Added.
* http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html: Added.
* http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php: Added.
* http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php: Added.
* http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadcpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagercpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscachediskcachespeculativevalidationcacheableredirectexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachespeculativevalidationcacheableredirecthtml">trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcescacheableredirectframephp">trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcescsstorevalidatephp">trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcesredirecttocssphp">trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/LayoutTests/ChangeLog        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-04-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        We should not speculatively revalidate cached redirects
+        https://bugs.webkit.org/show_bug.cgi?id=156548
+        &lt;rdar://problem/25583886&gt;
+
+        Reviewed by Darin Adler.
+
+        Add layout test to make sure that speculative loading does not break
+        redirects. This replicates the issue seen with fonts.css on stripe.com.
+
+        * http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt: Added.
+        * http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html: Added.
+        * http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php: Added.
+        * http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php: Added.
+        * http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php: Added.
+
</ins><span class="cx"> 2016-04-13  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Text on compositing layer with negative letter-spacing is truncated.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachespeculativevalidationcacheableredirectexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt (0 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect-expected.txt        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests that speculative validation does not break redirects.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS frames[0].getComputedStyle(testDiv).color is &quot;rgb(0, 128, 0)&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachespeculativevalidationcacheableredirecthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html (0 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/cacheable-redirect.html        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;script src=&quot;/js-test-resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description(&quot;Tests that speculative validation does not break redirects.&quot;);
+jsTestIsAsync = true;
+
+state = &quot;warmup&quot;;
+
+function frameLoaded()
+{
+    if (state == &quot;warmup&quot;) {
+        state = &quot;flushingMetadata&quot;;
+        document.getElementById(&quot;testFrame&quot;).src = &quot;about:blank&quot;;
+        return;
+    }
+    if (state == &quot;flushingMetadata&quot;) {
+        // Navigate frame to its original location again. This time it should speculatively
+        // validate subresources as we have subresource loads metadata in the disk cache.
+        state = &quot;speculativeRevalidation&quot;;
+        document.getElementById(&quot;testFrame&quot;).src = &quot;resources/cacheable-redirect-frame.php&quot;;
+        return;
+    }
+    if (state == &quot;speculativeRevalidation&quot;) {
+        testDiv = frames[0].document.getElementById(&quot;testDiv&quot;);
+        shouldBeEqualToString(&quot;frames[0].getComputedStyle(testDiv).color&quot;, &quot;rgb(0, 128, 0)&quot;);
+        finishJSTest();
+        return;
+    }
+}
+
+&lt;/script&gt;
+&lt;iframe id=&quot;testFrame&quot; src=&quot;resources/cacheable-redirect-frame.php&quot; onload=&quot;frameLoaded()&quot;&gt;&lt;/iframe&gt;
+&lt;script src=&quot;/js-test-resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcescacheableredirectframephp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php (0 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/cacheable-redirect-frame.php        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;?php
+header('Content-Type: text/html');
+header('Cache-Control: max-age=0');
+header('Etag: 123456789');
+
+?&gt;
+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;redirect-to-css.php&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;testDiv&quot; class=&quot;testClass&quot;&gt;
+TEST
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcescsstorevalidatephp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php (0 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/css-to-revalidate.php        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;?php
+if ($_SERVER[&quot;HTTP_IF_NONE_MATCH&quot;] == &quot;foo&quot;) {
+    header(&quot;HTTP/1.1 304 Not Modified&quot;);
+    header(&quot;ETag: foo&quot;);
+    return;
+}
+
+header(&quot;Content-Type: text/css&quot;);
+header(&quot;ETag: foo&quot;);
+header(&quot;Cache-Control: max-age=0&quot;);
+
+?&gt;
+
+.testClass
+{
+    color: green;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachespeculativevalidationresourcesredirecttocssphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php (0 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/redirect-to-css.php        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+&lt;?php
+header('HTTP/1.1 302 Found');
+header('Location: /cache/disk-cache/speculative-validation/resources/css-to-revalidate.php');
+header('Expires: Thu, 01 Dec 2003 16:00:00 GMT');
+header('ETag: foo');
+?&gt;
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2016-04-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        We should not speculatively revalidate cached redirects
+        https://bugs.webkit.org/show_bug.cgi?id=156548
+        &lt;rdar://problem/25583886&gt;
+
+        Reviewed by Darin Adler.
+
+        Stop speculatively revalidating cached redirects. This matches matches
+        the behavior in NetworkCache's makeUseDecision() which reuses cached
+        redirects only if they do not need revalidation.
+
+        This was breaking fonts.css loading on stripe.com because the
+        SpeculativeLoadManager would wrongly speculatively revalidate the
+        redirect and then serve a 302 response the NetworkResourceLoader
+        when the actual request came in. This would cause us to not follow
+        the redirect.
+
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
+        (WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest):
+        Abort the speculative load if it hits a redirect. This is the safe thing
+        to do in this case, as we are supposed to do a hand-shake with WebCore
+        in such case.
+
+        (WebKit::NetworkCache::SpeculativeLoad::didReceiveResponse):
+        Let successful validations fall through instead of calling didComplete()
+        early. This matches what is not in NetworkResourceLoader. This way,
+        didFinishLoading() ends up getting called for both successful and
+        unsuccessful (i.e. did not return a 302 status code) network validation.
+
+        (WebKit::NetworkCache::SpeculativeLoad::didFinishLoading):
+        - Stop dealing with redirects as we abort the load as soon as we hit a
+          redirect now.
+        - Stop asserting that m_cacheEntryForValidation is null now that this
+          is called for successful validations as well.
+
+        (WebKit::NetworkCache::SpeculativeLoad::abort):
+        New method that aborts the network loads, calls the completion handler
+        and clean up. It is called in the case we hit a redirect while
+        revalidating.
+
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
+        Drop m_redirectChainCacheStatus member as we no longer deal with
+        redirects.
+
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        (WebKit::NetworkCache::SpeculativeLoadManager::retrieveEntryFromStorage):
+        If the resource needs revalidation AND is a cached redirect, then do not
+        use it. This matches what is done in NetworkCache's makeUseDecision().
+
</ins><span class="cx"> 2016-04-13  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: NetworkProcessConnection::didClose needs to have a self ref.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -65,8 +65,9 @@
</span><span class="cx"> 
</span><span class="cx"> void SpeculativeLoad::willSendRedirectedRequest(const ResourceRequest&amp;, const ResourceRequest&amp; redirectRequest, const ResourceResponse&amp; redirectResponse)
</span><span class="cx"> {
</span><del>-    updateRedirectChainStatus(m_redirectChainCacheStatus, redirectResponse);
-    m_networkLoad-&gt;continueWillSendRequest(redirectRequest);
</del><ins>+    LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Speculative revalidation for %s hit a redirect, aborting the load.&quot;, redirectResponse.url().string().utf8().data());
+    // We drop speculative revalidations if they redirect for now as we would need to notify WebCore of such redirects.
+    abort();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> auto SpeculativeLoad::didReceiveResponse(const ResourceResponse&amp; receivedResponse) -&gt; ShouldContinueDidReceiveResponse
</span><span class="lines">@@ -79,14 +80,11 @@
</span><span class="cx">     ASSERT(m_cacheEntryForValidation);
</span><span class="cx"> 
</span><span class="cx">     bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified
</span><del>-    if (validationSucceeded) {
</del><ins>+    if (validationSucceeded)
</ins><span class="cx">         m_cacheEntryForValidation = NetworkCache::singleton().update(m_originalRequest, m_frameID, *m_cacheEntryForValidation, m_response);
</span><del>-        didComplete();
-        return ShouldContinueDidReceiveResponse::No;
-    }
</del><ins>+    else
+        m_cacheEntryForValidation = nullptr;
</ins><span class="cx"> 
</span><del>-    m_cacheEntryForValidation = nullptr;
-
</del><span class="cx">     return ShouldContinueDidReceiveResponse::Yes;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -106,23 +104,8 @@
</span><span class="cx"> 
</span><span class="cx"> void SpeculativeLoad::didFinishLoading(double finishTime)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_cacheEntryForValidation);
-
-    bool allowStale = m_originalRequest.cachePolicy() &gt;= ReturnCacheDataElseLoad;
-    bool hasCacheableRedirect = m_response.isHTTP() &amp;&amp; redirectChainAllowsReuse(m_redirectChainCacheStatus, allowStale ? ReuseExpiredRedirection : DoNotReuseExpiredRedirection);
-    if (hasCacheableRedirect &amp;&amp; m_redirectChainCacheStatus.status == RedirectChainCacheStatus::CachedRedirection) {
-        // Maybe we should cache the actual redirects instead of the end result?
-        auto now = std::chrono::system_clock::now();
-        auto responseEndOfValidity = now + computeFreshnessLifetimeForHTTPFamily(m_response, now) - computeCurrentAge(m_response, now);
-        hasCacheableRedirect = responseEndOfValidity &lt;= m_redirectChainCacheStatus.endOfValidity;
-    }
-
-    if (m_bufferedDataForCache &amp;&amp; hasCacheableRedirect)
</del><ins>+    if (!m_cacheEntryForValidation &amp;&amp; m_bufferedDataForCache)
</ins><span class="cx">         m_cacheEntryForValidation = NetworkCache::singleton().store(m_originalRequest, m_response, WTFMove(m_bufferedDataForCache), [](NetworkCache::MappedBody&amp; mappedBody) { });
</span><del>-    else if (!hasCacheableRedirect) {
-        // Make sure we don't keep a stale entry in the cache.
-        NetworkCache::singleton().remove(m_originalRequest);
-    }
</del><span class="cx"> 
</span><span class="cx">     didComplete();
</span><span class="cx"> }
</span><span class="lines">@@ -134,6 +117,15 @@
</span><span class="cx">     didComplete();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeLoad::abort()
+{
+    if (m_networkLoad)
+        m_networkLoad-&gt;cancel();
+
+    m_cacheEntryForValidation = nullptr;
+    didComplete();
+}
+
</ins><span class="cx"> void SpeculativeLoad::didComplete()
</span><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT(RunLoop::isMain());
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     void didBecomeDownload() override { ASSERT_NOT_REACHED(); }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void abort();
</ins><span class="cx">     void didComplete();
</span><span class="cx"> 
</span><span class="cx">     GlobalFrameID m_frameID;
</span><span class="lines">@@ -77,8 +78,6 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WebCore::SharedBuffer&gt; m_bufferedDataForCache;
</span><span class="cx">     std::unique_ptr&lt;NetworkCache::Entry&gt; m_cacheEntryForValidation;
</span><del>-
-    WebCore::RedirectChainCacheStatus m_redirectChainCacheStatus;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace NetworkCache
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -425,8 +425,14 @@
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (responseNeedsRevalidation(response, entry-&gt;timeStamp()))
</del><ins>+        if (responseNeedsRevalidation(response, entry-&gt;timeStamp())) {
+            // Do not use cached redirects that have expired.
+            if (entry-&gt;redirectRequest()) {
+                completionHandler(nullptr);
+                return true;
+            }
</ins><span class="cx">             entry-&gt;setNeedsValidation(true);
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         completionHandler(WTFMove(entry));
</span><span class="cx">         return true;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Tools/ChangeLog        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-04-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        We should not speculatively revalidate cached redirects
+        https://bugs.webkit.org/show_bug.cgi?id=156548
+        &lt;rdar://problem/25583886&gt;
+
+        Reviewed by Darin Adler.
+
+        Re-enable speculative loading in the context of layout tests. This was
+        turned off by mistake when speculative loading was turned into a
+        setting recently.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::generatePageConfiguration):
+
</ins><span class="cx"> 2016-04-12  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Python test webkitpy.common.system.executive_unittest.ExecutiveTest.serial_test_kill_process is flaky
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (199520 => 199521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2016-04-14 00:13:52 UTC (rev 199520)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2016-04-14 00:14:05 UTC (rev 199521)
</span><span class="lines">@@ -426,6 +426,7 @@
</span><span class="cx">         WKContextSetIconDatabasePath(m_context.get(), toWK(emptyString()).get());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    WKContextSetDiskCacheSpeculativeValidationEnabled(m_context.get(), true);
</ins><span class="cx">     WKContextUseTestingNetworkSession(m_context.get());
</span><span class="cx">     WKContextSetCacheModel(m_context.get(), kWKCacheModelDocumentBrowser);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>