<!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>[213672] 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/213672">213672</a></dd>
<dt>Author</dt> <dd>yoav@yoav.ws</dd>
<dt>Date</dt> <dd>2017-03-09 14:29:39 -0800 (Thu, 09 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[link preload] Double downloads of preloaded CSS
https://bugs.webkit.org/show_bug.cgi?id=169274

Reviewed by Antti Koivisto.

Source/WebCore:

Avoid reloading link preloads in case of a charset mismatch.

Charset mismatch can happen for header based preloads, as they are requested before
the HTML's `&lt;meta charset&gt;` tag is processed. This change makes sure that in those
cases, we modify the resource's encoding setting instead of reloading it.

Test: http/tests/preload/single_download_preload_headers.php

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource): Initialize m_unknownCharset to be the same as the preload flag.
* loader/cache/CachedResource.h:
(WebCore::CachedResource::hasUnknownEncoding):
(WebCore::CachedResource::setHasUnknownEncoding):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy): In case of a charset
mismatch, set the encoding of the Resource instead of reloading it if the charset is unknown.

LayoutTests:

Added tests making sure that header based preloads also trigger a single download,
and that we properly handle multiple charsets for the same preloaded resource.

* http/tests/preload/single_download_preload_headers-expected.txt: Added.
* http/tests/preload/single_download_preload_headers.php: Added.
* http/tests/preload/preload-encoding-expected.txt: Added.
* http/tests/preload/preload-encoding.php: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceh">trunk/Source/WebCore/loader/cache/CachedResource.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestspreloadpreloadencodingexpectedtxt">trunk/LayoutTests/http/tests/preload/preload-encoding-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestspreloadpreloadencodingphp">trunk/LayoutTests/http/tests/preload/preload-encoding.php</a></li>
<li><a href="#trunkLayoutTestshttptestspreloadresourcessuccessjs">trunk/LayoutTests/http/tests/preload/resources/success.js</a></li>
<li><a href="#trunkLayoutTestshttptestspreloadsingle_download_preload_headersexpectedtxt">trunk/LayoutTests/http/tests/preload/single_download_preload_headers-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestspreloadsingle_download_preload_headersphp">trunk/LayoutTests/http/tests/preload/single_download_preload_headers.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213671 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-09 22:24:26 UTC (rev 213671)
+++ trunk/LayoutTests/ChangeLog        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-03-09  Yoav Weiss  &lt;yoav@yoav.ws&gt;
+
+        [link preload] Double downloads of preloaded CSS
+        https://bugs.webkit.org/show_bug.cgi?id=169274
+
+        Reviewed by Antti Koivisto.
+
+        Added tests making sure that header based preloads also trigger a single download,
+        and that we properly handle multiple charsets for the same preloaded resource.
+
+        * http/tests/preload/single_download_preload_headers-expected.txt: Added.
+        * http/tests/preload/single_download_preload_headers.php: Added.
+        * http/tests/preload/preload-encoding-expected.txt: Added.
+        * http/tests/preload/preload-encoding.php: Added.
+
</ins><span class="cx"> 2017-03-09  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement PBKDF2 in WebCrypto
</span></span></pre></div>
<a id="trunkLayoutTestshttptestspreloadpreloadencodingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/preload/preload-encoding-expected.txt (0 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/preload/preload-encoding-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/preload/preload-encoding-expected.txt        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+CONSOLE MESSAGE: line 1: SyntaxError: Invalid character '\u8307'
+First load a script with a wrong charset then again with the right one. Second attempt should work and 'scriptSuccess' should be set to true. 'successfullyParsed' will be undefined.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS scriptSuccess is true
+FAIL successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestspreloadpreloadencodingphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/preload/preload-encoding.php (0 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/preload/preload-encoding.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/preload/preload-encoding.php        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;?php
+header(&quot;Link: &lt;resources/success.js&gt;; rel=preload; as=script&quot;, false);
+?&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+jsTestIsAsync = true;
+
+description(&quot;First load a script with a wrong charset then again with the right one. Second attempt should work and 'scriptSuccess' should be set to true. 'successfullyParsed' will be undefined.&quot;);
+
+function appendScriptWithCharset(charset, onload)
+{
+    var script = document.createElement(&quot;script&quot;);
+    script.src = &quot;resources/success.js&quot;;
+    script.setAttribute(&quot;charset&quot;, charset);
+    script.onload = onload;
+    script.onerror = onload;
+    document.body.appendChild(script);
+}
+
+function test()
+{
+    appendScriptWithCharset(&quot;utf-16&quot;, function () {
+        appendScriptWithCharset(&quot;utf-8&quot;, function () {
+            shouldBeTrue(&quot;scriptSuccess&quot;);
+            finishJSTest();
+        });
+    });
+}
+&lt;/script&gt;
+&lt;body onload=&quot;test()&quot;&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestspreloadresourcessuccessjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/preload/resources/success.js (0 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/preload/resources/success.js                                (rev 0)
+++ trunk/LayoutTests/http/tests/preload/resources/success.js        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+scriptSuccess = true;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestspreloadsingle_download_preload_headersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/preload/single_download_preload_headers-expected.txt (0 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/preload/single_download_preload_headers-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/preload/single_download_preload_headers-expected.txt        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+CONSOLE MESSAGE: &lt;link rel=preload&gt; must have a valid `as` value

+
+PASS Makes sure that preloaded resources are not downloaded again when used 
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestspreloadsingle_download_preload_headersphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/preload/single_download_preload_headers.php (0 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/preload/single_download_preload_headers.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/preload/single_download_preload_headers.php        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;?php
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/dummy.js&gt;; rel=preload; as=script&quot;, false);
+header(&quot;LiNk:&lt;http://127.0.0.1:8000/resources/dummy.css&gt;; rel=preload; as=style&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/square100.png&gt;;rel=preload;as=image&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/square100.png?background&gt;;rel=preload;as=image&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/Ahem.woff&gt;; rel=preload; as=font; crossorigin&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/test.mp4&gt;; rel=preload; as=media&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/test.oga&gt;; rel=preload; as=media&quot;, false);
+header(&quot;link: &lt;http://127.0.0.1:8000/security/resources/captions.vtt&gt;; rel=preload; as=track&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/dummy.xml?foobar&gt;; rel=preload; as=foobar&quot;, false);
+header(&quot;Link: &lt;http://127.0.0.1:8000/resources/dummy.xml&gt;; crossorigin; rel=preload&quot;, false);
+?&gt;
+&lt;!DOCTYPE html&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;script src=&quot;/js-test-resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;/js-test-resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+    var t = async_test('Makes sure that preloaded resources are not downloaded again when used');
+&lt;/script&gt;
+&lt;script src=&quot;http://127.0.0.1:8000/resources/slow-script.pl?delay=200&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+    #background {
+        width: 200px;
+        height: 200px;
+        background-image: url(http://127.0.0.1:8000/resources/square100.png?background);
+    }
+    @font-face {
+      font-family:ahem;
+      src: url(http://127.0.0.1:8000/resources/Ahem.woff);
+    }
+    span { font-family: ahem, Arial; }
+&lt;/style&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;http://127.0.0.1:8000/resources/dummy.css&quot;&gt;
+&lt;script src=&quot;http://127.0.0.1:8000/resources/dummy.js&quot;&gt;&lt;/script&gt;
+&lt;div id=&quot;background&quot;&gt;&lt;/div&gt;
+&lt;img src=&quot;http://127.0.0.1:8000/resources/square100.png&quot;&gt;
+&lt;video src=&quot;http://127.0.0.1:8000/resources/test.mp4&quot;&gt;
+    &lt;track kind=subtitles src=&quot;http://127.0.0.1:8000/security/resources/captions.vtt&quot; srclang=en&gt;
+&lt;/video&gt;
+&lt;audio src=&quot;http://127.0.0.1:8000/resources/test.oga&quot;&gt;&lt;/audio&gt;
+&lt;script&gt;
+    var xhr = new XMLHttpRequest();
+    xhr.open(&quot;GET&quot;, &quot;http://127.0.0.1:8000/resources/dummy.xml&quot;);
+    xhr.send();
+
+    window.addEventListener(&quot;load&quot;, t.step_func(function() {
+        function verifyDownloadNumber(url, number) {
+            assert_equals(performance.getEntriesByName(url).length, number, url);
+        }
+        setTimeout(t.step_func(function() {
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/dummy.js&quot;, 1);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/dummy.css&quot;, 1);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/square100.png&quot;, 1);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/square100.png?background&quot;, 1);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/Ahem.woff&quot;, 1);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/dummy.xml?foobar&quot;, 0);
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/security/resources/captions.vtt&quot;, 1);
+            // FIXME: XHR should trigger a single download, but it downloads 2 resources instead.
+            verifyDownloadNumber(&quot;http://127.0.0.1:8000/resources/dummy.xml&quot;, 2);
+            // FIXME: We should verify for video and audio as well, but they seem to (flakily?) trigger multiple partial requests.
+            t.done();
+            }), 100);
+    }));
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213671 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-09 22:24:26 UTC (rev 213671)
+++ trunk/Source/WebCore/ChangeLog        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2017-03-09  Yoav Weiss  &lt;yoav@yoav.ws&gt;
+
+        [link preload] Double downloads of preloaded CSS
+        https://bugs.webkit.org/show_bug.cgi?id=169274
+
+        Reviewed by Antti Koivisto.
+
+        Avoid reloading link preloads in case of a charset mismatch.
+
+        Charset mismatch can happen for header based preloads, as they are requested before
+        the HTML's `&lt;meta charset&gt;` tag is processed. This change makes sure that in those
+        cases, we modify the resource's encoding setting instead of reloading it.
+
+        Test: http/tests/preload/single_download_preload_headers.php
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::CachedResource): Initialize m_unknownCharset to be the same as the preload flag.
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::hasUnknownEncoding):
+        (WebCore::CachedResource::setHasUnknownEncoding):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy): In case of a charset
+        mismatch, set the encoding of the Resource instead of reloading it if the charset is unknown.
+
</ins><span class="cx"> 2017-03-09  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement PBKDF2 in WebCrypto
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (213671 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2017-03-09 22:24:26 UTC (rev 213671)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -123,6 +123,7 @@
</span><span class="cx">     , m_origin(request.releaseOrigin())
</span><span class="cx">     , m_initiatorName(request.initiatorName())
</span><span class="cx">     , m_isLinkPreload(request.isLinkPreload())
</span><ins>+    , m_hasUnknownEncoding(request.isLinkPreload())
</ins><span class="cx">     , m_type(type)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(sessionID.isValid());
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (213671 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.h        2017-03-09 22:24:26 UTC (rev 213671)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -232,6 +232,8 @@
</span><span class="cx">     void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; }
</span><span class="cx">     bool isLinkPreload() { return m_isLinkPreload; }
</span><span class="cx">     void setLinkPreload() { m_isLinkPreload = true; }
</span><ins>+    bool hasUnknownEncoding() { return m_hasUnknownEncoding; }
+    void setHasUnknownEncoding(bool hasUnknownEncoding) { m_hasUnknownEncoding = hasUnknownEncoding; }
</ins><span class="cx"> 
</span><span class="cx">     void registerHandle(CachedResourceHandleBase*);
</span><span class="cx">     WEBCORE_EXPORT void unregisterHandle(CachedResourceHandleBase*);
</span><span class="lines">@@ -334,6 +336,7 @@
</span><span class="cx">     bool m_inCache { false };
</span><span class="cx">     bool m_loading { false };
</span><span class="cx">     bool m_isLinkPreload { false };
</span><ins>+    bool m_hasUnknownEncoding { false };
</ins><span class="cx"> 
</span><span class="cx">     bool m_switchingClientsToRevalidatedResource { false };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (213671 => 213672)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2017-03-09 22:24:26 UTC (rev 213671)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2017-03-09 22:29:39 UTC (rev 213672)
</span><span class="lines">@@ -922,8 +922,12 @@
</span><span class="cx">         return Reload;
</span><span class="cx"> 
</span><span class="cx">     auto* textDecoder = existingResource-&gt;textResourceDecoder();
</span><del>-    if (textDecoder &amp;&amp; !textDecoder-&gt;hasEqualEncodingForCharset(cachedResourceRequest.charset()))
-        return Reload;
</del><ins>+    if (textDecoder &amp;&amp; !textDecoder-&gt;hasEqualEncodingForCharset(cachedResourceRequest.charset())) {
+        if (!existingResource-&gt;hasUnknownEncoding())
+            return Reload;
+        existingResource-&gt;setHasUnknownEncoding(false);
+        existingResource-&gt;setEncoding(cachedResourceRequest.charset());
+    }
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: We should use the same cache policy for all resource types. The raw resource policy is overly strict
</span><span class="cx">     //        while the normal subresource policy is too loose.
</span></span></pre>
</div>
</div>

</body>
</html>