<!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>[209629] 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/209629">209629</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2016-12-09 14:12:08 -0800 (Fri, 09 Dec 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Some resources fetched via Fetch API do not have data
https://bugs.webkit.org/show_bug.cgi?id=165230
<rdar://problem/29449220>
Reviewed by Alex Christensen.
Source/JavaScriptCore:
* inspector/protocol/Page.json:
Add new Fetch Page.ResourceType.
Source/WebCore:
Tests: http/tests/inspector/network/fetch-response-body.html
http/tests/inspector/network/xhr-response-body.html
* platform/network/ResourceRequestBase.h:
Distinguish Fetch requests.
* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::initializeWith):
Set the requester type as Fetch.
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::didReceiveResponse):
* loader/DocumentThreadableLoader.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didReceiveThreadableLoaderResponseImpl):
(WebCore::InspectorInstrumentation::didReceiveXHRResponseImpl): Deleted.
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didReceiveResourceResponse):
(WebCore::InspectorInstrumentation::didReceiveThreadableLoaderResponse):
(WebCore::InspectorInstrumentation::didReceiveXHRResponse): Deleted.
* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveThreadableLoaderResponse):
(WebCore::InspectorNetworkAgent::didFinishXHRLoading):
(WebCore::InspectorNetworkAgent::didReceiveXHRResponse): Deleted.
Add a generic way for a ThreadableLoader load to update the type of a network request.
This will include both XHR and Fetch requests.
* inspector/InspectorPageAgent.cpp:
(WebCore::hasTextContent):
(WebCore::createXHRTextDecoder):
(WebCore::InspectorPageAgent::resourceTypeJson):
(WebCore::InspectorPageAgent::cachedResourceType):
(WebCore::InspectorPageAgent::createTextDecoder):
(WebCore::textContentForCachedResource):
* inspector/InspectorPageAgent.h:
* inspector/NetworkResourcesData.cpp:
(WebCore::createOtherResourceTextDecoder): Deleted.
Share the logic that creates a Text Decoders for XHR with other non-buffered requests
(like Fetch). This moves us to identical behavior for now.
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType):
(WebCore::MIMETypeRegistry::isTextMIMEType):
* platform/MIMETypeRegistry.h:
Better detect different JSON content based on MIME Type.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js:
New "Fetch" and "Fetches" localized strings.
* UserInterface/Models/Resource.js:
(WebInspector.Resource.displayNameForType):
* UserInterface/Models/ResourceCollection.js:
(WebInspector.ResourceCollection.verifierForType):
* UserInterface/Views/CollectionContentView.js:
(WebInspector.CollectionContentView):
* UserInterface/Views/ResourceClusterContentView.js:
(WebInspector.ResourceClusterContentView.prototype.get responseContentView):
* UserInterface/Views/ResourceTreeElement.js:
(WebInspector.ResourceTreeElement.compareResourceTreeElements):
New ResourceType.Fetch. Behave like XHR in most places.
LayoutTests:
* http/tests/inspector/network/fetch-response-body-expected.txt: Added.
* http/tests/inspector/network/fetch-response-body.html: Added.
* http/tests/inspector/network/resources/data.html: Added.
* http/tests/inspector/network/resources/data.json: Added.
* http/tests/inspector/network/resources/data.svg: Added.
* http/tests/inspector/network/resources/data.txt: Added.
* http/tests/inspector/network/resources/echo.php: Added.
* http/tests/inspector/network/xhr-response-body-expected.txt: Added.
* http/tests/inspector/network/xhr-response-body.html: Added.
Tests for viewing content of XHR and Fetch requested resources
with different kinds of content.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolPagejson">trunk/Source/JavaScriptCore/inspector/protocol/Page.json</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequestcpp">trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorDOMAgentcpp">trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationcpp">trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationh">trunk/Source/WebCore/inspector/InspectorInstrumentation.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorNetworkAgentcpp">trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorNetworkAgenth">trunk/Source/WebCore/inspector/InspectorNetworkAgent.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgentcpp">trunk/Source/WebCore/inspector/InspectorPageAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgenth">trunk/Source/WebCore/inspector/InspectorPageAgent.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheetcpp">trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorNetworkResourcesDatacpp">trunk/Source/WebCore/inspector/NetworkResourcesData.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoadercpp">trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoaderh">trunk/Source/WebCore/loader/DocumentThreadableLoader.h</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistrycpp">trunk/Source/WebCore/platform/MIMETypeRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistryh">trunk/Source/WebCore/platform/MIMETypeRegistry.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceRequestBaseh">trunk/Source/WebCore/platform/network/ResourceRequestBase.h</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestcpp">trunk/Source/WebCore/xml/XMLHttpRequest.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsResourcejs">trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsResourceCollectionjs">trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsCollectionContentViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsResourceClusterContentViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsResourceTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkfetchresponsebodyexpectedtxt">trunk/LayoutTests/http/tests/inspector/network/fetch-response-body-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkfetchresponsebodyhtml">trunk/LayoutTests/http/tests/inspector/network/fetch-response-body.html</a></li>
<li>trunk/LayoutTests/http/tests/inspector/network/resources/</li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesdatahtml">trunk/LayoutTests/http/tests/inspector/network/resources/data.html</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesdatajson">trunk/LayoutTests/http/tests/inspector/network/resources/data.json</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesdatasvg">trunk/LayoutTests/http/tests/inspector/network/resources/data.svg</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesdatatxt">trunk/LayoutTests/http/tests/inspector/network/resources/data.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesechophp">trunk/LayoutTests/http/tests/inspector/network/resources/echo.php</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkxhrresponsebodyexpectedtxt">trunk/LayoutTests/http/tests/inspector/network/xhr-response-body-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkxhrresponsebodyhtml">trunk/LayoutTests/http/tests/inspector/network/xhr-response-body.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/LayoutTests/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-12-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Some resources fetched via Fetch API do not have data
+ https://bugs.webkit.org/show_bug.cgi?id=165230
+ <rdar://problem/29449220>
+
+ Reviewed by Alex Christensen.
+
+ * http/tests/inspector/network/fetch-response-body-expected.txt: Added.
+ * http/tests/inspector/network/fetch-response-body.html: Added.
+ * http/tests/inspector/network/resources/data.html: Added.
+ * http/tests/inspector/network/resources/data.json: Added.
+ * http/tests/inspector/network/resources/data.svg: Added.
+ * http/tests/inspector/network/resources/data.txt: Added.
+ * http/tests/inspector/network/resources/echo.php: Added.
+ * http/tests/inspector/network/xhr-response-body-expected.txt: Added.
+ * http/tests/inspector/network/xhr-response-body.html: Added.
+ Tests for viewing content of XHR and Fetch requested resources
+ with different kinds of content.
+
</ins><span class="cx"> 2016-12-09 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> document.webkitFullscreenElement leaks elements inside a shadow tree
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkfetchresponsebodyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/fetch-response-body-expected.txt (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/fetch-response-body-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/fetch-response-body-expected.txt        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+Tests for getting the content of Fetch requests.
+
+
+== Running test suite: Network.getResponseBody.Fetch
+-- Running test case: Network.getResponseBody.Fetch.Text
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'text/plain'.
+PASS: Text content should match data.txt.
+
+-- Running test case: Network.getResponseBody.Fetch.HTML
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'text/html'.
+PASS: Text content should match data.html.
+
+-- Running test case: Network.getResponseBody.Fetch.JSON
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'application/octet-stream'.
+PASS: JSON content should match data.json.
+
+-- Running test case: Network.getResponseBody.Fetch.JSON2
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'application/json'.
+PASS: JSON content should match specified content.
+
+-- Running test case: Network.getResponseBody.Fetch.JSON3
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'application/vnd.api+json'.
+PASS: JSON content should match specified content.
+
+-- Running test case: Network.getResponseBody.Fetch.SVG
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'image/svg+xml'.
+PASS: SVG content should be text.
+
+-- Running test case: Network.getResponseBody.Fetch.PNG
+PASS: Resource should be Fetch type.
+PASS: MIMEType should be 'image/png'.
+PASS: Image content should be text.
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkfetchresponsebodyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/fetch-response-body.html (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/fetch-response-body.html         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/fetch-response-body.html        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,139 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../resources/inspector-test.js"></script>
+<script>
+function createFetchForText() {
+ fetch("resources/data.txt");
+}
+
+function createFetchForHTML() {
+ fetch("resources/data.html");
+}
+
+function createFetchForJSON() {
+ fetch("resources/data.json");
+}
+
+function createFetchForJSON2() {
+ fetch(`resources/echo.php?mimetype=application/json&content={"json":true,"value":42}`);
+}
+
+function createFetchForJSON3() {
+ fetch(`resources/echo.php?mimetype=application/vnd.api%2Bjson&content={"json":true,"value":999}`);
+}
+
+function createFetchForSVG() {
+ fetch("resources/data.svg");
+}
+
+function createFetchForPNG() {
+ fetch("/resources/square100.png");
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Network.getResponseBody.Fetch");
+
+ function addTestCase({name, description, expression, contentHandler}) {
+ suite.addTestCase({
+ name, description,
+ test(resolve, reject) {
+ InspectorTest.evaluateInPage(expression);
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
+ let resource = event.data.resource;
+ InspectorTest.expectEqual(resource.type, WebInspector.Resource.Type.Fetch, "Resource should be Fetch type.");
+ return resource.requestContent();
+ })
+ .then(contentHandler)
+ .then(resolve, reject);
+ }
+ });
+ }
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.Text",
+ description: "Get text/plain content as text.",
+ expression: "createFetchForText()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "text/plain", "MIMEType should be 'text/plain'.");
+ InspectorTest.expectEqual(content, "Plain text resource.\n", "Text content should match data.txt.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.HTML",
+ description: "Get text/html content as text.",
+ expression: "createFetchForHTML()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "text/html", "MIMEType should be 'text/html'.");
+ InspectorTest.expectEqual(content, "<span>Hello World</span>\n", "Text content should match data.html.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.JSON",
+ description: "Get application/octet-stream content as text.",
+ expression: "createFetchForJSON()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/octet-stream", "MIMEType should be 'application/octet-stream'.");
+ InspectorTest.expectEqual(content, `{"json": true, "value": 42}\n`, "JSON content should match data.json.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.JSON2",
+ description: "Get application/json content as text.",
+ expression: "createFetchForJSON2()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/json", "MIMEType should be 'application/json'.");
+ InspectorTest.expectEqual(content, `{"json":true,"value":42}`, "JSON content should match specified content.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.JSON3",
+ description: "Get arbitrary +json content as text.",
+ expression: "createFetchForJSON3()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/vnd.api+json", "MIMEType should be 'application/vnd.api+json'.");
+ InspectorTest.expectEqual(content, `{"json":true,"value":999}`, "JSON content should match specified content.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.SVG",
+ description: "Get image/svg+xml content as text.",
+ expression: "createFetchForSVG()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "image/svg+xml", "MIMEType should be 'image/svg+xml'.");
+ InspectorTest.expectEqual(content,
+`<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200">
+ <rect width="100%" height="50%" fill="green"/>
+</svg>
+`, "SVG content should be text.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.Fetch.PNG",
+ description: "Get image/png content.",
+ expression: "createFetchForPNG()",
+ contentHandler({error, sourceCode, content}) {
+ // FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
+ InspectorTest.expectEqual(sourceCode.mimeType, "image/png", "MIMEType should be 'image/png'.");
+ InspectorTest.expectEqual(typeof content, "string", "Image content should be text.");
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for getting the content of Fetch requests.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesdatahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/data.html (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/data.html         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/data.html        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+<span>Hello World</span>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesdatajson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/data.json (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/data.json         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/data.json        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+{"json": true, "value": 42}
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesdatasvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/data.svg (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/data.svg         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/data.svg        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200">
+ <rect width="100%" height="50%" fill="green"/>
+</svg>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesdatatxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/data.txt (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/data.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/data.txt        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+Plain text resource.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesechophp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/echo.php (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/echo.php         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/echo.php        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+<?php
+$mimeType = isset($_GET['mimetype']) ? $_GET['mimetype'] : 'text/plain';
+$content = isset($_GET['content']) ? $_GET['content'] : 'Missing mimetype or content query parameter.';
+
+header("Content-Type: $mimeType");
+echo $content;
+?>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkxhrresponsebodyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/xhr-response-body-expected.txt (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/xhr-response-body-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/xhr-response-body-expected.txt        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+Tests for getting the content of XHR requests.
+
+
+== Running test suite: Network.getResponseBody.XHR
+-- Running test case: Network.getResponseBody.XHR.Text
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'text/plain'.
+PASS: Text content should match data.txt.
+
+-- Running test case: Network.getResponseBody.XHR.HTML
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'text/html'.
+PASS: Text content should match data.html.
+
+-- Running test case: Network.getResponseBody.XHR.JSON
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'application/octet-stream'.
+PASS: JSON content should match data.json.
+
+-- Running test case: Network.getResponseBody.XHR.JSON2
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'application/json'.
+PASS: JSON content should match specified content.
+
+-- Running test case: Network.getResponseBody.XHR.JSON3
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'application/vnd.api+json'.
+PASS: JSON content should match specified content.
+
+-- Running test case: Network.getResponseBody.XHR.SVG
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'image/svg+xml'.
+PASS: SVG content should be text.
+
+-- Running test case: Network.getResponseBody.XHR.PNG
+PASS: Resource should be XHR type.
+PASS: MIMEType should be 'image/png'.
+PASS: Image content should be text.
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkxhrresponsebodyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/xhr-response-body.html (0 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/xhr-response-body.html         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/xhr-response-body.html        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -0,0 +1,145 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../resources/inspector-test.js"></script>
+<script>
+function xhrGet(url) {
+ let xhr = new XMLHttpRequest;
+ xhr.open("GET", url, true);
+ xhr.send();
+}
+
+function createXHRForText() {
+ xhrGet("resources/data.txt");
+}
+
+function createXHRForHTML() {
+ xhrGet("resources/data.html");
+}
+
+function createXHRForJSON() {
+ xhrGet("resources/data.json");
+}
+
+function createXHRForJSON2() {
+ xhrGet(`resources/echo.php?mimetype=application/json&content={"json":true,"value":42}`);
+}
+
+function createXHRForJSON3() {
+ xhrGet(`resources/echo.php?mimetype=application/vnd.api%2Bjson&content={"json":true,"value":999}`);
+}
+
+function createXHRForSVG() {
+ xhrGet("resources/data.svg");
+}
+
+function createXHRForPNG() {
+ xhrGet("/resources/square100.png");
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Network.getResponseBody.XHR");
+
+ function addTestCase({name, description, expression, contentHandler}) {
+ suite.addTestCase({
+ name, description,
+ test(resolve, reject) {
+ InspectorTest.evaluateInPage(expression);
+ WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+ .then((event) => {
+ let resource = event.data.resource;
+ InspectorTest.expectEqual(resource.type, WebInspector.Resource.Type.XHR, "Resource should be XHR type.");
+ return resource.requestContent();
+ })
+ .then(contentHandler)
+ .then(resolve, reject);
+ }
+ });
+ }
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.Text",
+ description: "Get text/plain content as text.",
+ expression: "createXHRForText()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "text/plain", "MIMEType should be 'text/plain'.");
+ InspectorTest.expectEqual(content, "Plain text resource.\n", "Text content should match data.txt.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.HTML",
+ description: "Get text/html content as text.",
+ expression: "createXHRForHTML()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "text/html", "MIMEType should be 'text/html'.");
+ InspectorTest.expectEqual(content, "<span>Hello World</span>\n", "Text content should match data.html.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.JSON",
+ description: "Get application/octet-stream content as text.",
+ expression: "createXHRForJSON()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/octet-stream", "MIMEType should be 'application/octet-stream'.");
+ InspectorTest.expectEqual(content, `{"json": true, "value": 42}\n`, "JSON content should match data.json.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.JSON2",
+ description: "Get application/json content as text.",
+ expression: "createXHRForJSON2()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/json", "MIMEType should be 'application/json'.");
+ InspectorTest.expectEqual(content, `{"json":true,"value":42}`, "JSON content should match specified content.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.JSON3",
+ description: "Get arbitrary +json content as text.",
+ expression: "createXHRForJSON3()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "application/vnd.api+json", "MIMEType should be 'application/vnd.api+json'.");
+ InspectorTest.expectEqual(content, `{"json":true,"value":999}`, "JSON content should match specified content.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.SVG",
+ description: "Get image/svg+xml content as text.",
+ expression: "createXHRForSVG()",
+ contentHandler({error, sourceCode, content}) {
+ InspectorTest.expectEqual(sourceCode.mimeType, "image/svg+xml", "MIMEType should be 'image/svg+xml'.");
+ InspectorTest.expectEqual(content,
+`<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200">
+ <rect width="100%" height="50%" fill="green"/>
+</svg>
+`, "SVG content should be text.");
+ }
+ });
+
+ addTestCase({
+ name: "Network.getResponseBody.XHR.PNG",
+ description: "Get image/png content.",
+ expression: "createXHRForPNG()",
+ contentHandler({error, sourceCode, content}) {
+ // FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
+ InspectorTest.expectEqual(sourceCode.mimeType, "image/png", "MIMEType should be 'image/png'.");
+ InspectorTest.expectEqual(typeof content, "string", "Image content should be text.");
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for getting the content of XHR requests.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-12-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Some resources fetched via Fetch API do not have data
+ https://bugs.webkit.org/show_bug.cgi?id=165230
+ <rdar://problem/29449220>
+
+ Reviewed by Alex Christensen.
+
+ * inspector/protocol/Page.json:
+ Add new Fetch Page.ResourceType.
+
</ins><span class="cx"> 2016-12-09 Geoffrey Garen <ggaren@apple.com>
</span><span class="cx">
</span><span class="cx"> TextPosition and OrdinalNumber should be more like idiomatic numbers
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolPagejson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Page.json (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Page.json        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Page.json        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> {
</span><span class="cx"> "id": "ResourceType",
</span><span class="cx"> "type": "string",
</span><del>- "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "WebSocket", "Other"],
</del><ins>+ "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "Fetch", "WebSocket", "Other"],
</ins><span class="cx"> "description": "Resource type as it was perceived by the rendering engine."
</span><span class="cx"> },
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2016-12-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Some resources fetched via Fetch API do not have data
+ https://bugs.webkit.org/show_bug.cgi?id=165230
+ <rdar://problem/29449220>
+
+ Reviewed by Alex Christensen.
+
+ Tests: http/tests/inspector/network/fetch-response-body.html
+ http/tests/inspector/network/xhr-response-body.html
+
+ * platform/network/ResourceRequestBase.h:
+ Distinguish Fetch requests.
+
+ * Modules/fetch/FetchRequest.cpp:
+ (WebCore::FetchRequest::initializeWith):
+ Set the requester type as Fetch.
+
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::didReceiveResponse):
+ * loader/DocumentThreadableLoader.h:
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::didReceiveThreadableLoaderResponseImpl):
+ (WebCore::InspectorInstrumentation::didReceiveXHRResponseImpl): Deleted.
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::didReceiveResourceResponse):
+ (WebCore::InspectorInstrumentation::didReceiveThreadableLoaderResponse):
+ (WebCore::InspectorInstrumentation::didReceiveXHRResponse): Deleted.
+ * inspector/InspectorNetworkAgent.cpp:
+ (WebCore::InspectorNetworkAgent::didReceiveThreadableLoaderResponse):
+ (WebCore::InspectorNetworkAgent::didFinishXHRLoading):
+ (WebCore::InspectorNetworkAgent::didReceiveXHRResponse): Deleted.
+ Add a generic way for a ThreadableLoader load to update the type of a network request.
+ This will include both XHR and Fetch requests.
+
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::hasTextContent):
+ (WebCore::createXHRTextDecoder):
+ (WebCore::InspectorPageAgent::resourceTypeJson):
+ (WebCore::InspectorPageAgent::cachedResourceType):
+ (WebCore::InspectorPageAgent::createTextDecoder):
+ (WebCore::textContentForCachedResource):
+ * inspector/InspectorPageAgent.h:
+ * inspector/NetworkResourcesData.cpp:
+ (WebCore::createOtherResourceTextDecoder): Deleted.
+ Share the logic that creates a Text Decoders for XHR with other non-buffered requests
+ (like Fetch). This moves us to identical behavior for now.
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::isSupportedJSONMIMEType):
+ (WebCore::MIMETypeRegistry::isTextMIMEType):
+ * platform/MIMETypeRegistry.h:
+ Better detect different JSON content based on MIME Type.
+
</ins><span class="cx"> 2016-12-09 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> document.webkitFullscreenElement leaks elements inside a shadow tree
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -151,6 +151,7 @@
</span><span class="cx"> m_internalRequest.options.credentials = Credentials::Omit;
</span><span class="cx"> m_internalRequest.referrer = ASCIILiteral("client");
</span><span class="cx"> m_internalRequest.request.setURL(requestURL);
</span><ins>+ m_internalRequest.request.setRequester(ResourceRequest::Requester::Fetch);
</ins><span class="cx"> m_internalRequest.request.setInitiatorIdentifier(scriptExecutionContext()->resourceRequestIdentifier());
</span><span class="cx">
</span><span class="cx"> return initializeOptions(init);
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorDOMAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1261,7 +1261,6 @@
</span><span class="cx"> *nodeId = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// static
</del><span class="cx"> String InspectorDOMAgent::documentURLString(Document* document)
</span><span class="cx"> {
</span><span class="cx"> if (!document || document->url().isNull())
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -627,6 +627,12 @@
</span><span class="cx"> didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InspectorInstrumentation::didReceiveThreadableLoaderResponseImpl(InstrumentingAgents& instrumentingAgents, DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
+{
+ if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
+ networkAgent->didReceiveThreadableLoaderResponse(identifier, documentThreadableLoader);
+}
+
</ins><span class="cx"> void InspectorInstrumentation::didReceiveDataImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
</span><span class="cx"> {
</span><span class="cx"> if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
</span><span class="lines">@@ -663,12 +669,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void InspectorInstrumentation::didReceiveXHRResponseImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier)
-{
- if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
- networkAgent->didReceiveXHRResponse(identifier);
-}
-
</del><span class="cx"> void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents& instrumentingAgents)
</span><span class="cx"> {
</span><span class="cx"> if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><span class="cx"> #include "CSSSelector.h"
</span><ins>+#include "DocumentThreadableLoader.h"
</ins><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "FormData.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="lines">@@ -158,11 +159,11 @@
</span><span class="cx"> static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><span class="cx"> static void continueWithPolicyDownload(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><span class="cx"> static void continueWithPolicyIgnore(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><ins>+ static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
</ins><span class="cx"> static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
</span><span class="cx"> static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, double finishTime);
</span><span class="cx"> static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
</span><span class="cx"> static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
</span><del>- static void didReceiveXHRResponse(ScriptExecutionContext*, unsigned long identifier);
</del><span class="cx"> static void willLoadXHRSynchronously(ScriptExecutionContext*);
</span><span class="cx"> static void didLoadXHRSynchronously(ScriptExecutionContext*);
</span><span class="cx"> static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
</span><span class="lines">@@ -329,11 +330,11 @@
</span><span class="cx"> static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><span class="cx"> static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><span class="cx"> static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
</span><ins>+ static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
</ins><span class="cx"> static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
</span><span class="cx"> static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, double finishTime);
</span><span class="cx"> static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
</span><span class="cx"> static void didFinishXHRLoadingImpl(InstrumentingAgents&, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
</span><del>- static void didReceiveXHRResponseImpl(InstrumentingAgents&, unsigned long identifier);
</del><span class="cx"> static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
</span><span class="cx"> static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
</span><span class="cx"> static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
</span><span class="lines">@@ -859,8 +860,7 @@
</span><span class="cx"> inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
</span><span class="cx"> {
</span><span class="cx"> // Call this unconditionally so that we're able to log to console with no front-end attached.
</span><del>- if (cookie.isValid())
- didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
</del><ins>+ didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
</span><span class="lines">@@ -881,6 +881,12 @@
</span><span class="cx"> InspectorInstrumentation::continueWithPolicyIgnoreImpl(frame, loader, identifier, r);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
+{
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(documentThreadableLoader.document()))
+ didReceiveThreadableLoaderResponseImpl(*instrumentingAgents, documentThreadableLoader, identifier);
+}
+
</ins><span class="cx"> inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
</span><span class="cx"> {
</span><span class="cx"> if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
</span><span class="lines">@@ -905,12 +911,6 @@
</span><span class="cx"> didFinishXHRLoadingImpl(*instrumentingAgents, identifier, decodedText, url, sendURL, sendLineNumber, sendColumnNumber);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline void InspectorInstrumentation::didReceiveXHRResponse(ScriptExecutionContext* context, unsigned long identifier)
-{
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
- didReceiveXHRResponseImpl(*instrumentingAgents, identifier);
-}
-
</del><span class="cx"> inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
</span><span class="cx"> {
</span><span class="cx"> if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorNetworkAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "CachedRawResource.h"
</span><span class="cx"> #include "CachedResource.h"
</span><span class="cx"> #include "CachedResourceLoader.h"
</span><ins>+#include "CachedResourceRequestInitiators.h"
</ins><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "DocumentLoader.h"
</span><span class="cx"> #include "DocumentThreadableLoader.h"
</span><span class="lines">@@ -450,14 +451,18 @@
</span><span class="cx"> m_resourcesData->setResourceType(IdentifiersFactory::requestId(identifier), InspectorPageAgent::ScriptResource);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void InspectorNetworkAgent::didFinishXHRLoading(unsigned long identifier, const String& decodedText)
</del><ins>+void InspectorNetworkAgent::didReceiveThreadableLoaderResponse(unsigned long identifier, DocumentThreadableLoader& documentThreadableLoader)
</ins><span class="cx"> {
</span><del>- m_resourcesData->setResourceContent(IdentifiersFactory::requestId(identifier), decodedText);
</del><ins>+ String initiator = documentThreadableLoader.options().initiator;
+ if (initiator == cachedResourceRequestInitiators().fetch)
+ m_resourcesData->setResourceType(IdentifiersFactory::requestId(identifier), InspectorPageAgent::FetchResource);
+ else if (initiator == cachedResourceRequestInitiators().xmlhttprequest)
+ m_resourcesData->setResourceType(IdentifiersFactory::requestId(identifier), InspectorPageAgent::XHRResource);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void InspectorNetworkAgent::didReceiveXHRResponse(unsigned long identifier)
</del><ins>+void InspectorNetworkAgent::didFinishXHRLoading(unsigned long identifier, const String& decodedText)
</ins><span class="cx"> {
</span><del>- m_resourcesData->setResourceType(IdentifiersFactory::requestId(identifier), InspectorPageAgent::XHRResource);
</del><ins>+ m_resourcesData->setResourceContent(IdentifiersFactory::requestId(identifier), decodedText);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void InspectorNetworkAgent::willLoadXHRSynchronously()
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorNetworkAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> class CachedResource;
</span><span class="cx"> class Document;
</span><span class="cx"> class DocumentLoader;
</span><ins>+class DocumentThreadableLoader;
</ins><span class="cx"> class InspectorPageAgent;
</span><span class="cx"> class NetworkLoadTiming;
</span><span class="cx"> class NetworkResourcesData;
</span><span class="lines">@@ -81,8 +82,8 @@
</span><span class="cx"> void didFinishLoading(unsigned long identifier, DocumentLoader&, double finishTime);
</span><span class="cx"> void didFailLoading(unsigned long identifier, DocumentLoader&, const ResourceError&);
</span><span class="cx"> void didLoadResourceFromMemoryCache(DocumentLoader&, CachedResource&);
</span><ins>+ void didReceiveThreadableLoaderResponse(unsigned long identifier, DocumentThreadableLoader&);
</ins><span class="cx"> void didFinishXHRLoading(unsigned long identifier, const String& decodedText);
</span><del>- void didReceiveXHRResponse(unsigned long identifier);
</del><span class="cx"> void willLoadXHRSynchronously();
</span><span class="cx"> void didLoadXHRSynchronously();
</span><span class="cx"> void didReceiveScriptResponse(unsigned long identifier);
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -114,28 +114,17 @@
</span><span class="cx">
</span><span class="cx"> static bool hasTextContent(CachedResource* cachedResource)
</span><span class="cx"> {
</span><ins>+ // FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
+ // We should not assume XHR / Fetch have text content.
+
</ins><span class="cx"> InspectorPageAgent::ResourceType type = InspectorPageAgent::cachedResourceType(*cachedResource);
</span><span class="cx"> return type == InspectorPageAgent::DocumentResource
</span><span class="cx"> || type == InspectorPageAgent::StylesheetResource
</span><span class="cx"> || type == InspectorPageAgent::ScriptResource
</span><del>- || type == InspectorPageAgent::XHRResource;
</del><ins>+ || type == InspectorPageAgent::XHRResource
+ || type == InspectorPageAgent::FetchResource;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<TextResourceDecoder> createXHRTextDecoder(const String& mimeType, const String& textEncodingName)
-{
- RefPtr<TextResourceDecoder> decoder;
- if (!textEncodingName.isEmpty())
- decoder = TextResourceDecoder::create("text/plain", textEncodingName);
- else if (MIMETypeRegistry::isXMLMIMEType(mimeType)) {
- decoder = TextResourceDecoder::create("application/xml");
- decoder->useLenientXMLDecoding();
- } else if (equalLettersIgnoringASCIICase(mimeType, "text/html"))
- decoder = TextResourceDecoder::create("text/html", "UTF-8");
- else
- decoder = TextResourceDecoder::create("text/plain", "UTF-8");
- return decoder;
-}
-
</del><span class="cx"> bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, String* result, bool* base64Encoded)
</span><span class="cx"> {
</span><span class="cx"> // FIXME: result should be a String& and base64Encoded should be a bool&.
</span><span class="lines">@@ -176,7 +165,7 @@
</span><span class="cx"> auto* buffer = cachedResource->resourceBuffer();
</span><span class="cx"> if (!buffer)
</span><span class="cx"> return false;
</span><del>- RefPtr<TextResourceDecoder> decoder = createXHRTextDecoder(cachedResource->response().mimeType(), cachedResource->response().textEncodingName());
</del><ins>+ RefPtr<TextResourceDecoder> decoder = InspectorPageAgent::createTextDecoder(cachedResource->response().mimeType(), cachedResource->response().textEncodingName());
</ins><span class="cx"> // We show content for raw resources only for certain mime types (text, html and xml). Otherwise decoder will be null.
</span><span class="cx"> if (!decoder)
</span><span class="cx"> return false;
</span><span class="lines">@@ -199,7 +188,6 @@
</span><span class="cx"> return InspectorPageAgent::dataContent(buffer->data(), buffer->size(), frame->document()->encoding(), withBase64Encode, result);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// static
</del><span class="cx"> bool InspectorPageAgent::sharedBufferContent(RefPtr<SharedBuffer>&& buffer, const String& textEncodingName, bool withBase64Encode, String* result)
</span><span class="cx"> {
</span><span class="cx"> return dataContent(buffer ? buffer->data() : nullptr, buffer ? buffer->size() : 0, textEncodingName, withBase64Encode, result);
</span><span class="lines">@@ -215,7 +203,6 @@
</span><span class="cx"> return decodeBuffer(data, size, textEncodingName, result);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// static
</del><span class="cx"> void InspectorPageAgent::resourceContent(ErrorString& errorString, Frame* frame, const URL& url, String* result, bool* base64Encoded)
</span><span class="cx"> {
</span><span class="cx"> DocumentLoader* loader = assertDocumentLoader(errorString, frame);
</span><span class="lines">@@ -297,6 +284,8 @@
</span><span class="cx"> return Inspector::Protocol::Page::ResourceType::Script;
</span><span class="cx"> case XHRResource:
</span><span class="cx"> return Inspector::Protocol::Page::ResourceType::XHR;
</span><ins>+ case FetchResource:
+ return Inspector::Protocol::Page::ResourceType::Fetch;
</ins><span class="cx"> case WebSocketResource:
</span><span class="cx"> return Inspector::Protocol::Page::ResourceType::WebSocket;
</span><span class="cx"> case OtherResource:
</span><span class="lines">@@ -315,19 +304,26 @@
</span><span class="cx"> #endif
</span><span class="cx"> case CachedResource::FontResource:
</span><span class="cx"> return InspectorPageAgent::FontResource;
</span><del>- case CachedResource::CSSStyleSheet:
- // Fall through.
</del><span class="cx"> #if ENABLE(XSLT)
</span><span class="cx"> case CachedResource::XSLStyleSheet:
</span><span class="cx"> #endif
</span><ins>+ case CachedResource::CSSStyleSheet:
</ins><span class="cx"> return InspectorPageAgent::StylesheetResource;
</span><span class="cx"> case CachedResource::Script:
</span><span class="cx"> return InspectorPageAgent::ScriptResource;
</span><del>- case CachedResource::MediaResource:
- case CachedResource::RawResource:
- return InspectorPageAgent::XHRResource;
</del><span class="cx"> case CachedResource::MainResource:
</span><span class="cx"> return InspectorPageAgent::DocumentResource;
</span><ins>+ case CachedResource::MediaResource:
+ case CachedResource::RawResource: {
+ switch (cachedResource.resourceRequest().requester()) {
+ case ResourceRequest::Requester::Fetch:
+ return InspectorPageAgent::FetchResource;
+ case ResourceRequest::Requester::Main:
+ return InspectorPageAgent::DocumentResource;
+ default:
+ return InspectorPageAgent::XHRResource;
+ }
+ }
</ins><span class="cx"> default:
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -339,6 +335,23 @@
</span><span class="cx"> return resourceTypeJson(cachedResourceType(cachedResource));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RefPtr<TextResourceDecoder> InspectorPageAgent::createTextDecoder(const String& mimeType, const String& textEncodingName)
+{
+ if (!textEncodingName.isEmpty())
+ return TextResourceDecoder::create(ASCIILiteral("text/plain"), textEncodingName);
+
+ if (MIMETypeRegistry::isTextMIMEType(mimeType))
+ return TextResourceDecoder::create(mimeType, "UTF-8");
+
+ if (MIMETypeRegistry::isXMLMIMEType(mimeType)) {
+ RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(ASCIILiteral("application/xml"));
+ decoder->useLenientXMLDecoding();
+ return decoder;
+ }
+
+ return TextResourceDecoder::create(ASCIILiteral("text/plain"), "UTF-8");
+}
+
</ins><span class="cx"> InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClient* client, InspectorOverlay* overlay)
</span><span class="cx"> : InspectorAgentBase(ASCIILiteral("Page"), context)
</span><span class="cx"> , m_frontendDispatcher(std::make_unique<Inspector::PageFrontendDispatcher>(context.frontendRouter))
</span><span class="lines">@@ -562,7 +575,6 @@
</span><span class="cx"> static bool textContentForCachedResource(CachedResource* cachedResource, String* result)
</span><span class="cx"> {
</span><span class="cx"> if (hasTextContent(cachedResource)) {
</span><del>- String content;
</del><span class="cx"> bool base64Encoded;
</span><span class="cx"> if (InspectorPageAgent::cachedResourceContent(cachedResource, result, &base64Encoded)) {
</span><span class="cx"> ASSERT(!base64Encoded);
</span><span class="lines">@@ -768,7 +780,6 @@
</span><span class="cx"> return frame;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// static
</del><span class="cx"> DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString& errorString, Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> FrameLoader& frameLoader = frame->loader();
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -51,10 +51,11 @@
</span><span class="cx"> class InspectorClient;
</span><span class="cx"> class InspectorOverlay;
</span><span class="cx"> class MainFrame;
</span><del>-class URL;
</del><span class="cx"> class Page;
</span><span class="cx"> class RenderObject;
</span><span class="cx"> class SharedBuffer;
</span><ins>+class TextResourceDecoder;
+class URL;
</ins><span class="cx">
</span><span class="cx"> typedef String ErrorString;
</span><span class="cx">
</span><span class="lines">@@ -71,6 +72,7 @@
</span><span class="cx"> FontResource,
</span><span class="cx"> ScriptResource,
</span><span class="cx"> XHRResource,
</span><ins>+ FetchResource,
</ins><span class="cx"> WebSocketResource,
</span><span class="cx"> OtherResource
</span><span class="cx"> };
</span><span class="lines">@@ -84,6 +86,7 @@
</span><span class="cx"> static Inspector::Protocol::Page::ResourceType resourceTypeJson(ResourceType);
</span><span class="cx"> static ResourceType cachedResourceType(const CachedResource&);
</span><span class="cx"> static Inspector::Protocol::Page::ResourceType cachedResourceTypeJson(const CachedResource&);
</span><ins>+ static RefPtr<TextResourceDecoder> createTextDecoder(const String& mimeType, const String& textEncodingName);
</ins><span class="cx">
</span><span class="cx"> // Page API for InspectorFrontend
</span><span class="cx"> void enable(ErrorString&) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -805,7 +805,6 @@
</span><span class="cx"> return adoptRef(*new InspectorStyleSheet(pageAgent, id, WTFMove(pageStyleSheet), origin, documentURL, listener));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// static
</del><span class="cx"> String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet)
</span><span class="cx"> {
</span><span class="cx"> if (pageStyleSheet && !pageStyleSheet->contents().baseURL().isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorNetworkResourcesDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -129,21 +129,6 @@
</span><span class="cx"> m_requestIdToResourceDataMap.set(requestId, new ResourceData(requestId, loaderId));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<TextResourceDecoder> createOtherResourceTextDecoder(const String& mimeType, const String& textEncodingName)
-{
- RefPtr<TextResourceDecoder> decoder;
- if (!textEncodingName.isEmpty())
- decoder = TextResourceDecoder::create("text/plain", textEncodingName);
- else if (MIMETypeRegistry::isXMLMIMEType(mimeType)) {
- decoder = TextResourceDecoder::create("application/xml");
- decoder->useLenientXMLDecoding();
- } else if (equalLettersIgnoringASCIICase(mimeType, "text/html"))
- decoder = TextResourceDecoder::create("text/html", "UTF-8");
- else if (mimeType == "text/plain")
- decoder = TextResourceDecoder::create("text/plain", "ISO-8859-1");
- return decoder;
-}
-
</del><span class="cx"> void NetworkResourcesData::responseReceived(const String& requestId, const String& frameId, const ResourceResponse& response)
</span><span class="cx"> {
</span><span class="cx"> ResourceData* resourceData = resourceDataForRequestId(requestId);
</span><span class="lines">@@ -151,7 +136,7 @@
</span><span class="cx"> return;
</span><span class="cx"> resourceData->setFrameId(frameId);
</span><span class="cx"> resourceData->setUrl(response.url());
</span><del>- resourceData->setDecoder(createOtherResourceTextDecoder(response.mimeType(), response.textEncodingName()));
</del><ins>+ resourceData->setDecoder(InspectorPageAgent::createTextDecoder(response.mimeType(), response.textEncodingName()));
</ins><span class="cx"> resourceData->setHTTPStatusCode(response.httpStatusCode());
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -294,6 +294,8 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_client);
</span><span class="cx">
</span><ins>+ InspectorInstrumentation::didReceiveThreadableLoaderResponse(*this, identifier);
+
</ins><span class="cx"> ASSERT(response.type() != ResourceResponse::Type::Error);
</span><span class="cx"> if (response.type() == ResourceResponse::Type::Default) {
</span><span class="cx"> m_client->didReceiveResponse(identifier, ResourceResponse::filterResponse(response, tainting));
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -58,6 +58,8 @@
</span><span class="cx"> virtual void setDefersLoading(bool);
</span><span class="cx">
</span><span class="cx"> friend CrossOriginPreflightChecker;
</span><ins>+ friend class InspectorInstrumentation;
+ friend class InspectorNetworkAgent;
</ins><span class="cx">
</span><span class="cx"> using RefCounted<DocumentThreadableLoader>::ref;
</span><span class="cx"> using RefCounted<DocumentThreadableLoader>::deref;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -516,6 +516,24 @@
</span><span class="cx"> return supportedJavaScriptMIMETypes->contains(mimeType);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool MIMETypeRegistry::isSupportedJSONMIMEType(const String& mimeType)
+{
+ if (mimeType.isEmpty())
+ return false;
+
+ if (equalLettersIgnoringASCIICase(mimeType, "application/json"))
+ return true;
+
+ // When detecting +json ensure there is a non-empty type / subtype preceeding the suffix.
+ if (mimeType.endsWith("+json", false) && mimeType.length() >= 8) {
+ size_t slashPosition = mimeType.find('/');
+ if (slashPosition != notFound && slashPosition > 0 && slashPosition <= mimeType.length() - 6)
+ return true;
+ }
+
+ return false;
+}
+
</ins><span class="cx"> bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType)
</span><span class="cx"> {
</span><span class="cx"> if (mimeType.isEmpty())
</span><span class="lines">@@ -546,7 +564,7 @@
</span><span class="cx"> bool MIMETypeRegistry::isTextMIMEType(const String& mimeType)
</span><span class="cx"> {
</span><span class="cx"> return isSupportedJavaScriptMIMEType(mimeType)
</span><del>- || equalLettersIgnoringASCIICase(mimeType, "application/json") // Render JSON as text/plain.
</del><ins>+ || isSupportedJSONMIMEType(mimeType) // Render JSON as text/plain.
</ins><span class="cx"> || (mimeType.startsWith("text/", false)
</span><span class="cx"> && !equalLettersIgnoringASCIICase(mimeType, "text/html")
</span><span class="cx"> && !equalLettersIgnoringASCIICase(mimeType, "text/xml")
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -54,8 +54,9 @@
</span><span class="cx"> // Check to see if a MIME type is suitable for being encoded.
</span><span class="cx"> static bool isSupportedImageMIMETypeForEncoding(const String& mimeType);
</span><span class="cx">
</span><del>- // Check to see if a MIME type is suitable for being loaded as a JavaScript resource.
- static bool isSupportedJavaScriptMIMEType(const String& mimeType);
</del><ins>+ // Check to see if a MIME type is suitable for being loaded as a JavaScript or JSON resource.
+ static bool isSupportedJavaScriptMIMEType(const String& mimeType);
+ static bool isSupportedJSONMIMEType(const String& mimeType);
</ins><span class="cx">
</span><span class="cx"> // Check to see if a non-image MIME type is suitable for being loaded as a
</span><span class="cx"> // document in a frame. Includes supported JavaScript MIME types.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -160,7 +160,7 @@
</span><span class="cx"> bool ignoreForRequestCount() const { return m_ignoreForRequestCount; }
</span><span class="cx"> void setIgnoreForRequestCount(bool ignoreForRequestCount) { m_ignoreForRequestCount = ignoreForRequestCount; }
</span><span class="cx">
</span><del>- enum class Requester { Unspecified, Main, XHR, Media };
</del><ins>+ enum class Requester { Unspecified, Main, XHR, Fetch, Media };
</ins><span class="cx"> Requester requester() const { return m_requester; }
</span><span class="cx"> void setRequester(Requester requester) { m_requester = requester; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1015,10 +1015,8 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void XMLHttpRequest::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
</del><ins>+void XMLHttpRequest::didReceiveResponse(unsigned long, const ResourceResponse& response)
</ins><span class="cx"> {
</span><del>- InspectorInstrumentation::didReceiveXHRResponse(scriptExecutionContext(), identifier);
-
</del><span class="cx"> m_response = response;
</span><span class="cx"> if (!m_mimeTypeOverride.isEmpty())
</span><span class="cx"> m_response.setHTTPHeaderField(HTTPHeaderName::ContentType, m_mimeTypeOverride);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-12-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Some resources fetched via Fetch API do not have data
+ https://bugs.webkit.org/show_bug.cgi?id=165230
+ <rdar://problem/29449220>
+
+ Reviewed by Alex Christensen.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ New "Fetch" and "Fetches" localized strings.
+
+ * UserInterface/Models/Resource.js:
+ (WebInspector.Resource.displayNameForType):
+ * UserInterface/Models/ResourceCollection.js:
+ (WebInspector.ResourceCollection.verifierForType):
+ * UserInterface/Views/CollectionContentView.js:
+ (WebInspector.CollectionContentView):
+ * UserInterface/Views/ResourceClusterContentView.js:
+ (WebInspector.ResourceClusterContentView.prototype.get responseContentView):
+ * UserInterface/Views/ResourceTreeElement.js:
+ (WebInspector.ResourceTreeElement.compareResourceTreeElements):
+ New ResourceType.Fetch. Behave like XHR in most places.
+
</ins><span class="cx"> 2016-12-08 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Unable to delete breakpoint from worker script
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -346,6 +346,8 @@
</span><span class="cx"> localizedStrings["Failed to upgrade"] = "Failed to upgrade";
</span><span class="cx"> localizedStrings["Family"] = "Family";
</span><span class="cx"> localizedStrings["Features"] = "Features";
</span><ins>+localizedStrings["Fetch"] = "Fetch";
+localizedStrings["Fetches"] = "Fetches";
</ins><span class="cx"> localizedStrings["File or Resource"] = "File or Resource";
</span><span class="cx"> localizedStrings["Filename"] = "Filename";
</span><span class="cx"> localizedStrings["Fill"] = "Fill";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsResourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -114,6 +114,10 @@
</span><span class="cx"> if (plural)
</span><span class="cx"> return WebInspector.UIString("XHRs");
</span><span class="cx"> return WebInspector.UIString("XHR");
</span><ins>+ case WebInspector.Resource.Type.Fetch:
+ if (plural)
+ return WebInspector.UIString("Fetches");
+ return WebInspector.UIString("Fetch");
</ins><span class="cx"> case WebInspector.Resource.Type.WebSocket:
</span><span class="cx"> if (plural)
</span><span class="cx"> return WebInspector.UIString("Sockets");
</span><span class="lines">@@ -753,6 +757,7 @@
</span><span class="cx"> Font: "resource-type-font",
</span><span class="cx"> Script: "resource-type-script",
</span><span class="cx"> XHR: "resource-type-xhr",
</span><ins>+ Fetch: "resource-type-fetch",
</ins><span class="cx"> WebSocket: "resource-type-websocket",
</span><span class="cx"> Other: "resource-type-other"
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsResourceCollectionjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -51,6 +51,8 @@
</span><span class="cx"> return WebInspector.ResourceCollection.TypeVerifier.Script;
</span><span class="cx"> case WebInspector.Resource.Type.XHR:
</span><span class="cx"> return WebInspector.ResourceCollection.TypeVerifier.XHR;
</span><ins>+ case WebInspector.Resource.Type.Fetch:
+ return WebInspector.ResourceCollection.TypeVerifier.Fetch;
</ins><span class="cx"> case WebInspector.Resource.Type.WebSocket:
</span><span class="cx"> return WebInspector.ResourceCollection.TypeVerifier.WebSocket;
</span><span class="cx"> case WebInspector.Resource.Type.Other:
</span><span class="lines">@@ -191,6 +193,7 @@
</span><span class="cx"> Font: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Font,
</span><span class="cx"> Script: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Script,
</span><span class="cx"> XHR: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.XHR,
</span><ins>+ Fetch: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Fetch,
</ins><span class="cx"> WebSocket: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.WebSocket,
</span><span class="cx"> Other: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Other,
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsCollectionContentViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -81,6 +81,10 @@
</span><span class="cx"> title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.XHR, true);
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case WebInspector.ResourceCollection.TypeVerifier.Fetch:
+ title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.Fetch, true);
+ break;
+
</ins><span class="cx"> case WebInspector.ResourceCollection.TypeVerifier.WebSocket:
</span><span class="cx"> title = WebInspector.Resource.displayNameForType(WebInspector.Resource.Type.WebSocket, true);
</span><span class="cx"> break;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsResourceClusterContentViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -65,7 +65,13 @@
</span><span class="cx"> case WebInspector.Resource.Type.Document:
</span><span class="cx"> case WebInspector.Resource.Type.Script:
</span><span class="cx"> case WebInspector.Resource.Type.Stylesheet:
</span><ins>+ this._responseContentView = new WebInspector.TextResourceContentView(this._resource);
+ break;
+
</ins><span class="cx"> case WebInspector.Resource.Type.XHR:
</span><ins>+ case WebInspector.Resource.Type.Fetch:
+ // FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
+ // XHR / Fetch content may not always be text.
</ins><span class="cx"> this._responseContentView = new WebInspector.TextResourceContentView(this._resource);
</span><span class="cx"> break;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsResourceTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js (209628 => 209629)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js        2016-12-09 22:06:29 UTC (rev 209628)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js        2016-12-09 22:12:08 UTC (rev 209629)
</span><span class="lines">@@ -44,7 +44,9 @@
</span><span class="cx"> return comparisonResult;
</span><span class="cx">
</span><span class="cx"> // Compare async resource types by their first timestamp so they are in chronological order.
</span><del>- if (a.resource.type === WebInspector.Resource.Type.XHR || a.resource.type === WebInspector.Resource.Type.WebSocket)
</del><ins>+ if (a.resource.type === WebInspector.Resource.Type.XHR
+ || a.resource.type === WebInspector.Resource.Type.Fetch
+ || a.resource.type === WebInspector.Resource.Type.WebSocket)
</ins><span class="cx"> return a.resource.firstTimestamp - b.resource.firstTimestamp || 0;
</span><span class="cx">
</span><span class="cx"> // Compare by subtitle when the types are the same. The subtitle is used to show the
</span></span></pre>
</div>
</div>
</body>
</html>