Web Inspector: response.bodySize in HAR is invalid (negative) for cached resources
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 14:52:50 +0000 (14:52 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 14:52:50 +0000 (14:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76823

Reviewed by Yury Semikhatsky.

- fix response.bodySize for cached resources;
Also some drive-by fixes:
- pretty-print HAR when exported
- proper annotation for JSON.stringify()
- de-obfuscate a piece of code in TimelinePanel

* inspector/front-end/HAREntry.js:
(WebInspector.HAREntry.prototype.get responseBodySize):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.prototype._exportAll):
(WebInspector.NetworkLogView.prototype._exportResource):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105619 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HAREntry.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/TimelinePanel.js
Source/WebCore/inspector/front-end/externs.js

index cff6371..6f00362 100644 (file)
@@ -1,3 +1,22 @@
+2012-01-23  Andrey Kosyakov  <caseq@chromium.org>
+
+        Web Inspector: response.bodySize in HAR is invalid (negative) for cached resources
+        https://bugs.webkit.org/show_bug.cgi?id=76823
+
+        Reviewed by Yury Semikhatsky.
+
+        - fix response.bodySize for cached resources;
+        Also some drive-by fixes:
+        - pretty-print HAR when exported
+        - proper annotation for JSON.stringify()
+        - de-obfuscate a piece of code in TimelinePanel
+
+        * inspector/front-end/HAREntry.js:
+        (WebInspector.HAREntry.prototype.get responseBodySize):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView.prototype._exportAll):
+        (WebInspector.NetworkLogView.prototype._exportResource):
+
 2012-01-23  Mario Sanchez Prada  <msanchez@igalia.com>
 
         [GTK] Refactor GTK's accessibilitity code to be more modular
index 0c33f77..e9c1d38 100644 (file)
@@ -250,6 +250,8 @@ WebInspector.HAREntry.prototype = {
      */
     get responseBodySize()
     {
+        if (this._resource.cached || this._resource.statusCode === 304)
+            return 0;
         return this._resource.transferSize - this._resource.responseHeadersSize
     },
 
index 6fd4fcd..9b65a87 100644 (file)
@@ -964,13 +964,13 @@ WebInspector.NetworkLogView.prototype = {
         var harArchive = {
             log: (new WebInspector.HARLog(this._resources)).build()
         };
-        InspectorFrontendHost.copyText(JSON.stringify(harArchive));
+        InspectorFrontendHost.copyText(JSON.stringify(harArchive, null, 2));
     },
 
     _copyResource: function(resource)
     {
         var har = (new WebInspector.HAREntry(resource)).build();
-        InspectorFrontendHost.copyText(JSON.stringify(har));
+        InspectorFrontendHost.copyText(JSON.stringify(har, null, 2));
     },
 
     _copyLocation: function(resource)
@@ -994,13 +994,13 @@ WebInspector.NetworkLogView.prototype = {
             log: (new WebInspector.HARLog(this._resources)).build()
         };
         
-        InspectorFrontendHost.saveAs(WebInspector.inspectedPageDomain + ".har", JSON.stringify(harArchive));
+        InspectorFrontendHost.saveAs(WebInspector.inspectedPageDomain + ".har", JSON.stringify(harArchive, null, 2));
     },
 
     _exportResource: function(resource)
     {
         var har = (new WebInspector.HAREntry(resource)).build();
-        InspectorFrontendHost.saveAs(resource.displayName + ".har", JSON.stringify(har));
+        InspectorFrontendHost.saveAs(resource.displayName + ".har", JSON.stringify(har, null, 2));
     },
 
     _clearBrowserCache: function(event)
index 9947b96..201bdbe 100644 (file)
@@ -1391,12 +1391,13 @@ WebInspector.TimelineModel.prototype = {
 
     _saveToFile: function()
     {
-        var records = ['[' + JSON.stringify(window.navigator.appVersion)];
+        var records = ['[' + JSON.stringify(new String(window.navigator.appVersion))];
         for (var i = 0; i < this._records.length; ++i)
             records.push(JSON.stringify(this._records[i]));
-            records[records.length - 1] = records[records.length - 1] + "]";
 
-        var now= new Date();
+        records[records.length - 1] = records[records.length - 1] + "]";
+
+        var now = new Date();
         var suggestedFileName = "TimelineRawData-" + now.toISO8601Compact() + ".json";
         InspectorFrontendHost.saveAs(suggestedFileName, records.join(",\n"));
     },
index f7421f9..45aded5 100644 (file)
@@ -41,9 +41,13 @@ console.trace = function() {}
 var JSON = {}
 /** @param {string} str */
 JSON.parse = function(str) {}
-/** @param {Object} obj */
-/** @return {string} */
-JSON.stringify = function(str) {}
+/**
+ * @param {Object} obj
+ * @param {Function=} replacer
+ * @param {number=} space
+ * @return {string}
+ */
+JSON.stringify = function(obj, replacer, space) {}
 
 /** @param {boolean=} param */
 Element.prototype.scrollIntoViewIfNeeded = function(param) {}