WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
176252
WebKit should claim that it can show responses for a broader range of JSON MIMETypes
https://bugs.webkit.org/show_bug.cgi?id=176252
Summary
WebKit should claim that it can show responses for a broader range of JSON MI...
Joseph Pecoraro
Reported
2017-09-01 16:01:27 PDT
WebKit claims to be able to support some JSON types ("application/json") but not other types ("application/vnd.api+json") even though it can and actually does handle it. Lets broaden that to the full list of resources WebKit decides to handle as text. Steps to Reproduce: 1. Visit a URL that loads JSON with MIMEType "application/json" => WebKit shows the content as text 2. Visit a URL that loads JSON with MIMEType "application/vnd.api+json" => WebKit ignores the content by default, Safari decides to download the response Notes: WebKit knows how to display responses matching a whitelist of different MIME types. This whitelist is mostly summarized by the following: (WebKit extends this list to PDFs and plugins)
> bool MIMETypeRegistry::canShowMIMEType(const String& mimeType) > { > if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType)) > return true; > > if (mimeType.startsWith("text/", false)) > return !isUnsupportedTextMIMEType(mimeType); > > return false; > }
Included in this whitelist is "application/json" but not other MIME types that we recognize as JSON (namely isSupportedJSONMIMEType()) When WebKit lets clients decide what to do with a response it includes an indication of whether or not WebKit claims to be able to handle the response or not:
> /*! Contains information about a navigation response, used for making policy decisions. */ > @interface WKNavigationResponse : NSObject > > /*! @abstract A Boolean value indicating whether WebKit can display the response's MIME type natively. > @discussion Allowing a navigation response with a MIME type that can't be shown will cause the navigation to fail. */ > @property (nonatomic, readonly) BOOL canShowMIMEType; > > @end
Since this is based off of the strict whitelist above, canShowMIMEType may be NO even if WebKit can ultimately recognize and show the response as text. There is a list non-"text/" prefixed MIME Types in isSupportedJavaScriptMIMEType and isSupportedJSONMIMEType that WebKit will be able to show as text, but it claims it does not know how to show. So WebKit clients like Safari allow "application/json" but not some other JSON types.
Attachments
[PATCH] Proposed Fix
(15.46 KB, patch)
2017-09-01 16:09 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(15.04 KB, patch)
2017-09-01 16:43 PDT
,
Joseph Pecoraro
ap
: review-
buildbot
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews105 for mac-elcapitan-wk2
(1.48 MB, application/zip)
2017-09-01 17:33 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews101 for mac-elcapitan
(1.63 MB, application/zip)
2017-09-01 17:34 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews124 for ios-simulator-wk2
(1.31 MB, application/zip)
2017-09-01 17:59 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews116 for mac-elcapitan
(2.18 MB, application/zip)
2017-09-01 18:05 PDT
,
Build Bot
no flags
Details
[PATCH] Proposed Fix
(14.54 KB, patch)
2017-09-06 13:38 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(15.18 KB, patch)
2017-09-06 13:40 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(23.12 KB, patch)
2017-09-07 19:36 PDT
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
Show Obsolete
(8)
View All
Add attachment
proposed patch, testcase, etc.
Joseph Pecoraro
Comment 1
2017-09-01 16:01:37 PDT
<
rdar://problem/34212885
>
Joseph Pecoraro
Comment 2
2017-09-01 16:08:57 PDT
Modifying the whitelist of MIME Types WebKit claims to be able to show will affect WebKit clients. - Default behavior would have been to Ignore the load and would now be Use. - WebKit client's will receive a difference value for the canShowMimeType indication (WKNavigationResponse) - Safari behavior would likely have been to Download a `!canShowMimeType` indicated response and may now change to Use. In this case, since WebKit already claimed to support "application/json" I think it is safe to extend this to a broader list of JSON mime types. Does anyone actually like that Safari / WebKit sometimes ignores / downloads a JSON response instead of showing it immediately? We've had requests, specifically for "application/vnd.api+json" to show it immediately as text instead of downloading it.
Joseph Pecoraro
Comment 3
2017-09-01 16:09:14 PDT
Created
attachment 319661
[details]
[PATCH] Proposed Fix
Joseph Pecoraro
Comment 4
2017-09-01 16:43:30 PDT
Created
attachment 319669
[details]
[PATCH] Proposed Fix
Build Bot
Comment 5
2017-09-01 17:33:52 PDT
Comment on
attachment 319669
[details]
[PATCH] Proposed Fix
Attachment 319669
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/4429962
New failing tests: imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html
Build Bot
Comment 6
2017-09-01 17:33:53 PDT
Created
attachment 319678
[details]
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 7
2017-09-01 17:34:11 PDT
Comment on
attachment 319669
[details]
[PATCH] Proposed Fix
Attachment 319669
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.webkit.org/results/4429965
New failing tests: imported/w3c/web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects.html imported/w3c/web-platform-tests/html/semantics/forms/historical.html imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-pathname-setter-question-mark.html imported/w3c/web-platform-tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html http/tests/inspector/network/resource-mime-type.html
Build Bot
Comment 8
2017-09-01 17:34:13 PDT
Created
attachment 319679
[details]
Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 9
2017-09-01 17:59:30 PDT
Comment on
attachment 319669
[details]
[PATCH] Proposed Fix
Attachment 319669
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/4429989
New failing tests: imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html
Build Bot
Comment 10
2017-09-01 17:59:31 PDT
Created
attachment 319681
[details]
Archive of layout-test-results from ews124 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Build Bot
Comment 11
2017-09-01 18:05:45 PDT
Comment on
attachment 319669
[details]
[PATCH] Proposed Fix
Attachment 319669
[details]
did not pass mac-debug-ews (mac): Output:
http://webkit-queues.webkit.org/results/4430042
New failing tests: imported/w3c/web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects.html imported/w3c/web-platform-tests/html/semantics/forms/historical.html imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-pathname-setter-question-mark.html imported/w3c/web-platform-tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html http/tests/inspector/network/resource-mime-type.html
Build Bot
Comment 12
2017-09-01 18:05:47 PDT
Created
attachment 319683
[details]
Archive of layout-test-results from ews116 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Alexey Proskuryakov
Comment 13
2017-09-06 12:31:15 PDT
Comment on
attachment 319669
[details]
[PATCH] Proposed Fix Marking r- for the red EWS.
Joseph Pecoraro
Comment 14
2017-09-06 13:38:22 PDT
Created
attachment 320057
[details]
[PATCH] Proposed Fix
Joseph Pecoraro
Comment 15
2017-09-06 13:40:00 PDT
Created
attachment 320058
[details]
[PATCH] Proposed Fix
Joseph Pecoraro
Comment 16
2017-09-07 15:27:43 PDT
Comment on
attachment 320058
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=320058&action=review
> Tools/ChangeLog:3 > + WebKit should claim that it can show responses a broader range of JSON MIMETypes
Typo: "responses *for* a broader range"
Alexey Proskuryakov
Comment 17
2017-09-07 15:57:55 PDT
Comment on
attachment 320058
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=320058&action=review
> Tools/ChangeLog:13 > + * TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp: Added.
Discussing with Joseph on IRC, this change impacts behavior that's observable via API (SPI?). I think that it should be tested using API, and not by exposing an internal function.
Joseph Pecoraro
Comment 18
2017-09-07 19:36:17 PDT
Created
attachment 320227
[details]
[PATCH] Proposed Fix Now with API tests for the change in -[WKNavigationResponse canShowMIMEType].
WebKit Commit Bot
Comment 19
2017-09-07 23:21:33 PDT
Comment on
attachment 320227
[details]
[PATCH] Proposed Fix Clearing flags on attachment: 320227 Committed
r221778
: <
http://trac.webkit.org/changeset/221778
>
WebKit Commit Bot
Comment 20
2017-09-07 23:21:35 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug