Bug 1240959 - Properly calculate total size. r=vporof
authorJan Odvarko <odvarko@gmail.com>
Tue, 23 Feb 2016 12:47:15 +0100
changeset 286022 37ca88b45a72c955fda3069a4f9eb2b2e3d04b0a
parent 286021 396a68628a6bfc7bd0b96a9f64c94b4975f4cf93
child 286023 04634ec900b2fb94962733148ecdeac7ae98e0e2
push id17889
push userryanvm@gmail.com
push dateMon, 29 Feb 2016 17:49:02 +0000
treeherderfx-team@04634ec900b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1240959
milestone47.0a1
Bug 1240959 - Properly calculate total size. r=vporof
devtools/client/netmonitor/netmonitor-view.js
devtools/shared/webconsole/network-monitor.js
--- a/devtools/client/netmonitor/netmonitor-view.js
+++ b/devtools/client/netmonitor/netmonitor-view.js
@@ -2214,17 +2214,24 @@ RequestsMenuView.prototype = Heritage.ex
    *
    * @param array aItemsArray
    * @return number
    */
   _getTotalBytesOfRequests: function(aItemsArray) {
     if (!aItemsArray.length) {
       return 0;
     }
-    return aItemsArray.reduce((prev, curr) => prev + curr.attachment.contentSize || 0, 0);
+
+    let result = 0;
+    aItemsArray.forEach(item => {
+      let size = item.attachment.contentSize;
+      result += (typeof size == "number") ? size : 0;
+    });
+
+    return result;
   },
 
   /**
    * Gets the oldest (first performed) request in a set. Returns null for an
    * empty set.
    *
    * @param array aItemsArray
    * @return object
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -383,17 +383,19 @@ NetworkResponseListener.prototype = {
 
     try {
       response.mimeType = this.request.contentType;
     }
     catch (ex) { }
 
     if (!response.mimeType || !NetworkHelper.isTextMimeType(response.mimeType)) {
       response.encoding = "base64";
-      response.text = btoa(response.text);
+      try {
+        response.text = btoa(response.text);
+      } catch (err) { }
     }
 
     if (response.mimeType && this.request.contentCharset) {
       response.mimeType += "; charset=" + this.request.contentCharset;
     }
 
     this.receivedData = "";