Bug 1240762 - Fix ServiceWorker request coming from Cache/Fetch. r=vporof
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 20 Jan 2016 14:09:25 -0800
changeset 303135 afb7e27d06f569b5dbc6d477ce09135101fd5097
parent 303134 9300568c634b2f76eb5893b3630e1efe76c7f49d
child 303136 22d80ccb4626eaf220e7d00abe713893f88fe26c
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1240762
milestone46.0a1
Bug 1240762 - Fix ServiceWorker request coming from Cache/Fetch. r=vporof
devtools/server/actors/webconsole.js
devtools/shared/webconsole/network-monitor.js
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1027,16 +1027,19 @@ WebConsoleActor.prototype =
   onSetPreferences: function WCA_onSetPreferences(aRequest)
   {
     for (let key in aRequest.preferences) {
       this._prefs[key] = aRequest.preferences[key];
 
       if (key == "NetworkMonitor.saveRequestAndResponseBodies" &&
           this.networkMonitor) {
         this.networkMonitor.saveRequestAndResponseBodies = this._prefs[key];
+        if (this.networkMonitorChild) {
+          this.networkMonitorChild.saveRequestAndResponseBodies = this._prefs[key];
+        }
       }
     }
     return { updated: Object.keys(aRequest.preferences) };
   },
 
   //////////////////
   // End of request handlers.
   //////////////////
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -218,18 +218,20 @@ NetworkResponseListener.prototype = {
     this._findOpenResponse();
     // We need to track the offset for the onDataAvailable calls where we pass the data
     // from our pipe to the coverter.
     this.offset = 0;
 
     // In the multi-process mode, the conversion happens on the child side while we can
     // only monitor the channel on the parent side. If the content is gzipped, we have
     // to unzip it ourself. For that we use the stream converter services.
+    // Do not do that for Service workers as they are run in the child process.
     let channel = this.request;
-    if (channel instanceof Ci.nsIEncodedChannel &&
+    if (!this.httpActivity.fromServiceWorker &&
+        channel instanceof Ci.nsIEncodedChannel &&
         channel.contentEncodings &&
         !channel.applyConversion) {
       let encodingHeader = channel.getResponseHeader("Content-Encoding");
       let scs = Cc["@mozilla.org/streamConverters;1"].
         getService(Ci.nsIStreamConverterService);
       let encodings = encodingHeader.split(/\s*\t*,\s*\t*/);
       let nextListener = this;
       let acceptedEncodings = ["gzip", "deflate", "x-gzip", "x-deflate"];
@@ -855,16 +857,17 @@ NetworkMonitor.prototype = {
     let event = {};
     event.method = aChannel.requestMethod;
     event.url = aChannel.URI.spec;
     event.private = httpActivity.private;
     event.headersSize = 0;
     event.startedDateTime = (timestamp ? new Date(Math.round(timestamp / 1000)) : new Date()).toISOString();
     event.fromCache = fromCache;
     event.fromServiceWorker = fromServiceWorker;
+    httpActivity.fromServiceWorker = fromServiceWorker;
 
     if (extraStringData) {
       event.headersSize = extraStringData.length;
     }
 
     // Determine if this is an XHR request.
     httpActivity.isXHR = event.isXHR =
         (aChannel.loadInfo.externalContentPolicyType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||