Bug 1240959 - Properly calculate total size. r=vporof
authorJan Odvarko <odvarko@gmail.com>
Tue, 23 Feb 2016 12:47:15 +0100
changeset 286023 37ca88b45a72c955fda3069a4f9eb2b2e3d04b0a
parent 286022 396a68628a6bfc7bd0b96a9f64c94b4975f4cf93
child 286024 04634ec900b2fb94962733148ecdeac7ae98e0e2
push id30038
push usercbook@mozilla.com
push dateTue, 01 Mar 2016 10:59:06 +0000
treeherdermozilla-central@8ef94be995a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1240959
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 = "";