Bug 1450193 - Remove old-event-emitter usage from devtools/shared/client; r=jryans.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 30 Mar 2018 08:49:22 +0200
changeset 410782 206b41cdbafdfee947488a61f3ee40bd3bd9880b
parent 410781 523d310f551d5de194041fec635b8048d4d68aa2
child 410783 a86e795540dccdc02752f7233c91c66e20735490
push id33739
push usernbeleuzu@mozilla.com
push dateFri, 30 Mar 2018 21:47:45 +0000
treeherdermozilla-central@10c662d8416e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1450193
milestone61.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 1450193 - Remove old-event-emitter usage from devtools/shared/client; r=jryans. MozReview-Commit-ID: 42hBgG1IU2B
devtools/server/tests/mochitest/test_connection-manager.html
devtools/shared/client/connection-manager.js
--- a/devtools/server/tests/mochitest/test_connection-manager.html
+++ b/devtools/server/tests/mochitest/test_connection-manager.html
@@ -26,17 +26,17 @@ window.onload = function() {
 
   const {
     ConnectionManager,
     Connection
   } = require("devtools/shared/client/connection-manager");
 
   let orgCount = ConnectionManager.connections.length;
 
-  ConnectionManager.once("new", (event, c) => {
+  ConnectionManager.once("new", c => {
     is(ConnectionManager.connections[orgCount], c,
        "new event fired, with correct connection");
   });
 
   let c1 = ConnectionManager.createConnection();
   let c2 = ConnectionManager.createConnection();
 
   is(ConnectionManager.connections[orgCount], c1, "Connection 1 registered");
@@ -50,67 +50,67 @@ window.onload = function() {
     let eventsRef = "connecting connected disconnecting disconnected host-changed"
                     + " disconnected timeout destroyed";
     let events = [];
 
     let s = Connection.Status;
 
     is(c.status, s.DISCONNECTED, "disconnected");
 
-    c.once(Connection.Events.CONNECTING, function(e) {
-      events.push(e);
+    c.once(Connection.Events.CONNECTING, function() {
+      events.push(Connection.Events.CONNECTING);
       is(c.status, s.CONNECTING, "connecting");
     });
 
-    c.once(Connection.Events.CONNECTED, function(e) {
-      events.push(e);
+    c.once(Connection.Events.CONNECTED, function() {
+      events.push(Connection.Events.CONNECTED);
       is(c.status, s.CONNECTED, "connected");
       c.disconnect();
     });
 
-    c.once(Connection.Events.DISCONNECTING, function(e) {
-      events.push(e);
+    c.once(Connection.Events.DISCONNECTING, function() {
+      events.push(Connection.Events.DISCONNECTING);
       is(c.status, s.DISCONNECTING, "disconnecting");
     });
 
-    c.once(Connection.Events.DISCONNECTED, function(e) {
-      events.push(e);
+    c.once(Connection.Events.DISCONNECTED, function() {
+      events.push(Connection.Events.DISCONNECTED);
       is(c.status, s.DISCONNECTED, "disconnected");
       testError();
     });
 
-    c.once(Connection.Events.DESTROYED, function(e) {
-      events.push(e);
+    c.once(Connection.Events.DESTROYED, function() {
+      events.push(Connection.Events.DESTROYED);
       is(c.status, s.DESTROYED, "destroyed");
       finish();
     });
 
     c.connect();
 
     function testError() {
-      c.once(Connection.Events.DISCONNECTED, function(e) {
-        events.push(e);
+      c.once(Connection.Events.DISCONNECTED, function() {
+        events.push(Connection.Events.DISCONNECTED);
         testKeepConnecting();
       });
-      c.once(Connection.Events.HOST_CHANGED, function(e) {
-        events.push(e);
+      c.once(Connection.Events.HOST_CHANGED, function() {
+        events.push(Connection.Events.HOST_CHANGED);
         c.connect();
       });
       c.port = 1;
       c.host = "localhost";
     }
 
     function testKeepConnecting() {
       // ensure that keepConnecting keep trying connecting
       // until the connection attempts timeout
       let prefRemoteTimeout = "devtools.debugger.remote-timeout";
       let originalTimeout = Services.prefs.getIntPref(prefRemoteTimeout);
       Services.prefs.setIntPref("devtools.debugger.remote-timeout", 1000);
-      c.once("timeout", function(e) {
-        events.push(e);
+      c.once(Connection.Events.TIMEOUT, function() {
+        events.push(Connection.Events.TIMEOUT);
         Services.prefs.setIntPref(prefRemoteTimeout, originalTimeout);
         ConnectionManager.destroyConnection(c);
       });
       c.keepConnecting = true;
       let port = ConnectionManager.getFreeTCPPort();
       ok(parseInt(port, 10), "Free TCP port looks like a port number");
       c.port = port;
       c.host = "locahost";
--- a/devtools/shared/client/connection-manager.js
+++ b/devtools/shared/client/connection-manager.js
@@ -2,17 +2,17 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Cc, Ci, Cr} = require("chrome");
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
 const { DebuggerServer } = require("devtools/server/main");
 const { DebuggerClient } = require("devtools/shared/client/debugger-client");
 const Services = require("Services");
 
 const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout";
 
 /**
  * Connection Manager.
@@ -78,17 +78,17 @@ const REMOTE_TIMEOUT = "devtools.debugge
  *  . Connection.Events.NEW_LOG         A new log line is available
  *
  */
 
 var ConnectionManager = {
   _connections: new Set(),
   createConnection: function(host, port) {
     let c = new Connection(host, port);
-    c.once("destroy", (event) => this.destroyConnection(c));
+    c.once("destroy", () => this.destroyConnection(c));
     this._connections.add(c);
     this.emit("new", c);
     return c;
   },
   destroyConnection: function(connection) {
     if (this._connections.has(connection)) {
       this._connections.delete(connection);
       if (connection.status != Connection.Status.DESTROYED) {