<!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>[214492] 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/214492">214492</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-28 13:57:11 -0700 (Tue, 28 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Inspecting a Main Resource that is JS/JSON does not format / syntax highlight it properly
https://bugs.webkit.org/show_bug.cgi?id=166862
<rdar://problem/29835977>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-03-28
Reviewed by Brian Burg.
Source/WebInspectorUI:
* UserInterface/Models/Resource.js:
(WebInspector.Resource.prototype.get syntheticMIMEType):
Don't override the mime type for Document resources. They should always
have a mime type and we should use whatever it is.
LayoutTests:
* http/tests/inspector/network/resource-mime-type-expected.txt: Added.
* http/tests/inspector/network/resource-mime-type.html: Added.
Test resource mime types for different resources.
* http/tests/inspector/network/resources/json.php: Added.
* http/tests/inspector/network/resources/script.js: Added.
* http/tests/inspector/network/resources/script.txt: Added.
* http/tests/inspector/network/resources/stylesheet.css: Added.
* http/tests/inspector/network/resources/stylesheet.txt: Added.
* http/tests/resources/square20.jpg: Added.
Resources for various requests and different mime types.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsResourcejs">trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcemimetypeexpectedtxt">trunk/LayoutTests/http/tests/inspector/network/resource-mime-type-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcemimetypehtml">trunk/LayoutTests/http/tests/inspector/network/resource-mime-type.html</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesjsonphp">trunk/LayoutTests/http/tests/inspector/network/resources/json.php</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesscriptjs">trunk/LayoutTests/http/tests/inspector/network/resources/script.js</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesscripttxt">trunk/LayoutTests/http/tests/inspector/network/resources/script.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesstylesheetcss">trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.css</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectornetworkresourcesstylesheettxt">trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsresourcessquare20jpg">trunk/LayoutTests/http/tests/resources/square20.jpg</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214491 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-28 20:50:36 UTC (rev 214491)
+++ trunk/LayoutTests/ChangeLog        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-03-28 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Inspecting a Main Resource that is JS/JSON does not format / syntax highlight it properly
+ https://bugs.webkit.org/show_bug.cgi?id=166862
+ <rdar://problem/29835977>
+
+ Reviewed by Brian Burg.
+
+ * http/tests/inspector/network/resource-mime-type-expected.txt: Added.
+ * http/tests/inspector/network/resource-mime-type.html: Added.
+ Test resource mime types for different resources.
+
+ * http/tests/inspector/network/resources/json.php: Added.
+ * http/tests/inspector/network/resources/script.js: Added.
+ * http/tests/inspector/network/resources/script.txt: Added.
+ * http/tests/inspector/network/resources/stylesheet.css: Added.
+ * http/tests/inspector/network/resources/stylesheet.txt: Added.
+ * http/tests/resources/square20.jpg: Added.
+ Resources for various requests and different mime types.
+
</ins><span class="cx"> 2017-03-28 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Mark http/tests/xmlhttprequest/simple-cross-origin-progress-events.html as flaky.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcemimetypeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resource-mime-type-expected.txt (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resource-mime-type-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-mime-type-expected.txt        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+Tests for the `mimeType` and `syntheticMIMEType` properties of different Resource Types.
+
+
+== Running test suite: Resource.MIMEType
+-- Running test case: Resource.MIMEType.Script.js
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-script'.
+PASS: Resource mimeType should be 'application/x-javascript'.
+PASS: Resource syntheticMIMEType should be 'application/x-javascript'.
+
+-- Running test case: Resource.MIMEType.Script.txt
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-script'.
+PASS: Resource mimeType should be 'text/plain'.
+PASS: Resource syntheticMIMEType should be 'text/javascript'.
+
+-- Running test case: Resource.MIMEType.Stylesheet.css
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-stylesheet'.
+PASS: Resource mimeType should be 'text/css'.
+PASS: Resource syntheticMIMEType should be 'text/css'.
+
+-- Running test case: Resource.MIMEType.Stylesheet.txt
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-stylesheet'.
+PASS: Resource mimeType should be 'text/plain'.
+PASS: Resource syntheticMIMEType should be 'text/css'.
+
+-- Running test case: Resource.MIMEType.Image.png
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-image'.
+PASS: Resource mimeType should be 'image/png'.
+PASS: Resource syntheticMIMEType should be 'image/png'.
+
+-- Running test case: Resource.MIMEType.Image.jpg
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-image'.
+PASS: Resource mimeType should be 'image/jpeg'.
+PASS: Resource syntheticMIMEType should be 'image/jpeg'.
+
+-- Running test case: Resource.MIMEType.XHR.js
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'application/x-javascript'.
+PASS: Resource syntheticMIMEType should be 'application/x-javascript'.
+
+-- Running test case: Resource.MIMEType.XHR.css
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'text/css'.
+PASS: Resource syntheticMIMEType should be 'text/css'.
+
+-- Running test case: Resource.MIMEType.XHR.png
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'image/png'.
+PASS: Resource syntheticMIMEType should be 'image/png'.
+
+-- Running test case: Resource.MIMEType.XHR.txt
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'image/jpeg'.
+PASS: Resource syntheticMIMEType should be 'image/jpeg'.
+
+-- Running test case: Resource.MIMEType.XHR.json
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'application/json'.
+PASS: Resource syntheticMIMEType should be 'application/json'.
+
+-- Running test case: Resource.MIMEType.XHR.html
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-xhr'.
+PASS: Resource mimeType should be 'text/html'.
+PASS: Resource syntheticMIMEType should be 'text/html'.
+
+-- Running test case: Resource.MIMEType.Fetch.js
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'application/x-javascript'.
+PASS: Resource syntheticMIMEType should be 'application/x-javascript'.
+
+-- Running test case: Resource.MIMEType.Fetch.css
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'text/css'.
+PASS: Resource syntheticMIMEType should be 'text/css'.
+
+-- Running test case: Resource.MIMEType.Fetch.png
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'image/png'.
+PASS: Resource syntheticMIMEType should be 'image/png'.
+
+-- Running test case: Resource.MIMEType.Fetch.txt
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'image/jpeg'.
+PASS: Resource syntheticMIMEType should be 'image/jpeg'.
+
+-- Running test case: Resource.MIMEType.Fetch.json
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'application/json'.
+PASS: Resource syntheticMIMEType should be 'application/json'.
+
+-- Running test case: Resource.MIMEType.Fetch.html
+PASS: Resource should be created.
+PASS: Resource Type should be 'resource-type-fetch'.
+PASS: Resource mimeType should be 'text/html'.
+PASS: Resource syntheticMIMEType should be 'text/html'.
+
+-- Running test case: Resource.MIMEType.Document.js
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'application/x-javascript'.
+PASS: Resource syntheticMIMEType should be 'application/x-javascript'.
+
+-- Running test case: Resource.MIMEType.Document.css
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'text/css'.
+PASS: Resource syntheticMIMEType should be 'text/css'.
+
+-- Running test case: Resource.MIMEType.Document.png
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'image/png'.
+PASS: Resource syntheticMIMEType should be 'image/png'.
+
+-- Running test case: Resource.MIMEType.Document.txt
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'image/jpeg'.
+PASS: Resource syntheticMIMEType should be 'image/jpeg'.
+
+-- Running test case: Resource.MIMEType.Document.json
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'application/json'.
+PASS: Resource syntheticMIMEType should be 'application/json'.
+
+-- Running test case: Resource.MIMEType.Document.html
+PASS: Frame MainResource should be created.
+PASS: Resource Type should be 'resource-type-document'.
+PASS: Resource mimeType should be 'text/html'.
+PASS: Resource syntheticMIMEType should be 'text/html'.
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcemimetypehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resource-mime-type.html (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resource-mime-type.html         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-mime-type.html        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1,304 @@
</span><ins>+<!-- No DOCTYPE to avoid Flakey Strict Mode Console Warning -->
+<html>
+<head>
+<script src="../resources/inspector-test.js"></script>
+<script>
+function loadDocumentWithURL(url) {
+ let iframe = document.createElement("iframe");
+ iframe.src = url;
+ document.body.appendChild(iframe);
+}
+
+function loadScriptWithURL(url) {
+ let script = document.createElement("script");
+ script.src = url;
+ document.body.appendChild(script);
+}
+
+function loadStyleSheetWithURL(url) {
+ let link = document.createElement("link");
+ link.rel = "stylesheet";
+ link.href = url;
+ document.head.appendChild(link);
+}
+
+function loadImageWithURL(url) {
+ let img = document.createElement("img");
+ img.src = url;
+ document.body.appendChild(img);
+}
+
+function loadXHRWithURL(url) {
+ let xhr = new XMLHttpRequest;
+ xhr.open("GET", url, true);
+ xhr.send();
+}
+
+function loadFetchWithURL(url) {
+ fetch(url);
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Resource.MIMEType");
+
+ function addTestCase({name, description, expression, type, mimeType, synthetic}) {
+ suite.addTestCase({
+ name, description,
+ test(resolve, reject) {
+ InspectorTest.evaluateInPage(expression);
+ WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ let resource = event.data.resource;
+ InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+ resource.singleFireEventListener(WebInspector.Resource.Event.ResponseReceived, (event) => {
+ InspectorTest.expectEqual(resource.type, type, `Resource Type should be '${type}'.`);
+ InspectorTest.expectEqual(resource.mimeType, mimeType, `Resource mimeType should be '${mimeType}'.`);
+ InspectorTest.expectEqual(resource.syntheticMIMEType, synthetic, `Resource syntheticMIMEType should be '${synthetic}'.`);
+ resolve();
+ });
+ });
+ }
+ });
+ }
+
+ function addDocumentResourceTestCase({name, description, expression, type, mimeType, synthetic}) {
+ suite.addTestCase({
+ name, description,
+ test(resolve, reject) {
+ InspectorTest.evaluateInPage(expression);
+ WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ChildFrameWasAdded, (event) => {
+ // At this point the frame's resource has loaded.
+ let resource = event.data.childFrame.mainResource;
+ InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Frame MainResource should be created.");
+ InspectorTest.expectEqual(resource.type, type, `Resource Type should be '${type}'.`);
+ InspectorTest.expectEqual(resource.mimeType, mimeType, `Resource mimeType should be '${mimeType}'.`);
+ InspectorTest.expectEqual(resource.syntheticMIMEType, synthetic, `Resource syntheticMIMEType should be '${synthetic}'.`);
+ resolve();
+ });
+ }
+ });
+ }
+
+ // These are the Apache MIME types returned for file extensions.
+ let mimeTypeForExtension = {
+ js: "application/x-javascript",
+ json: "application/json",
+ css: "text/css",
+ txt: "text/plain",
+ html: "text/html",
+ png: "image/png",
+ jpg: "image/jpeg",
+ };
+
+ // Scripts.
+
+ addTestCase({
+ name: "Resource.MIMEType.Script.js",
+ expression: `loadScriptWithURL("resources/script.js")`,
+ type: WebInspector.Resource.Type.Script,
+ mimeType: mimeTypeForExtension.js,
+ synthetic: mimeTypeForExtension.js,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Script.txt",
+ expression: `loadScriptWithURL("resources/script.txt")`,
+ type: WebInspector.Resource.Type.Script,
+ mimeType: mimeTypeForExtension.txt,
+ synthetic: "text/javascript",
+ });
+
+ // Stylesheets.
+
+ addTestCase({
+ name: "Resource.MIMEType.Stylesheet.css",
+ expression: `loadStyleSheetWithURL("resources/stylesheet.css")`,
+ type: WebInspector.Resource.Type.Stylesheet,
+ mimeType: mimeTypeForExtension.css,
+ synthetic: mimeTypeForExtension.css,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Stylesheet.txt",
+ expression: `loadStyleSheetWithURL("resources/stylesheet.txt")`,
+ type: WebInspector.Resource.Type.Stylesheet,
+ mimeType: mimeTypeForExtension.txt,
+ synthetic: "text/css",
+ });
+
+ // Images.
+
+ addTestCase({
+ name: "Resource.MIMEType.Image.png",
+ expression: `loadImageWithURL("/resources/square100.png")`,
+ type: WebInspector.Resource.Type.Image,
+ mimeType: mimeTypeForExtension.png,
+ synthetic: mimeTypeForExtension.png,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Image.jpg",
+ expression: `loadImageWithURL("/resources/square20.jpg")`,
+ type: WebInspector.Resource.Type.Image,
+ mimeType: mimeTypeForExtension.jpg,
+ synthetic: mimeTypeForExtension.jpg,
+ });
+
+ // XHRs.
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.js",
+ expression: `loadXHRWithURL("resources/script.js")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.js,
+ synthetic: mimeTypeForExtension.js,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.css",
+ expression: `loadXHRWithURL("resources/stylesheet.css")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.css,
+ synthetic: mimeTypeForExtension.css,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.png",
+ expression: `loadXHRWithURL("/resources/square100.png")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.png,
+ synthetic: mimeTypeForExtension.png,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.txt",
+ expression: `loadXHRWithURL("/resources/square20.jpg")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.jpg,
+ synthetic: mimeTypeForExtension.jpg,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.json",
+ expression: `loadXHRWithURL("resources/json.php")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.json,
+ synthetic: mimeTypeForExtension.json,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.XHR.html",
+ expression: `loadXHRWithURL("resources/data.html")`,
+ type: WebInspector.Resource.Type.XHR,
+ mimeType: mimeTypeForExtension.html,
+ synthetic: mimeTypeForExtension.html,
+ });
+
+ // Fetch.
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.js",
+ expression: `loadFetchWithURL("resources/script.js")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.js,
+ synthetic: mimeTypeForExtension.js,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.css",
+ expression: `loadFetchWithURL("resources/stylesheet.css")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.css,
+ synthetic: mimeTypeForExtension.css,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.png",
+ expression: `loadFetchWithURL("/resources/square100.png")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.png,
+ synthetic: mimeTypeForExtension.png,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.txt",
+ expression: `loadFetchWithURL("/resources/square20.jpg")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.jpg,
+ synthetic: mimeTypeForExtension.jpg,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.json",
+ expression: `loadFetchWithURL("resources/json.php")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.json,
+ synthetic: mimeTypeForExtension.json,
+ });
+
+ addTestCase({
+ name: "Resource.MIMEType.Fetch.html",
+ expression: `loadFetchWithURL("resources/data.html")`,
+ type: WebInspector.Resource.Type.Fetch,
+ mimeType: mimeTypeForExtension.html,
+ synthetic: mimeTypeForExtension.html,
+ });
+
+ // Documents.
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.js",
+ expression: `loadDocumentWithURL("resources/script.js")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.js,
+ synthetic: mimeTypeForExtension.js,
+ });
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.css",
+ expression: `loadDocumentWithURL("resources/stylesheet.css")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.css,
+ synthetic: mimeTypeForExtension.css,
+ });
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.png",
+ expression: `loadDocumentWithURL("/resources/square100.png")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.png,
+ synthetic: mimeTypeForExtension.png,
+ });
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.txt",
+ expression: `loadDocumentWithURL("/resources/square20.jpg")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.jpg,
+ synthetic: mimeTypeForExtension.jpg,
+ });
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.json",
+ expression: `loadDocumentWithURL("resources/json.php")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.json,
+ synthetic: mimeTypeForExtension.json,
+ });
+
+ addDocumentResourceTestCase({
+ name: "Resource.MIMEType.Document.html",
+ expression: `loadDocumentWithURL("resources/data.html")`,
+ type: WebInspector.Resource.Type.Document,
+ mimeType: mimeTypeForExtension.html,
+ synthetic: mimeTypeForExtension.html,
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for the `mimeType` and `syntheticMIMEType` properties of different Resource Types.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesjsonphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/json.php (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/json.php         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/json.php        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+<?php
+header("Content-Type: application/json");
+echo '{"version": 1}';
+?>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesscriptjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/script.js (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/script.js         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/script.js        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+function myScriptJS() {}
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesscripttxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/script.txt (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/script.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/script.txt        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+function myScriptTXT() {}
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesstylesheetcss"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.css (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.css         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.css        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+#stylesheet-css { color: blue; }
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectornetworkresourcesstylesheettxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.txt (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet.txt        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+#stylesheet-txt { color: orange; }
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsresourcessquare20jpg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/resources/square20.jpg (0 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resources/square20.jpg         (rev 0)
+++ trunk/LayoutTests/http/tests/resources/square20.jpg        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+\xFF\xD8\xFF\xE0 JFIF H H \xFF\xDB C \xFF\xDB C\xFF\xC2 \xFF\xC4         \xFF\xC4         \xFF\xDA \x8E{\xF9+ \xFF\xC4 0\xFF\xDA \xFF\xC4 0\xFF\xDA ?\xFF\xC4 0\xFF\xDA ?\xFF\xC4 0\xFF\xDA ?\xFF\xC4 0\xFF\xDA ?!\xFF\xDA \xFF\xC4 0\xFF\xDA ?\xFF\xC4 0\xFF\xDA ?\xFF\xC4 0\xFF\xDA ?\xFF\xD9
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (214491 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2017-03-28 20:50:36 UTC (rev 214491)
+++ trunk/Source/WebInspectorUI/ChangeLog        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2017-03-28 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ Web Inspector: Inspecting a Main Resource that is JS/JSON does not format / syntax highlight it properly
+ https://bugs.webkit.org/show_bug.cgi?id=166862
+ <rdar://problem/29835977>
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Models/Resource.js:
+ (WebInspector.Resource.prototype.get syntheticMIMEType):
+ Don't override the mime type for Document resources. They should always
+ have a mime type and we should use whatever it is.
+
+2017-03-28 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> Web Inspector: Unable to Format JSON Request Data
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=170189
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsResourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (214491 => 214492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js        2017-03-28 20:50:36 UTC (rev 214491)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js        2017-03-28 20:57:11 UTC (rev 214492)
</span><span class="lines">@@ -270,8 +270,6 @@
</span><span class="cx"> // Return the default MIME-types for the Resource.Type, since the current MIME-type
</span><span class="cx"> // does not match what is expected for the Resource.Type.
</span><span class="cx"> switch (this._type) {
</span><del>- case WebInspector.Resource.Type.Document:
- return "text/html";
</del><span class="cx"> case WebInspector.Resource.Type.Stylesheet:
</span><span class="cx"> return "text/css";
</span><span class="cx"> case WebInspector.Resource.Type.Script:
</span></span></pre>
</div>
</div>
</body>
</html>