REGRESSION (Safari 6): Web Inspector: JSON may not be pretty printed if served as...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2019 22:12:12 +0000 (22:12 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2019 22:12:12 +0000 (22:12 +0000)
commitd7e64a9ca69393bfa1dea75ca24293a36fcd95c1
tree1cbc8a01dd38250899e2afaf8e37e4def6ea7ecf
parentbbfb9588c4d805d6b0ebf9547e721ddf50da3e1d
REGRESSION (Safari 6): Web Inspector: JSON may not be pretty printed if served as text/html
https://bugs.webkit.org/show_bug.cgi?id=122898
<rdar://problem/15241419>

Reviewed by Joseph Pecoraro.

Check the request/response data to see if it's JSON parsable. If so, allow the user to elect
to view the request/response as a JSON preview instead of raw (or pretty printed) text.

Prefer the JSON view wherever possible.

* UserInterface/Views/ResourceClusterContentView.js:
(WI.ResourceClusterContentView):
(WI.ResourceClusterContentView.prototype.get requestContentView):
(WI.ResourceClusterContentView.prototype.get customRequestContentView): Added.
(WI.ResourceClusterContentView.prototype.get customResponseContentView):
(WI.ResourceClusterContentView.prototype.get selectionPathComponents):
(WI.ResourceClusterContentView.prototype.showRequest):
(WI.ResourceClusterContentView.prototype._canShowCustomRequestContentView): Added.
(WI.ResourceClusterContentView.prototype._canShowCustomResponseContentView):
(WI.ResourceClusterContentView.prototype._contentViewForResourceType):
(WI.ResourceClusterContentView.prototype._pathComponentForContentView):
(WI.ResourceClusterContentView.prototype._identifierForContentView):
(WI.ResourceClusterContentView.prototype._showContentViewForIdentifier):
(WI.ResourceClusterContentView.prototype._canUseJSONContentViewForContent): Added.
(WI.ResourceClusterContentView.prototype._tryEnableCustomRequestContentView): Added.
(WI.ResourceClusterContentView.prototype._tryEnableCustomResponseContentView):
(WI.ResourceClusterContentView.prototype.saveToCookie): Deleted.
(WI.ResourceClusterContentView.prototype._customContentViewConstructorForResource): Deleted.
Since the current view is already saved in a `WI.Setting`, there's no need to save that
state to a cookie, as it'll be restored elsewhere.

* UserInterface/Base/Main.js:
(WI.showResourceRequest):

* UserInterface/Main.html:
* UserInterface/Views/JSONContentView.js: Added.
(WI.JSONContentView):
(WI.JSONContentView.prototype.initialLayout):
(WI.JSONContentView.prototype.attached):
(WI.JSONContentView.prototype.closed):
* UserInterface/Views/JSONContentView.css: Added.
(.content-view.json):
* Source/WebInspectorUI/UserInterface/Views/JSONResourceContentView.js: Deleted.
* Source/WebInspectorUI/UserInterface/Views/JSONResourceContentView.css: Deleted.
Create a more generic content view that shows a preview for the given JSON parsable string.

* UserInterface/Base/Utilities.js:
(String.prototype.isJSON): Added.
* UserInterface/Views/WebSocketDataGridNode.js:
(WI.WebSocketDataGridNode.prototype.appendContextMenuItems):
Utility function for checking if a string is JSON parsable.

* Localizations/en.lproj/localizedStrings.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Base/Utilities.js
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Views/JSONContentView.css [moved from Source/WebInspectorUI/UserInterface/Views/JSONResourceContentView.css with 94% similarity]
Source/WebInspectorUI/UserInterface/Views/JSONContentView.js [moved from Source/WebInspectorUI/UserInterface/Views/JSONResourceContentView.js with 63% similarity]
Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js
Source/WebInspectorUI/UserInterface/Views/WebSocketDataGridNode.js