OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 var htmlErrorPreview = this._htmlErrorPreview(); | 137 var htmlErrorPreview = this._htmlErrorPreview(); |
138 if (htmlErrorPreview) | 138 if (htmlErrorPreview) |
139 return htmlErrorPreview; | 139 return htmlErrorPreview; |
140 } | 140 } |
141 | 141 |
142 var xmlView = this._xmlView(); | 142 var xmlView = this._xmlView(); |
143 if (xmlView) | 143 if (xmlView) |
144 return xmlView; | 144 return xmlView; |
145 | 145 |
146 if (this.request.resourceType() === WebInspector.resourceTypes.XHR) { | 146 if (this.request.resourceType() === WebInspector.resourceTypes.XHR) { |
147 var jsonView = this._jsonView(); | 147 var isHtml = false; |
148 if (jsonView) | 148 try { |
149 return jsonView; | 149 isHtml = !!((new DOMParser()).parseFromString(this._requestConte
nt(), mimeType)).body; |
150 var htmlErrorPreview = this._htmlErrorPreview(); | 150 } catch (e) { |
151 if (htmlErrorPreview) | 151 } |
152 return htmlErrorPreview; | 152 if (!isHtml) { |
| 153 var jsonView = this._jsonView(); |
| 154 if (jsonView) |
| 155 return jsonView; |
| 156 } else { |
| 157 var htmlErrorPreview = this._htmlErrorPreview(); |
| 158 if (htmlErrorPreview) |
| 159 return htmlErrorPreview; |
| 160 } |
153 } | 161 } |
154 | 162 |
155 if (this._responseView.sourceView) | 163 if (this._responseView.sourceView) |
156 return this._responseView.sourceView; | 164 return this._responseView.sourceView; |
157 | 165 |
158 if (this.request.resourceType() === WebInspector.resourceTypes.Other) | 166 if (this.request.resourceType() === WebInspector.resourceTypes.Other) |
159 return this._createEmptyView(); | 167 return this._createEmptyView(); |
160 | 168 |
161 return WebInspector.RequestView.nonSourceViewForRequest(this.request); | 169 return WebInspector.RequestView.nonSourceViewForRequest(this.request); |
162 }, | 170 }, |
163 | 171 |
164 __proto__: WebInspector.RequestContentView.prototype | 172 __proto__: WebInspector.RequestContentView.prototype |
165 } | 173 } |
OLD | NEW |