Summary: Inspecting a Main Resource that is JS/JSON does not format / syntax highlight it properly Steps to Reproduce: 1. Inspect https://svn.webkit.org/repository/webkit/trunk/Source/JavaScriptCore/features.json 2. Show the features.json main resource => Detected as JSON, is syntax highlighted, and can be pretty printed 3. Reload => Main resource is not syntax highlighted and cannot be pretty printed Notes: - Document resources may have more specific mime types than the text/html that syntheticMIMEType forces them to be.
<rdar://problem/29835977>
Created attachment 298389 [details] [PATCH] Proposed Fix
Created attachment 298394 [details] [Image] Behavior in trunk Following the steps to reproduce seems to produce the expected result in trunk, am I missing something?
Comment on attachment 298389 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=298389&action=review Code change looks fine, but this begs for a test. Try loading JSON into an iframe as the main resource. You'll want the test and the JSON file in LayoutTests/http/tests/inspector/. > Source/WebInspectorUI/ChangeLog:11 > + Don't override the mime type for Document resources if it has one. Grumpy nit, please don't fix: MIME is an initialism.
(In reply to comment #3) > Created attachment 298394 [details] > [Image] Behavior in trunk > > Following the steps to reproduce seems to produce the expected result in > trunk, am I missing something? Did you reload? I can reproduce on trunk.
(In reply to comment #5) > (In reply to comment #3) > > Created attachment 298394 [details] > > [Image] Behavior in trunk > > > > Following the steps to reproduce seems to produce the expected result in > > trunk, am I missing something? > > Did you reload? I can reproduce on trunk. I hadn't tried reloading. Now I can reproduce it.
Created attachment 298526 [details] [PATCH] Proposed Fix
Comment on attachment 298526 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=298526&action=review > LayoutTests/http/tests/inspector/network/resource-mime-type.html:285 > + mimeType: "text/plain", // NOTE: Unsure why this MIME type is different than when XHR requested it. I'm seeing super weird behavior where we sometimes see one and sometimes the other (text/plain, application/octet-stream). Running this test multiple times encounters this issue, and also the Console Message above is finicky...
Comment on attachment 298526 [details] [PATCH] Proposed Fix Attachment 298526 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/2866950 New failing tests: http/tests/inspector/network/resource-mime-type.html
Created attachment 298541 [details] Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Comment on attachment 298526 [details] [PATCH] Proposed Fix Attachment 298526 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2866952 New failing tests: http/tests/inspector/network/resource-mime-type.html
Created attachment 298542 [details] Archive of layout-test-results from ews114 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Comment on attachment 298526 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=298526&action=review Marking r- because of EWS failures. Probably need more investigation of the flaky test case. > LayoutTests/http/tests/inspector/network/resource-mime-type.html:85 > + json: "application/octet-stream", this is surprising, i have seen things like text/json before. Can we have multiple test cases for cases like this? Or is this mime type specific to XHR requests? > LayoutTests/http/tests/inspector/network/resource-mime-type.html:99 > + mimeType: mimeTypeForExtension.js, this is clever. >> LayoutTests/http/tests/inspector/network/resource-mime-type.html:285 >> + mimeType: "text/plain", // NOTE: Unsure why this MIME type is different than when XHR requested it. > > I'm seeing super weird behavior where we sometimes see one and sometimes the other (text/plain, application/octet-stream). Running this test multiple times encounters this issue, and also the Console Message above is finicky... This seems to be the only thing blocking this patch from review/landing. If you want to land everything else separately, then investigate this issue (which seems related to the actual bug at hand here), that's fine with me.
Created attachment 305614 [details] [PATCH] Proposed Fix This gets rid of the flakiness by making a few minor changes: 1. Not using a Strict DOCTYPE to remove a flakey console warning message 2. Forcing application/json mime type for a JSON resource (data.json => json.php)
Comment on attachment 305614 [details] [PATCH] Proposed Fix r=me
Comment on attachment 305614 [details] [PATCH] Proposed Fix Clearing flags on attachment: 305614 Committed r214492: <http://trac.webkit.org/changeset/214492>
All reviewed patches have been landed. Closing bug.