Bug 1564105 - Enable WS Monitor in Nightly. r=Honza,jdescottes
authortanhengyeow <E0032242@u.nus.edu>
Thu, 18 Jul 2019 13:49:59 +0000
changeset 483315 8c833d50284dbcdabc004cc0a2676750bd5fb6af
parent 483314 268013e80821d3a1a155453f5712ad43551c26b3
child 483316 18a84c6f33925bbc8e13763f495e7fcb1b2bee92
push id36313
push useropoprus@mozilla.com
push dateThu, 18 Jul 2019 21:50:51 +0000
treeherdermozilla-central@5fceb8c496bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, jdescottes
bugs1564105
milestone70.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 1564105 - Enable WS Monitor in Nightly. r=Honza,jdescottes Enable WS Monitor in Nightly Differential Revision: https://phabricator.services.mozilla.com/D38230
devtools/client/preferences/devtools-client.js
devtools/server/actors/network-monitor/websocket-actor.js
devtools/shared/fronts/websocket.js
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -184,18 +184,22 @@ pref("devtools.netmonitor.har.defaultFil
 pref("devtools.netmonitor.har.jsonp", false);
 pref("devtools.netmonitor.har.jsonpCallback", "");
 pref("devtools.netmonitor.har.includeResponseBodies", true);
 pref("devtools.netmonitor.har.compress", false);
 pref("devtools.netmonitor.har.forceExport", false);
 pref("devtools.netmonitor.har.pageLoadedTimeout", 1500);
 pref("devtools.netmonitor.har.enableAutoExportToFile", false);
 
-// Support for WebSocket monitoring pref (pending complete implementation)
+// Enable WebSocket monitoring in Nightly builds.
+#if defined(NIGHTLY_BUILD)
+pref("devtools.netmonitor.features.webSockets", true);
+#else
 pref("devtools.netmonitor.features.webSockets", false);
+#endif
 
 // Scratchpad settings
 // - recentFileMax: The maximum number of recently-opened files
 //                  stored. Setting this preference to 0 will not
 //                  clear any recent files, but rather hide the
 //                  'Open Recent'-menu.
 // - lineNumbers: Whether to show line numbers or not.
 // - wrapText: Whether to wrap text or not.
--- a/devtools/server/actors/network-monitor/websocket-actor.js
+++ b/devtools/server/actors/network-monitor/websocket-actor.js
@@ -18,17 +18,17 @@ const webSocketEventService = Cc[
  *
  * @see devtools/shared/spec/websocket.js for documentation.
  */
 const WebSocketActor = ActorClassWithSpec(webSocketSpec, {
   initialize(conn, targetActor) {
     Actor.prototype.initialize.call(this, conn);
 
     this.targetActor = targetActor;
-    this.listening = false;
+    this.innerWindowID = null;
 
     // Each connection's webSocketSerialID is mapped to a httpChannelId
     this.connections = new Map();
 
     // Register for backend events.
     this.onNavigate = this.onNavigate.bind(this);
     this.onWillNavigate = this.onWillNavigate.bind(this);
     this.targetActor.on("navigate", this.onNavigate);
@@ -49,32 +49,30 @@ const WebSocketActor = ActorClassWithSpe
 
     this.stopListening();
     Actor.prototype.destroy.call(this);
   },
 
   // Actor API
 
   startListening: function() {
-    // Register WS listener
-    if (!this.listening) {
-      const innerWindowID = this.targetActor.window.windowUtils
-        .currentInnerWindowID;
-      webSocketEventService.addListener(innerWindowID, this);
-      this.listening = true;
-    }
+    this.stopListening();
+    this.innerWindowID = this.targetActor.window.windowUtils.currentInnerWindowID;
+    webSocketEventService.addListener(this.innerWindowID, this);
   },
 
   stopListening() {
-    if (this.listening) {
-      const innerWindowID = this.targetActor.window.windowUtils
-        .currentInnerWindowID;
-      webSocketEventService.removeListener(innerWindowID, this);
-      this.listening = false;
+    if (!this.innerWindowID) {
+      return;
     }
+    if (webSocketEventService.hasListenerFor(this.innerWindowID)) {
+      webSocketEventService.removeListener(this.innerWindowID, this);
+    }
+
+    this.innerWindowID = null;
   },
 
   // nsIWebSocketEventService
 
   webSocketCreated(webSocketSerialID, uri, protocols) {},
 
   webSocketOpened(
     webSocketSerialID,
--- a/devtools/shared/fronts/websocket.js
+++ b/devtools/shared/fronts/websocket.js
@@ -32,19 +32,16 @@ class WebSocketFront extends FrontClassW
     this.on("serverFrameReceived", this._onFrameReceived);
   }
 
   /**
    * Close the WebSocketFront.
    *
    */
   destroy() {
-    if (!this._client) {
-      return null;
-    }
     this.off("serverWebSocketOpened");
     this.off("serverWebSocketClosed");
     this.off("serverFrameSent");
     this.off("serverFrameReceived");
     return super.destroy();
   }
 
   /**