<!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
&lt;rdar://problem/29835977&gt;

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; 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  &lt;pecoraro@apple.com&gt;
+
+        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
+        &lt;rdar://problem/29835977&gt;
+
+        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  &lt;ryanhaddad@apple.com&gt;
</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>+&lt;!-- No DOCTYPE to avoid Flakey Strict Mode Console Warning --&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function loadDocumentWithURL(url) {
+    let iframe = document.createElement(&quot;iframe&quot;);
+    iframe.src = url;
+    document.body.appendChild(iframe);
+}
+
+function loadScriptWithURL(url) {
+    let script = document.createElement(&quot;script&quot;);
+    script.src = url;
+    document.body.appendChild(script);
+}
+
+function loadStyleSheetWithURL(url) {
+    let link = document.createElement(&quot;link&quot;);
+    link.rel = &quot;stylesheet&quot;;
+    link.href = url;
+    document.head.appendChild(link);
+}
+
+function loadImageWithURL(url) {
+    let img = document.createElement(&quot;img&quot;);
+    img.src = url;
+    document.body.appendChild(img);
+}
+
+function loadXHRWithURL(url) {
+    let xhr = new XMLHttpRequest;
+    xhr.open(&quot;GET&quot;, url, true);
+    xhr.send();
+}
+
+function loadFetchWithURL(url) {
+    fetch(url);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite(&quot;Resource.MIMEType&quot;);
+
+    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) =&gt; {
+                    let resource = event.data.resource;
+                    InspectorTest.expectThat(resource instanceof WebInspector.Resource, &quot;Resource should be created.&quot;);
+                    resource.singleFireEventListener(WebInspector.Resource.Event.ResponseReceived, (event) =&gt; {
+                        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) =&gt; {
+                    // At this point the frame's resource has loaded.
+                    let resource = event.data.childFrame.mainResource;
+                    InspectorTest.expectThat(resource instanceof WebInspector.Resource, &quot;Frame MainResource should be created.&quot;);
+                    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: &quot;application/x-javascript&quot;,
+        json: &quot;application/json&quot;,
+        css: &quot;text/css&quot;,
+        txt: &quot;text/plain&quot;,
+        html: &quot;text/html&quot;,
+        png: &quot;image/png&quot;,
+        jpg: &quot;image/jpeg&quot;,
+    };
+
+    // Scripts.
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Script.js&quot;,
+        expression: `loadScriptWithURL(&quot;resources/script.js&quot;)`,
+        type: WebInspector.Resource.Type.Script,
+        mimeType: mimeTypeForExtension.js,
+        synthetic: mimeTypeForExtension.js,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Script.txt&quot;,
+        expression: `loadScriptWithURL(&quot;resources/script.txt&quot;)`,
+        type: WebInspector.Resource.Type.Script,
+        mimeType: mimeTypeForExtension.txt,
+        synthetic: &quot;text/javascript&quot;,
+    });
+
+    // Stylesheets.
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Stylesheet.css&quot;,
+        expression: `loadStyleSheetWithURL(&quot;resources/stylesheet.css&quot;)`,
+        type: WebInspector.Resource.Type.Stylesheet,
+        mimeType: mimeTypeForExtension.css,
+        synthetic: mimeTypeForExtension.css,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Stylesheet.txt&quot;,
+        expression: `loadStyleSheetWithURL(&quot;resources/stylesheet.txt&quot;)`,
+        type: WebInspector.Resource.Type.Stylesheet,
+        mimeType: mimeTypeForExtension.txt,
+        synthetic: &quot;text/css&quot;,
+    });
+
+    // Images.
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Image.png&quot;,
+        expression: `loadImageWithURL(&quot;/resources/square100.png&quot;)`,
+        type: WebInspector.Resource.Type.Image,
+        mimeType: mimeTypeForExtension.png,
+        synthetic: mimeTypeForExtension.png,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Image.jpg&quot;,
+        expression: `loadImageWithURL(&quot;/resources/square20.jpg&quot;)`,
+        type: WebInspector.Resource.Type.Image,
+        mimeType: mimeTypeForExtension.jpg,
+        synthetic: mimeTypeForExtension.jpg,
+    });
+
+    // XHRs.
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.js&quot;,
+        expression: `loadXHRWithURL(&quot;resources/script.js&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.js,
+        synthetic: mimeTypeForExtension.js,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.css&quot;,
+        expression: `loadXHRWithURL(&quot;resources/stylesheet.css&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.css,
+        synthetic: mimeTypeForExtension.css,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.png&quot;,
+        expression: `loadXHRWithURL(&quot;/resources/square100.png&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.png,
+        synthetic: mimeTypeForExtension.png,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.txt&quot;,
+        expression: `loadXHRWithURL(&quot;/resources/square20.jpg&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.jpg,
+        synthetic: mimeTypeForExtension.jpg,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.json&quot;,
+        expression: `loadXHRWithURL(&quot;resources/json.php&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.json,
+        synthetic: mimeTypeForExtension.json,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.XHR.html&quot;,
+        expression: `loadXHRWithURL(&quot;resources/data.html&quot;)`,
+        type: WebInspector.Resource.Type.XHR,
+        mimeType: mimeTypeForExtension.html,
+        synthetic: mimeTypeForExtension.html,
+    });
+
+    // Fetch.
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.js&quot;,
+        expression: `loadFetchWithURL(&quot;resources/script.js&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.js,
+        synthetic: mimeTypeForExtension.js,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.css&quot;,
+        expression: `loadFetchWithURL(&quot;resources/stylesheet.css&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.css,
+        synthetic: mimeTypeForExtension.css,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.png&quot;,
+        expression: `loadFetchWithURL(&quot;/resources/square100.png&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.png,
+        synthetic: mimeTypeForExtension.png,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.txt&quot;,
+        expression: `loadFetchWithURL(&quot;/resources/square20.jpg&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.jpg,
+        synthetic: mimeTypeForExtension.jpg,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.json&quot;,
+        expression: `loadFetchWithURL(&quot;resources/json.php&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.json,
+        synthetic: mimeTypeForExtension.json,
+    });
+
+    addTestCase({
+        name: &quot;Resource.MIMEType.Fetch.html&quot;,
+        expression: `loadFetchWithURL(&quot;resources/data.html&quot;)`,
+        type: WebInspector.Resource.Type.Fetch,
+        mimeType: mimeTypeForExtension.html,
+        synthetic: mimeTypeForExtension.html,
+    });
+
+    // Documents.
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.js&quot;,
+        expression: `loadDocumentWithURL(&quot;resources/script.js&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.js,
+        synthetic: mimeTypeForExtension.js,
+    });
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.css&quot;,
+        expression: `loadDocumentWithURL(&quot;resources/stylesheet.css&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.css,
+        synthetic: mimeTypeForExtension.css,
+    });
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.png&quot;,
+        expression: `loadDocumentWithURL(&quot;/resources/square100.png&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.png,
+        synthetic: mimeTypeForExtension.png,
+    });
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.txt&quot;,
+        expression: `loadDocumentWithURL(&quot;/resources/square20.jpg&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.jpg,
+        synthetic: mimeTypeForExtension.jpg,
+    });
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.json&quot;,
+        expression: `loadDocumentWithURL(&quot;resources/json.php&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.json,
+        synthetic: mimeTypeForExtension.json,
+    });
+
+    addDocumentResourceTestCase({
+        name: &quot;Resource.MIMEType.Document.html&quot;,
+        expression: `loadDocumentWithURL(&quot;resources/data.html&quot;)`,
+        type: WebInspector.Resource.Type.Document,
+        mimeType: mimeTypeForExtension.html,
+        synthetic: mimeTypeForExtension.html,
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;p&gt;Tests for the `mimeType` and `syntheticMIMEType` properties of different Resource Types.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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>+&lt;?php
+header(&quot;Content-Type: application/json&quot;);
+echo '{&quot;version&quot;: 1}';
+?&gt;
</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\xE0JFIFHH\xFF\xDBC\xFF\xDBC\xFF\xC2\xFF\xC4        \xFF\xC4        \xFF\xDA \x8E{\xF9+\xFF\xC40\xFF\xDA\xFF\xC40\xFF\xDA?\xFF\xC40\xFF\xDA?\xFF\xC40\xFF\xDA?\xFF\xC40\xFF\xDA?!\xFF\xDA \xFF\xC40\xFF\xDA?\xFF\xC40\xFF\xDA?\xFF\xC40\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  &lt;pecoraro@apple.com&gt;
</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
+        &lt;rdar://problem/29835977&gt;
+
+        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  &lt;pecoraro@apple.com&gt;
+
</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 &quot;text/html&quot;;
</del><span class="cx">         case WebInspector.Resource.Type.Stylesheet:
</span><span class="cx">             return &quot;text/css&quot;;
</span><span class="cx">         case WebInspector.Resource.Type.Script:
</span></span></pre>
</div>
</div>

</body>
</html>