<!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>[204163] 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/204163">204163</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-05 00:25:15 -0700 (Fri, 05 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>DocumentThreadableLoader should report an error when getting a null CachedResource
https://bugs.webkit.org/show_bug.cgi?id=160444

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2016-08-05
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/XMLHttpRequest/event-error-expected.txt:
* web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt:
* web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt:
* web-platform-tests/fetch/api/cors/cors-cookies-expected.txt:
* web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt:

Source/WebCore:

Covered by existing and rebased tests.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest): Calling didFail with an AccessControl error if unable to have a CachedResource.
The resource error type AccessControl is important as it indicates to some clients that they should not retry loading the same resource (EventSource notably).
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest): Removed handling of ThreadableLoader::create returning null.
This should be handled in didFail callback. This allows aligning behavior of
WorkerThreadableLoaderi::MainThreadBridge and XMLHttpRequest as ThreadableLoader clients.
(WebCore::XMLHttpRequest::didFail): Handle the case of didFail being called synchronously from ThreadableLoader::create.
In that case, use a timer to dispatch network events asynchronously.

LayoutTests:

* fast/frames/frame-unload-crash.html:
* http/tests/contentextensions/async-xhr-onerror-expected.txt:
* http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt:
* http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt:
* http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt:
* http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastframesframeunloadcrashexpectedtxt">trunk/LayoutTests/fast/frames/frame-unload-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsasyncxhronerrorexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestseventsourceeventsourcereconnectduringnavigatecrashexpectedtxt">trunk/LayoutTests/http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsnavigationsubframepagehidehandlerstartsloadexpectedtxt">trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsnavigationsubframepagehidehandlerstartsload2expectedtxt">trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframeexpectedtxt">trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequesteventerrorexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/event-error-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestgetresponseheadererrorstateexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequesttimeoutcorsasyncexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapicorscorscookiesexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapicorscorscookiesworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoadercpp">trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestcpp">trunk/Source/WebCore/xml/XMLHttpRequest.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-08-05  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        DocumentThreadableLoader should report an error when getting a null CachedResource
+        https://bugs.webkit.org/show_bug.cgi?id=160444
+
+        Reviewed by Alex Christensen.
+
+        * fast/frames/frame-unload-crash.html:
+        * http/tests/contentextensions/async-xhr-onerror-expected.txt:
+        * http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt:
+        * http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt:
+        * http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt:
+        * http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:
+
</ins><span class="cx"> 2016-08-04  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move insertAdjacent*() API from HTMLElement to Element
</span></span></pre></div>
<a id="trunkLayoutTestsfastframesframeunloadcrashexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/frames/frame-unload-crash-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/frames/frame-unload-crash-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/fast/frames/frame-unload-crash-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> frame &quot;&lt;!--framePath //&lt;!--frame0--&gt;/&lt;!--frame0--&gt;--&gt;&quot; - has 1 onunload handler(s)
</span><ins>+CONSOLE MESSAGE: line 13: XMLHttpRequest cannot load frame-unload-crash-2.html due to access control checks.
</ins><span class="cx"> This is a test for bug 25136: CRASH in DocumentLoader::removeSubresourceLoader due to null m_frame. If successful, PASS should be printed below.
</span><span class="cx"> 
</span><span class="cx"> PASS
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsasyncxhronerrorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,5 +1,7 @@
</span><span class="cx"> CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
</span><ins>+CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
</ins><span class="cx"> CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
</span><ins>+CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
</ins><span class="cx"> Asynchronous onreadystatechange status: 0, readyState:1, responseText: 
</span><span class="cx"> Finished runTest. Waiting for callbacks
</span><span class="cx"> Asynchronous onreadystatechange status: 0, readyState:1, responseText: 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestseventsourceeventsourcereconnectduringnavigatecrashexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1 +1,2 @@
</span><ins>+CONSOLE MESSAGE: EventSource cannot load http://127.0.0.1:8000/eventsource/resources/reconnect.php. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsnavigationsubframepagehidehandlerstartsloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 8: XMLHttpRequest cannot load http://127.0.0.1:8000/navigation/resources/resources/slow-resource.pl?delay=3000 due to access control checks.
</ins><span class="cx"> Tests that we don't crash when a load is started in a subframe on 'pagehide' handling
</span><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></pre></div>
<a id="trunkLayoutTestshttptestsnavigationsubframepagehidehandlerstartsload2expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 9: XMLHttpRequest cannot load http://127.0.0.1:8000/navigation/resources/resources/slow-resource.pl?delay=3000 due to access control checks.
</ins><span class="cx"> Tests that we don't crash when a load is started in a subframe on 'pagehide' handling
</span><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></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><span class="cx"> CONSOLE MESSAGE: line 28: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html was not allowed to display insecure content from http://127.0.0.1:8000/.
</span><span class="cx"> 
</span><ins>+CONSOLE MESSAGE: line 28: XMLHttpRequest cannot load http://127.0.0.1:8000/ due to access control checks.
</ins><span class="cx"> This test opens a HTTPS window that loads insecure data via XHR. We should trigger a mixed content callback because the main frame in the window is HTTPS but now has insecure data.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-08-05  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        DocumentThreadableLoader should report an error when getting a null CachedResource
+        https://bugs.webkit.org/show_bug.cgi?id=160444
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/XMLHttpRequest/event-error-expected.txt:
+        * web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt:
+        * web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt:
+        * web-platform-tests/fetch/api/cors/cors-cookies-expected.txt:
+        * web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt:
+
</ins><span class="cx"> 2016-08-04  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for DOMTokenList.replace()
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequesteventerrorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/event-error-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/event-error-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/event-error-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> Blocked access to external URL http://example.nonexist/
</span><ins>+CONSOLE MESSAGE: line 22: XMLHttpRequest cannot load http://example.nonexist/ due to access control checks.
</ins><span class="cx"> 
</span><span class="cx"> PASS XMLHttpRequest Test: event - error 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestgetresponseheadererrorstateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> Blocked access to external URL http://www1.localhost:8800/XMLHttpRequest/resources/nocors/folder.txt
</span><ins>+CONSOLE MESSAGE: line 32: XMLHttpRequest cannot load http://www1.localhost:8800/XMLHttpRequest/resources/nocors/folder.txt due to access control checks.
</ins><span class="cx"> 
</span><span class="cx"> PASS XMLHttpRequest: getResponseHeader() in error state (failing cross-origin test) 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequesttimeoutcorsasyncexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> Blocked access to external URL http://www2.localhost:8800/XMLHttpRequest/resources/corsenabled.py?delay=2&amp;code=200
</span><ins>+CONSOLE MESSAGE: line 40: XMLHttpRequest cannot load http://www2.localhost:8800/XMLHttpRequest/resources/corsenabled.py?delay=2&amp;code=200 due to access control checks.
</ins><span class="cx"> 
</span><span class="cx"> FAIL XMLHttpRequest: timeout event and cross-origin request assert_true: timeout event should fire expected true got false
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapicorscorscookiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,11 +1,9 @@
</span><span class="cx"> Blocked access to external URL http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&amp;headers=cookie
</span><span class="cx"> 
</span><del>-Harness Error (TIMEOUT), message = null
-
</del><span class="cx"> PASS Omit mode: no cookie sent 
</span><span class="cx"> FAIL Include mode: 1 cookie assert_equals: Request includes cookie(s) expected (string) &quot;a=1&quot; but got (object) null
</span><span class="cx"> PASS Include mode: local cookies are not sent with remote request 
</span><span class="cx"> PASS Include mode: remote cookies are not sent with local request 
</span><span class="cx"> PASS Same-origin mode: cookies are discarded in cors request 
</span><del>-TIMEOUT Include mode: remote cookies are not sent with other remote request Test timed out
</del><ins>+FAIL Include mode: remote cookies are not sent with other remote request promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapicorscorscookiesworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,11 +1,9 @@
</span><span class="cx"> Blocked access to external URL http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&amp;headers=cookie
</span><span class="cx"> 
</span><del>-Harness Error (TIMEOUT), message = null
-
</del><span class="cx"> PASS Omit mode: no cookie sent 
</span><span class="cx"> FAIL Include mode: 1 cookie assert_equals: Request includes cookie(s) expected (string) &quot;a=1&quot; but got (object) null
</span><span class="cx"> PASS Include mode: local cookies are not sent with remote request 
</span><span class="cx"> PASS Include mode: remote cookies are not sent with local request 
</span><span class="cx"> PASS Same-origin mode: cookies are discarded in cors request 
</span><del>-TIMEOUT Include mode: remote cookies are not sent with other remote request Test timed out
</del><ins>+FAIL Include mode: remote cookies are not sent with other remote request promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/Source/WebCore/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-08-05  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        DocumentThreadableLoader should report an error when getting a null CachedResource
+        https://bugs.webkit.org/show_bug.cgi?id=160444
+
+        Reviewed by Alex Christensen.
+
+        Covered by existing and rebased tests.
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::loadRequest): Calling didFail with an AccessControl error if unable to have a CachedResource.
+        The resource error type AccessControl is important as it indicates to some clients that they should not retry loading the same resource (EventSource notably).
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest): Removed handling of ThreadableLoader::create returning null.
+        This should be handled in didFail callback. This allows aligning behavior of
+        WorkerThreadableLoaderi::MainThreadBridge and XMLHttpRequest as ThreadableLoader clients.
+        (WebCore::XMLHttpRequest::didFail): Handle the case of didFail being called synchronously from ThreadableLoader::create.
+        In that case, use a timer to dispatch network events asynchronously.
+
</ins><span class="cx"> 2016-08-04  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for DOMTokenList.replace()
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -368,7 +368,10 @@
</span><span class="cx">         m_resource = m_document.cachedResourceLoader().requestRawResource(newRequest);
</span><span class="cx">         if (m_resource)
</span><span class="cx">             m_resource-&gt;addClient(this);
</span><del>-
</del><ins>+        else {
+            // FIXME: Since we receive a synchronous error, this is probably due to some AccessControl checks. We should try to retrieve the actual error.
+            m_client-&gt;didFail(ResourceError(String(), 0, newRequest.resourceRequest().url(), String(), ResourceError::Type::AccessControl));
+        }
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (204162 => 204163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-08-05 06:46:55 UTC (rev 204162)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-08-05 07:25:15 UTC (rev 204163)
</span><span class="lines">@@ -715,15 +715,14 @@
</span><span class="cx">         // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload, &lt;http://bugs.webkit.org/show_bug.cgi?id=10904&gt;.
</span><span class="cx">         m_loader = ThreadableLoader::create(*scriptExecutionContext(), *this, WTFMove(request), options);
</span><span class="cx"> 
</span><ins>+        // Either loader is null or some error was synchronously sent to us.
+        ASSERT(m_loader || !m_sendFlag);
+
</ins><span class="cx">         // Neither this object nor the JavaScript wrapper should be deleted while
</span><span class="cx">         // a request is in progress because we need to keep the listeners alive,
</span><span class="cx">         // and they are referenced by the JavaScript wrapper.
</span><del>-        setPendingActivity(this);
-        if (!m_loader) {
-            m_sendFlag = false;
-            m_timeoutTimer.stop();
-            m_networkErrorTimer.startOneShot(0);
-        }
</del><ins>+        if (m_loader)
+            setPendingActivity(this);
</ins><span class="cx">     } else {
</span><span class="cx">         InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContext());
</span><span class="cx">         ThreadableLoader::loadResourceSynchronously(*scriptExecutionContext(), WTFMove(request), *this, options);
</span><span class="lines">@@ -956,7 +955,6 @@
</span><span class="cx"> 
</span><span class="cx"> void XMLHttpRequest::didFail(const ResourceError&amp; error)
</span><span class="cx"> {
</span><del>-
</del><span class="cx">     // If we are already in an error state, for instance we called abort(), bail out early.
</span><span class="cx">     if (m_error)
</span><span class="cx">         return;
</span><span class="lines">@@ -982,6 +980,14 @@
</span><span class="cx">         logConsoleError(scriptExecutionContext(), message);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // In case didFail is called synchronously on an asynchronous XHR call, let's dispatch network error asynchronously
+    if (m_async &amp;&amp; m_sendFlag &amp;&amp; !m_loader) {
+        m_sendFlag = false;
+        setPendingActivity(this);
+        m_timeoutTimer.stop();
+        m_networkErrorTimer.startOneShot(0);
+        return;
+    }
</ins><span class="cx">     m_exceptionCode = NETWORK_ERR;
</span><span class="cx">     networkError();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>