<!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>[204164] 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/204164">204164</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-05 00:39:01 -0700 (Fri, 05 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Fetch API] Activate CSP checks
https://bugs.webkit.org/show_bug.cgi?id=160445
Patch by Youenn Fablet <youenn@apple.com> on 2016-08-05
Reviewed by Daniel Bates.
LayoutTests/imported/w3c:
* web-platform-tests/fetch/api/policies/csp-blocked-expected.txt:
* web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt:
Source/WebCore:
Tests: http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html
http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html
* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start): Adding CSP and URL upgrade checks.
LayoutTests:
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html: Added.
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html:
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html: Added.
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html: Added.
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt:
* platform/mac-wk2/TestExpectations: Marking new worker test as failing at loading https resource from loader.
It gets a "The certificate for this server is invalid" error.
* platform/wk2/TestExpectations: Marking new frame test as timing out for WK2 as fetch is not activated in the pop-up window.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsresourcesinsecurexhrinmainframewindowhtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurexhrinmainframeexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapipoliciescspblockedexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapipoliciescspblockedworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwk2TestExpectations">trunk/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoadercpp">trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsresourcesinsecurefetchinmainframewindowhtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinmainframeexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinmainframehtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinworkerexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinworkerhtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/ChangeLog        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2016-08-05 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><ins>+ [Fetch API] Activate CSP checks
+ https://bugs.webkit.org/show_bug.cgi?id=160445
+
+ Reviewed by Daniel Bates.
+
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html: Added.
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html:
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt: Added.
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html: Added.
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt: Added.
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html: Added.
+ * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt:
+ * platform/mac-wk2/TestExpectations: Marking new worker test as failing at loading https resource from loader.
+ It gets a "The certificate for this server is invalid" error.
+ * platform/wk2/TestExpectations: Marking new frame test as timing out for WK2 as fetch is not activated in the pop-up window.
+
+2016-08-05 Youenn Fablet <youenn@apple.com>
+
</ins><span class="cx"> DocumentThreadableLoader should report an error when getting a null CachedResource
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=160444
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsresourcesinsecurefetchinmainframewindowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html (0 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
+<body>
+<script>
+window.onload = () => {
+
+ var testIsFinished = false;
+ fetch("http://127.0.0.1:8443/", { mode: "no-cors" }).then(() => {
+ testIsFinished = true;
+ alert("PASS: load was not blocked");
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, () => {
+ testIsFinished = true;
+ alert("FAIL: load is not successful");
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+
+ // When running in normal environment, let's notify user if something went wrong
+ if (!window.testRunner) {
+ setTimeout(() => {
+ if (testIsFinished)
+ return;
+ alert("Test timed out");
+ }, 2000);
+ }
+};
+</script>
+
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsresourcesinsecurexhrinmainframewindowhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-xhr-in-main-frame-window.html        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -7,16 +7,15 @@
</span><span class="cx"> var xhr = new XMLHttpRequest();
</span><span class="cx"> xhr.onload = function() {
</span><span class="cx"> alert("PASS: load was not blocked");
</span><del>- if (window.testRunner)
- testRunner.notifyDone();
</del><span class="cx"> };
</span><span class="cx">
</span><del>- // When XHR is blocked due to mixed content blocking, it just appears as if the load stalls,
- // see https://bugs.webkit.org/show_bug.cgi?id=145717.
- setTimeout(function() {
</del><ins>+ var testIsFinished = false;
+ xhr.onloadend = function() {
+ testIsFinished = true;
+ alert("PASS: onloadend called");
</ins><span class="cx"> if (window.testRunner)
</span><span class="cx"> testRunner.notifyDone();
</span><del>- }, 2000);
</del><ins>+ }
</ins><span class="cx">
</span><span class="cx"> try {
</span><span class="cx"> xhr.open("GET", "http://127.0.0.1:8443/");
</span><span class="lines">@@ -26,6 +25,15 @@
</span><span class="cx"> testRunner.notifyDone();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // When running in normal environment, let's notify user if something went wrong
+ if (!window.testRunner) {
+ setTimeout(() => {
+ if (testIsFinished)
+ return;
+ alert("Test timed out");
+ }, 2000);
+ }
+
</ins><span class="cx"> xhr.send(null);
</span><span class="cx"> };
</span><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinmainframeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt (0 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame-expected.txt        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+ALERT: PASS: load was not blocked
+This test opens a HTTPS window that loads insecure data via the Fetch API. We should upgrade this request and thereby avoid a mixed content resource load.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinmainframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html (0 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+</script>
+<p>This test opens a HTTPS window that loads insecure data via the Fetch API.
+We should upgrade this request and thereby avoid a mixed content resource load.</p>
+<script>
+window.open("https://127.0.0.1:8443/security/contentSecurityPolicy/upgrade-insecure-requests/resources/insecure-fetch-in-main-frame-window.html");
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt (0 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker-expected.txt        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+ALERT: PASS: load was not blocked
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurefetchinworkerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html (0 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+var blob = new Blob([
+ "fetch('http://127.0.0.1:8443/', { mode: 'no-cors' }).then(() => {"
++ " postMessage('PASS: load was not blocked');"
++ "}, (e) => {"
++ " postMessage('FAIL: load is not successful: ' + e);"
++ "});"
+], { type: "text/javascript" });
+
+var testIsFinished = false;
+var worker = new Worker(window.URL.createObjectURL(blob));
+worker.onmessage = function(e) {
+ testIsFinished = true;
+ alert(e.data);
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+// When running in normal environment, let's notify user if something went wrong
+if (!window.testRunner) {
+ setTimeout(() => {
+ if (testIsFinished)
+ return;
+ alert("Test timed out");
+ }, 2000);
+}
+</script>
+
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyupgradeinsecurerequestsupgradeinsecurexhrinmainframeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-xhr-in-main-frame-expected.txt        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,2 +1,3 @@
</span><span class="cx"> ALERT: PASS: load was not blocked
</span><ins>+ALERT: PASS: onloadend called
</ins><span class="cx"> This test opens a HTTPS window that loads insecure data via XHR. We should upgrade this request and thereby avoid a mixed content callback.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2016-08-05 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><ins>+ [Fetch API] Activate CSP checks
+ https://bugs.webkit.org/show_bug.cgi?id=160445
+
+ Reviewed by Daniel Bates.
+
+ * web-platform-tests/fetch/api/policies/csp-blocked-expected.txt:
+ * web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt:
+
+2016-08-05 Youenn Fablet <youenn@apple.com>
+
</ins><span class="cx"> DocumentThreadableLoader should report an error when getting a null CachedResource
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=160444
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapipoliciescspblockedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-expected.txt (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-expected.txt        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: Refused to connect to http://localhost:8800/fetch/api/resources/top.txt because it does not appear in the connect-src directive of the Content Security Policy.
</ins><span class="cx">
</span><del>-FAIL Fetch is blocked by CSP, got a TypeError assert_unreached: Should have rejected. Reached unreachable code
</del><ins>+PASS Fetch is blocked by CSP, got a TypeError
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapipoliciescspblockedworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: Refused to connect to http://localhost:8800/fetch/api/resources/top.txt because it does not appear in the connect-src directive of the Content Security Policy.
</ins><span class="cx">
</span><del>-FAIL Fetch is blocked by CSP, got a TypeError assert_unreached: Should have rejected. Reached unreachable code
</del><ins>+PASS Fetch is blocked by CSP, got a TypeError
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -376,6 +376,9 @@
</span><span class="cx"> # This test fails every time on El Capitan
</span><span class="cx"> [ ElCapitan ] fast/mediastream/MediaStream-video-element-video-tracks-disabled.html [ Skip ]
</span><span class="cx">
</span><ins>+# Hitting "The certificate for this server is invalid" loading error (not happening in WK1)
+webkit.org/b/160445 http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html [ Failure Timeout ]
+
</ins><span class="cx"> ### END OF (3) Unclassified failures
</span><span class="cx"> ########################################
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wk2/TestExpectations (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wk2/TestExpectations        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/LayoutTests/platform/wk2/TestExpectations        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -42,6 +42,8 @@
</span><span class="cx"> ########################################
</span><span class="cx"> ### START OF (1) Classified failures with bug reports
</span><span class="cx">
</span><ins>+webkit.org/b/160445 http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html [ Timeout ]
+
</ins><span class="cx"> webkit.org/b/156612 http/tests/security/contentSecurityPolicy/embed-redirect-blocked3.html [ Failure ]
</span><span class="cx"> webkit.org/b/156612 http/tests/security/contentSecurityPolicy/object-redirect-blocked3.html [ Failure ]
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/Source/WebCore/ChangeLog        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2016-08-05 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><ins>+ [Fetch API] Activate CSP checks
+ https://bugs.webkit.org/show_bug.cgi?id=160445
+
+ Reviewed by Daniel Bates.
+
+ Tests: http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-main-frame.html
+ http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-insecure-fetch-in-worker.html
+
+ * Modules/fetch/FetchLoader.cpp:
+ (WebCore::FetchLoader::start): Adding CSP and URL upgrade checks.
+
+2016-08-05 Youenn Fablet <youenn@apple.com>
+
</ins><span class="cx"> DocumentThreadableLoader should report an error when getting a null CachedResource
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=160444
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp (204163 => 204164)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-08-05 07:25:15 UTC (rev 204163)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-08-05 07:39:01 UTC (rev 204164)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx">
</span><span class="cx"> #include "BlobURL.h"
</span><span class="cx"> #include "CachedResourceRequestInitiators.h"
</span><ins>+#include "ContentSecurityPolicy.h"
</ins><span class="cx"> #include "FetchBody.h"
</span><span class="cx"> #include "FetchLoaderClient.h"
</span><span class="cx"> #include "FetchRequest.h"
</span><span class="lines">@@ -73,11 +74,23 @@
</span><span class="cx">
</span><span class="cx"> void FetchLoader::start(ScriptExecutionContext& context, const FetchRequest& request)
</span><span class="cx"> {
</span><del>- ThreadableLoaderOptions options(request.fetchOptions(), ConsiderPreflight, ContentSecurityPolicyEnforcement::DoNotEnforce, String(cachedResourceRequestInitiators().fetch));
</del><ins>+ ThreadableLoaderOptions options(request.fetchOptions(), ConsiderPreflight,
+ context.shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective,
+ String(cachedResourceRequestInitiators().fetch));
</ins><span class="cx"> options.sendLoadCallbacks = SendCallbacks;
</span><span class="cx"> options.dataBufferingPolicy = DoNotBufferData;
</span><span class="cx">
</span><del>- m_loader = ThreadableLoader::create(context, *this, request.internalRequest(), options);
</del><ins>+ ResourceRequest fetchRequest = request.internalRequest();
+
+ ASSERT(context.contentSecurityPolicy());
+ context.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(fetchRequest, ContentSecurityPolicy::InsecureRequestType::Load);
+
+ if (!context.contentSecurityPolicy()->allowConnectToSource(fetchRequest.url(), context.shouldBypassMainWorldContentSecurityPolicy())) {
+ m_client.didFail();
+ return;
+ }
+
+ m_loader = ThreadableLoader::create(context, *this, WTFMove(fetchRequest), options);
</ins><span class="cx"> m_isStarted = m_loader;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>