RESOLVED FIXED 141389
Web Inspector: content views for resources loaded through XHR do not reflect declared mime-type
https://bugs.webkit.org/show_bug.cgi?id=141389
Summary Web Inspector: content views for resources loaded through XHR do not reflect ...
Brian Burg
Reported 2015-02-09 10:05:54 PST
This seems kinda screwy, since data:url resources will be placed in the Font group. But if it were loaded via XHR, then it goes to the XHR group, given a blank icon and Resource Type in the sidebar reads "XHR". The fact that it came by XHR seems secondary to whether it's HTML, image, etc. (It does seem that they are properly syntax highlighted, so maybe the text editor respects mime type but content view creation doesn't?)
Attachments
[PATCH] Proposed Fix (70.28 KB, patch)
2017-12-04 16:06 PST, Joseph Pecoraro
bburg: review+
[PATCH] For Bots (68.59 KB, patch)
2017-12-04 17:02 PST, Joseph Pecoraro
ews-watchlist: commit-queue-
Archive of layout-test-results from ews101 for mac-elcapitan (2.16 MB, application/zip)
2017-12-04 18:44 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews117 for mac-elcapitan (2.89 MB, application/zip)
2017-12-04 19:07 PST, EWS Watchlist
no flags
[PATCH] For Bots (with test debugging) (68.71 KB, patch)
2017-12-04 20:19 PST, Joseph Pecoraro
ews-watchlist: commit-queue-
Archive of layout-test-results from ews122 for ios-simulator-wk2 (2.13 MB, application/zip)
2017-12-04 20:45 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews103 for mac-elcapitan (2.33 MB, application/zip)
2017-12-04 21:03 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews117 for mac-elcapitan (2.97 MB, application/zip)
2017-12-04 21:47 PST, EWS Watchlist
no flags
[PATCH] Proposed Fix (68.53 KB, patch)
2017-12-05 12:13 PST, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2015-02-09 10:06:31 PST
Brian Burg
Comment 2 2015-02-11 14:45:39 PST
*** Bug 134725 has been marked as a duplicate of this bug. ***
Brian Burg
Comment 3 2015-02-11 14:48:20 PST
Another repro (copied from the bug dupe'd to this one): 1. Load http://en.wikipedia.org/wiki/Deh_Kahan 2. Click on the map to show a bigger view, which is loaded by XHR 3. Select the XHR resource in the resource sidebar panel 4. Gibberish, as what appears to be binary data is interpreted as text
Derk-Jan Hartman
Comment 4 2015-06-30 13:57:12 PDT
Problem still exists in Safari 9 Seed1
Blaze Burg
Comment 5 2016-08-01 10:43:51 PDT
Still reproduces after other encoding issue was fixed.
Johan K. Jensen
Comment 6 2016-08-01 15:11:19 PDT
It looks like the frontend could quickly get updated to use the correct mimetype, but it doesn’t look like we get the correct data from the backend. NetworkAgent.getResponseBody (called from Resource.js) returns (a promise with) the raw image, instead of a base64 encoded blob, which is what gets shown as text. Looks like it comes from InspectorNetworkAgent::didFinishXHRLoading and NetworkResourcesData::setResourceContent, but not quite sure how far back to track it.
Joseph Pecoraro
Comment 7 2017-11-29 13:14:34 PST
Joseph Pecoraro
Comment 8 2017-11-29 13:30:21 PST
*** Bug 165495 has been marked as a duplicate of this bug. ***
Joseph Pecoraro
Comment 9 2017-12-04 16:06:06 PST
Created attachment 328403 [details] [PATCH] Proposed Fix I suspect there might be some fallout here from default XHR application/octet-stream (which we used to treat as Text will now treat as binary), and probably show a blank Generic View. After some testing I'll see if we should add back a fallback to treat this as text for XHR only (not for Other / Fetch). Ideally a binary / general fallback view would be best.
Blaze Burg
Comment 10 2017-12-04 16:18:29 PST
Comment on attachment 328403 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=328403&action=review r=me, I am so glad you finally dug into this. It's one of my biggest pet peeves. > LayoutTests/inspector/page/searchInResources.html:27 > + InspectorTest.debug(); Please remove. > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:872 > + || MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType); I'm curious what will happen with video content and video metadata. This is something we can revisit later since we do a poor job anyway and it's not a current focus. > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:875 > +RefPtr<TextResourceDecoder> InspectorNetworkAgent::createTextDecoder(const String& mimeType, const String& textEncodingName) Nit: this should return a Ref. > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:898 > + if (InspectorNetworkAgent::cachedResourceContent(cachedResource, &result, &base64Encoded)) { Eww, we should clean up the parameter types. Can you make this by reference? > Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:906 > +bool InspectorNetworkAgent::cachedResourceContent(CachedResource& resource, String* result, bool* base64Encoded) Ditto. Looks like there are only two use sites. > Source/WebCore/inspector/agents/InspectorPageAgent.cpp:492 > + if (auto* resource = cachedResource(frame, kurl)) { kurl 👴🏻 > Source/WebInspectorUI/ChangeLog:26 > + Better handle a no content cases. -a > Source/WebInspectorUI/ChangeLog:32 > + This is done by looking at the ResourceType, and MIME Type. -,
Blaze Burg
Comment 11 2017-12-04 16:20:58 PST
"/Volumes/Data/EWS/WebKit/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:885:16: error: no viable conversion from 'WTF::Ref<WebCore::TextResourceDecoder>' to 'RefPtr<WebCore::TextResourceDecoder>' return decoder; ^~~~~~~ " Looks like you need to use this constructor: template<typename T> template<typename U> inline RefPtr<T>::RefPtr(Ref<U>&& reference)
Joseph Pecoraro
Comment 12 2017-12-04 17:02:54 PST
Created attachment 328415 [details] [PATCH] For Bots
EWS Watchlist
Comment 13 2017-12-04 18:44:22 PST Comment hidden (obsolete)
EWS Watchlist
Comment 14 2017-12-04 18:44:23 PST Comment hidden (obsolete)
EWS Watchlist
Comment 15 2017-12-04 19:07:09 PST Comment hidden (obsolete)
EWS Watchlist
Comment 16 2017-12-04 19:07:11 PST Comment hidden (obsolete)
Joseph Pecoraro
Comment 17 2017-12-04 20:19:50 PST
Created attachment 328432 [details] [PATCH] For Bots (with test debugging)
EWS Watchlist
Comment 18 2017-12-04 20:45:29 PST Comment hidden (obsolete)
EWS Watchlist
Comment 19 2017-12-04 20:45:30 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2017-12-04 21:03:37 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2017-12-04 21:03:38 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2017-12-04 21:47:43 PST Comment hidden (obsolete)
EWS Watchlist
Comment 23 2017-12-04 21:47:45 PST
Created attachment 328437 [details] Archive of layout-test-results from ews117 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Joseph Pecoraro
Comment 24 2017-12-05 12:08:26 PST
So, this fails on WebKit1 because WebKit1 appears to allow plugins to register any mime type as a non-image mime type even if it is an image mime type. TestNetscapePlugIn (used by DumpRenderTree) registers "image/png", and WebKit adds this to the MIMETypeRegistry::getSupportedNonImageMIMETypes. Which seems completely wrong since "image/png" is an image mime type. I'm going to drop use of SupportedNonImageMIMETypes since it looks like it can't be trusted.
Joseph Pecoraro
Comment 25 2017-12-05 12:13:11 PST
Created attachment 328481 [details] [PATCH] Proposed Fix
WebKit Commit Bot
Comment 26 2017-12-05 14:09:40 PST
Comment on attachment 328481 [details] [PATCH] Proposed Fix Clearing flags on attachment: 328481 Committed r225546: <https://trac.webkit.org/changeset/225546>
Note You need to log in before you can comment on or make changes to this bug.