Bug 1705219 - Remove use of jsenv object in chatZilla. r=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sun, 18 Apr 2021 19:50:53 +0100
changeset 42463 d46053462e664146cdd8bf207f85e3c15d788cc7
parent 42462 6b8988bf6c8d191c62f62589c18a581a4a62cae6
child 42464 1d1b0290a7684cbc5274ef71eb1b64c8152441eb
push id3121
push usertbbld-merge
push dateMon, 31 May 2021 21:07:04 +0000
treeherdercomm-beta@a02c59e58d79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg
bugs1705219
Bug 1705219 - Remove use of jsenv object in chatZilla. r=frg
suite/extensions/irc/js/lib/connection-rhino.js
suite/extensions/irc/js/lib/connection-xpcom.js
suite/extensions/irc/js/lib/connection.js
suite/extensions/irc/js/lib/dcc.js
suite/extensions/irc/js/lib/ident.js
suite/extensions/irc/js/lib/irc.js
suite/extensions/irc/js/lib/utils.js
suite/extensions/irc/js/tests/ircbot.js
suite/extensions/irc/locales/en-US/chrome/chatzilla.properties
suite/extensions/irc/xul/content/commands.js
suite/extensions/irc/xul/content/handlers.js
deleted file mode 100644
--- a/suite/extensions/irc/js/lib/connection-rhino.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * 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/. */
-
-function CBSConnection ()
-{
-    this._socket = null;
-}
-
-CBSConnection.prototype.connect = function(host, port, bind, tcp_flag)
-{
-    if (typeof tcp_flag == "undefined")
-        tcp_flag = false;
-    
-    this.host = host;
-    this.port = port;
-    this.bind = bind;
-    this.tcp_flag = tcp_flag;
-    
-    this._socket = new java.net.Socket(host, port);
-    this._inputStream = this._socket.getInputStream();
-    this._outputStream = new java.io.PrintStream(this._socket.getOutputStream());
-    
-    // create a 512 byte buffer for reading into.
-    this._buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 512);
-    dd("connected to " + host);
-    
-    this.isConnected = true;
-
-    return this.isConnected;
-}
-
-CBSConnection.prototype.disconnect = function()
-{
-    if (this.isConnected) {
-        this.isConnected = false;
-        this._socket.close();
-        delete this._socket;
-        delete this._inputStream;
-        delete this._outputStream;
-    }
-}
-
-CBSConnection.prototype.sendData = function(str)
-{
-    // dd ("sendData: str=" + str);
-
-    if (!this.isConnected)
-        throw "Not Connected.";
-
-    var rv = false;
-
-        
-    try
-    {
-        /* var s = new java.lang.String (str);
-        b = s.getBytes();
-        
-        this._outputStream.write(b, 0, b.length); */
-        this._outputStream.print(str);
-        rv = true;
-    }
-    catch (ex)
-    {
-        dd ("write caught exception " + ex + ".");
-        
-        if (typeof ex != "undefined")
-        {
-            this.isConnected = false;
-            throw (ex);
-        }
-        else
-            rv = false;
-    }
-    
-    return rv;        
-}
-
-CBSConnection.prototype.readData = function(timeout)
-{
-    if (!this.isConnected)
-        throw "Not Connected.";
-
-    var rv;
-
-    // dd ("readData: timeout " + timeout);
-    
-    try {
-        this._socket.setSoTimeout(Number(timeout));
-        var len = this._inputStream.read(this._buffer);
-        // dd ("read done, len = " + len + ", buffer = " + this._buffer);
-
-        rv = String(new java.lang.String(this._buffer, 0, 0, len));
-    } catch (ex) {
-        // dd ("read caught exception " + ex + ".");
-        
-        if ((typeof ex != "undefined") &&
-            (!(ex instanceof java.io.InterruptedIOException)))
-        {
-            dd ("@@@ throwing " + ex);
-            
-            this.isConnected = false;
-            throw (ex);
-        } else {
-            // dd ("int");
-            rv = "";
-        }
-    }
-
-    // dd ("readData: rv = '" + rv + "'");
-    
-    return rv;
-}
--- a/suite/extensions/irc/js/lib/connection-xpcom.js
+++ b/suite/extensions/irc/js/lib/connection-xpcom.js
@@ -309,58 +309,16 @@ function bc_connect(host, port, config, 
          */
     var proxyInfo = config.proxyInfo || null;
     var usingHTTPCONNECT = ("proxy" in config) && (config.proxy == "http")
                            && proxyInfo;
 
     if (proxyInfo && ("type" in proxyInfo) && (proxyInfo.type == "unknown"))
         throw JSIRC_ERR_PAC_LOADING;
 
-    if (jsenv.HAS_STREAM_PROVIDER)
-    {
-        if (("isSecure" in config) && config.isSecure)
-        {
-            this._transport = this._sockService.
-                              createTransportOfType("ssl", host, port,
-                                                    proxyInfo, 0, 0);
-        }
-        else
-        {
-            this._transport = this._sockService.
-                              createTransport(host, port, proxyInfo, 0, 0);
-        }
-        if (!this._transport)
-            throw ("Error creating transport.");
-
-        if (jsenv.HAS_NSPR_EVENTQ)
-        {   /* we've got an event queue, so start up an async write */
-            this._streamProvider = new StreamProvider();
-            this._write_req =
-                this._transport.asyncWrite (this._streamProvider, this,
-                                            0, -1, 0);
-        }
-        else
-        {
-            /* no nspr event queues in this environment, we can't use async
-             * calls, so set up the streams. */
-            this._outputStream = this._transport.openOutputStream(0, -1, 0);
-            if (!this._outputStream)
-                throw "Error getting output stream.";
-            this._sOutputStream = toSOutputStream(this._outputStream,
-                                                  this.binaryMode);
-
-            this._inputStream = this._transport.openInputStream(0, -1, 0);
-            if (!this._inputStream)
-                throw "Error getting input stream.";
-            this._sInputStream = toSInputStream(this._inputStream,
-                                                this.binaryMode);
-        }
-    }
-    else
-    {
         /* use new necko interfaces */
         if (("isSecure" in config) && config.isSecure)
         {
             this._transport = this._sockService.
                               createTransport(["ssl"], 1, host, port,
                                               proxyInfo);
 
             if (this.strictSSL)
@@ -369,37 +327,31 @@ function bc_connect(host, port, config, 
         else
         {
             this._transport = this._sockService.
                               createTransport(null, 0, host, port, proxyInfo);
         }
         if (!this._transport)
             throw ("Error creating transport.");
 
-        /* if we don't have an event queue, then all i/o must be blocking */
-        var openFlags;
-        if (jsenv.HAS_NSPR_EVENTQ)
-            openFlags = 0;
-        else
-            openFlags = Components.interfaces.nsITransport.OPEN_BLOCKING;
+        var openFlags = 0;
 
         /* no limit on the output stream buffer */
         this._outputStream =
             this._transport.openOutputStream(openFlags, 4096, -1);
         if (!this._outputStream)
             throw "Error getting output stream.";
         this._sOutputStream = toSOutputStream(this._outputStream,
                                               this.binaryMode);
 
         this._inputStream = this._transport.openInputStream(openFlags, 0, 0);
         if (!this._inputStream)
             throw "Error getting input stream.";
         this._sInputStream = toSInputStream(this._inputStream,
                                             this.binaryMode);
-    }
 
     this.connectDate = new Date();
     this.isConnected = true;
 
     // Bootstrap the connection if we're proxying via an HTTP proxy.
     if (usingHTTPCONNECT)
         this.sendData("CONNECT " + hostPort + " HTTP/1.1\r\n\r\n");
 
@@ -436,66 +388,31 @@ function bc_listen(port, observer)
 
 CBSConnection.prototype.accept =
 function bc_accept(transport, observer)
 {
     this._transport = transport;
     this.host = this._transport.host.toLowerCase();
     this.port = this._transport.port;
 
-    if (jsenv.HAS_STREAM_PROVIDER)
-    {
-        if (jsenv.HAS_NSPR_EVENTQ)
-        {   /* we've got an event queue, so start up an async write */
-            this._streamProvider = new StreamProvider (observer);
-            this._write_req =
-                this._transport.asyncWrite (this._streamProvider, this,
-                                            0, -1, 0);
-        }
-        else
-        {
-            /* no nspr event queues in this environment, we can't use async
-             * calls, so set up the streams. */
-            this._outputStream = this._transport.openOutputStream(0, -1, 0);
-            if (!this._outputStream)
-                throw "Error getting output stream.";
-            this._sOutputStream = toSOutputStream(this._outputStream,
-                                                  this.binaryMode);
-
-            //this._scriptableInputStream =
-            this._inputStream = this._transport.openInputStream(0, -1, 0);
-            if (!this._inputStream)
-                throw "Error getting input stream.";
-            this._sInputStream = toSInputStream(this._inputStream,
-                                                this.binaryMode);
-        }
-    }
-    else
-    {
-        /* if we don't have an event queue, then all i/o must be blocking */
-        var openFlags;
-        if (jsenv.HAS_NSPR_EVENTQ)
-            openFlags = 0;
-        else
-            openFlags = Components.interfaces.nsITransport.OPEN_BLOCKING;
+        var openFlags = 0;
 
         /* no limit on the output stream buffer */
         this._outputStream =
             this._transport.openOutputStream(openFlags, 4096, -1);
         if (!this._outputStream)
             throw "Error getting output stream.";
         this._sOutputStream = toSOutputStream(this._outputStream,
                                               this.binaryMode);
 
         this._inputStream = this._transport.openInputStream(openFlags, 0, 0);
         if (!this._inputStream)
             throw "Error getting input stream.";
         this._sInputStream = toSInputStream(this._inputStream,
                                             this.binaryMode);
-    }
 
     this.connectDate = new Date();
     this.isConnected = true;
 
     // Clean up listening socket.
     this.close();
 
     return this.isConnected;
@@ -524,20 +441,17 @@ function bc_disconnect()
 }
 
 CBSConnection.prototype.sendData =
 function bc_senddata(str)
 {
     if (!this.isConnected)
         throw "Not Connected.";
 
-    if (jsenv.HAS_NSPR_EVENTQ && jsenv.HAS_STREAM_PROVIDER)
-        this.asyncWrite (str);
-    else
-        this.sendDataNow (str);
+    this.sendDataNow(str);
 }
 
 CBSConnection.prototype.readData =
 function bc_readdata(timeout, count)
 {
     if (!this.isConnected)
         throw "Not Connected.";
 
@@ -566,55 +480,44 @@ function bc_readdata(timeout, count)
     }
 
     return rv;
 }
 
 CBSConnection.prototype.startAsyncRead =
 function bc_saread (observer)
 {
-    if (jsenv.HAS_STREAM_PROVIDER)
-    {
-        this._transport.asyncRead (new StreamListener (observer),
-                                   this, 0, -1, 0);
-    }
-    else
-    {
         var cls = Components.classes["@mozilla.org/network/input-stream-pump;1"];
         var pump = cls.createInstance(Components.interfaces.nsIInputStreamPump);
         // Account for Bug 1402888 which removed the startOffset and readLimit
         // parameters from init.
         if (pump.init.length > 5)
         {
             pump.init(this._inputStream, -1, -1, 0, 0, false);
         } else
         {
             pump.init(this._inputStream, 0, 0, false);
         }
         pump.asyncRead(new StreamListener(observer), this);
-    }
 }
 
 CBSConnection.prototype.asyncWrite =
 function bc_awrite (str)
 {
     this._streamProvider.pendingData += str;
     if (this._streamProvider.isBlocked)
     {
         this._write_req.resume();
         this._streamProvider.isBlocked = false;
     }
 }
 
 CBSConnection.prototype.hasPendingWrite =
 function bc_haspwrite ()
 {
-    if (jsenv.HAS_STREAM_PROVIDER)
-        return (this._streamProvider.pendingData != "");
-    else
         return false; /* data already pushed to necko */
 }
 
 CBSConnection.prototype.sendDataNow =
 function bc_senddatanow(str)
 {
     var rv = false;
 
@@ -689,37 +592,22 @@ function bc_getcertificate()
     // Get the actual SSL Status
     sslSp = this._transport.securityInfo.QueryInterface(sslSp);
     sslStatus = sslSp.SSLStatus.QueryInterface(sslStatus);
 
     // return the certificate
     return sslStatus.serverCert;
 }
 
-function _notimpl ()
+CBSConnection.prototype.asyncWrite =
+function bc_asyncwrite()
 {
     throw "Not Implemented.";
 }
 
-if (!jsenv.HAS_NSPR_EVENTQ)
-{
-    CBSConnection.prototype.startAsyncRead = _notimpl;
-    CBSConnection.prototype.asyncWrite = _notimpl;
-}
-else if (jsenv.HAS_STREAM_PROVIDER)
-{
-    CBSConnection.prototype.sendDataNow = _notimpl;
-}
-else
-{
-    CBSConnection.prototype.asyncWrite = _notimpl;
-}
-
-delete _notimpl;
-
 function StreamProvider(observer)
 {
     this._observer = observer;
 }
 
 StreamProvider.prototype.pendingData = "";
 StreamProvider.prototype.isBlocked = true;
 
deleted file mode 100644
--- a/suite/extensions/irc/js/lib/connection.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-/*
- * depends on utils.js, and the connection-*.js implementations.
- * 
- * loads an appropriate connection implementation, or dies trying.
- *
- */
-
-function connection_init(libPath)
-{
-    
-    if (jsenv.HAS_XPCOM)
-        load (libPath + "connection-xpcom.js");
-    else if (jsenv.HAS_RHINO)
-        load (libPath + "connection-rhino.js");
-    else
-    {
-        dd ("No connection object for this platform.");
-        return false;
-    }
-
-    return true;
-
-}
-
-
--- a/suite/extensions/irc/js/lib/dcc.js
+++ b/suite/extensions/irc/js/lib/dcc.js
@@ -91,24 +91,17 @@ function dcc_addhost(host, auth)
             {
                 while (record.hasMore())
                     me.addIP(record.getNextAddrAsString(), auth);
             }
         }
     };
 
     try {
-        var th;
-        if (jsenv.HAS_THREAD_MANAGER) {
-          th = getService("@mozilla.org/thread-manager;1").currentThread;
-        } else {
-          const EQS = getService("@mozilla.org/event-queue-service;1",
-                                 "nsIEventQueueService");
-          th = EQS.getSpecialEventQueue(EQS.CURRENT_THREAD_EVENT_QUEUE);
-        }
+        var th = getService("@mozilla.org/thread-manager;1").currentThread;
         var dnsRecord = this._dnsSvc.asyncResolve(host, false, listener, th);
     } catch (ex) {
         dd("Error resolving host to IP: " + ex);
     }
 }
 
 CIRCDCC.prototype.addIP =
 function dcc_addip(ip, auth)
@@ -611,21 +604,17 @@ function dchat_accept()
 // This may be called synchronously or asynchronously by CBSConnection.connect.
 CIRCDCCChat.prototype.onSocketConnection =
 function dchat_onsocketconnection(host, port, config, exception)
 {
     if (!exception)
     {
         this.state.socketConnected();
 
-        if (jsenv.HAS_NSPR_EVENTQ)
-            this.connection.startAsyncRead(this);
-        else
-            this.eventPump.addEvent(new CEvent("dcc-chat", "poll",
-                                               this, "onPoll"));
+        this.connection.startAsyncRead(this);
     }
     else
     {
         this.state.failed();
     }
 }
 
 // Call to make this end decline DCC Chat with target user.
@@ -685,59 +674,17 @@ function dchat_onSocketAccepted(socket, 
 
     this.connection.accept(transport, null);
 
     this.state.socketConnected();
 
     this.remoteIP = transport.host;
 
     // Start the reading!
-    if (jsenv.HAS_NSPR_EVENTQ)
-        this.connection.startAsyncRead(this);
-    else
-        this.eventPump.addEvent(new CEvent("dcc-chat", "poll",
-                                           this, "onPoll"));
-}
-
-CIRCDCCChat.prototype.onPoll =
-function dchat_poll (e)
-{
-    var line = "";
-    var ev;
-
-    try
-    {
-        line = this.connection.readData(this.READ_TIMEOUT);
-    }
-    catch (ex)
-    {
-        if (typeof (ex) != "undefined")
-        {
-            this.connection.disconnect();
-            ev = new CEvent("dcc-chat", "close", this, "onClose");
-            ev.reason = "read-error";
-            ev.exception = ex;
-            this.eventPump.addEvent(ev);
-            return false;
-        }
-        else
-            line = "";
-    }
-
-    this.eventPump.addEvent(new CEvent("dcc-chat", "poll",
-                                       this, "onPoll"));
-
-    if (line == "")
-        return false;
-
-    ev = new CEvent("dcc-chat", "data-available", this, "onDataAvailable");
-    ev.line = line;
-    this.eventPump.routeEvent(ev);
-
-    return true;
+    this.connection.startAsyncRead(this);
 }
 
 CIRCDCCChat.prototype.onStreamDataAvailable =
 function dchat_sda(request, inStream, sourceOffset, count)
 {
     var ev = new CEvent("dcc-chat", "data-available", this, "onDataAvailable");
     ev.line = this.connection.readData(0, count);
     this.eventPump.routeEvent(ev);
@@ -1048,21 +995,17 @@ function dfile_accept(localFile)
 // This may be called synchronously or asynchronously by CBSConnection.connect.
 CIRCDCCFileTransfer.prototype.onSocketConnection =
 function dfile_onsocketconnection(host, port, config, exception)
 {
     if (!exception)
     {
         this.state.socketConnected();
 
-        if (jsenv.HAS_NSPR_EVENTQ)
-            this.connection.startAsyncRead(this);
-        else
-            this.eventPump.addEvent(new CEvent("dcc-file", "poll",
-                                               this, "onPoll"));
+        this.connection.startAsyncRead(this);
     }
     else
     {
         this.state.failed();
         this.dispose();
     }
 }
 
@@ -1145,57 +1088,17 @@ function dfile_onSocketAccepted(socket, 
         this.connection.sendData(d);
     }
     catch(ex)
     {
         dd(ex);
     }
 
     // Start the reading!
-    if (jsenv.HAS_NSPR_EVENTQ)
-        this.connection.startAsyncRead(this);
-    else
-        this.eventPump.addEvent(new CEvent("dcc-file", "poll", this, "onPoll"));
-}
-
-CIRCDCCFileTransfer.prototype.onPoll =
-function dfile_poll (e)
-{
-    var data = "";
-    var ev;
-
-    try
-    {
-        data = this.connection.readData (this.READ_TIMEOUT);
-    }
-    catch (ex)
-    {
-        if (typeof (ex) != "undefined")
-        {
-            this.connection.disconnect();
-            ev = new CEvent("dcc-file", "close", this, "onClose");
-            ev.reason = "read-error";
-            ev.exception = ex;
-            this.eventPump.addEvent(ev);
-            return false;
-        }
-        else
-            data = "";
-    }
-
-    this.eventPump.addEvent(new CEvent("dcc-file", "poll", this, "onPoll"));
-
-    if (data == "")
-        return false;
-
-    ev = new CEvent("dcc-file", "data-available", this, "onDataAvailable");
-    ev.data = data;
-    this.eventPump.routeEvent(ev);
-
-    return true;
+    this.connection.startAsyncRead(this);
 }
 
 CIRCDCCFileTransfer.prototype.onStreamDataAvailable =
 function dfile_sda(request, inStream, sourceOffset, count)
 {
     var ev = new CEvent("dcc-file", "data-available", this, "onDataAvailable");
     ev.data = this.connection.readData(0, count);
     this.eventPump.routeEvent(ev);
--- a/suite/extensions/irc/js/lib/ident.js
+++ b/suite/extensions/irc/js/lib/ident.js
@@ -87,20 +87,17 @@ function ident_remove(net)
 IdentServer.prototype.onSocketAccepted =
 function ident_gotconn(serv, transport)
 {
     // Using the listening CBSConnection to accept would stop it listening.
     // A new CBSConnection does exactly what we want.
     var connection = new CBSConnection();
     connection.accept(transport);
 
-    if (jsenv.HAS_NSPR_EVENTQ)
-        connection.startAsyncRead(new IdentListener(this, connection));
-    else
-        throw "IdentServer requires HAS_NSPR_EVENTQ."; // FIXME
+    connection.startAsyncRead(new IdentListener(this, connection));
 }
 
 function IdentListener(server, connection)
 {
     this.server = server;
     this.connection = connection;
 }
 
--- a/suite/extensions/irc/js/lib/irc.js
+++ b/suite/extensions/irc/js/lib/irc.js
@@ -698,21 +698,17 @@ function serv_onsocketconnection(host, p
     }
     else if (!exception)
     {
         var ev = new CEvent("server", "connect", this, "onConnect");
         ev.server = this;
         this.parent.eventPump.addEvent(ev);
         this.isConnected = true;
 
-        if (jsenv.HAS_NSPR_EVENTQ)
-            this.connection.startAsyncRead(this);
-        else
-            this.parent.eventPump.addEvent(new CEvent("server", "poll", this,
-                                                      "onPoll"));
+        this.connection.startAsyncRead(this);
     }
     else
     {
         var ev = new CEvent("server", "disconnect", this, "onDisconnect");
         ev.server = this;
         ev.reason = "error";
         ev.exception = exception;
         ev.disconnectStatus = NS_ERROR_ABORT;
@@ -1169,31 +1165,23 @@ function serv_poll(e)
     {
         if (this.parent.state != NET_CANCELLING)
             line = this.connection.readData(this.READ_TIMEOUT);
     }
     catch (ex)
     {
         dd ("*** Caught exception " + ex + " reading from server " +
             this.hostname);
-        if (jsenv.HAS_RHINO && (ex instanceof java.lang.ThreadDeath))
-        {
-            dd("### catching a ThreadDeath");
-            throw(ex);
-        }
-        else
-        {
-            ev = new CEvent ("server", "disconnect", this, "onDisconnect");
-            ev.server = this;
-            ev.reason = "error";
-            ev.exception = ex;
-            ev.disconnectStatus = NS_ERROR_ABORT;
-            this.parent.eventPump.addEvent (ev);
-            return false;
-        }
+        ev = new CEvent ("server", "disconnect", this, "onDisconnect");
+        ev.server = this;
+        ev.reason = "error";
+        ev.exception = ex;
+        ev.disconnectStatus = NS_ERROR_ABORT;
+        this.parent.eventPump.addEvent (ev);
+        return false;
     }
 
     this.parent.eventPump.addEvent (new CEvent ("server", "poll", this,
                                                 "onPoll"));
 
     if (line)
     {
         ev = new CEvent ("server", "data-available", this, "onDataAvailable");
--- a/suite/extensions/irc/js/lib/utils.js
+++ b/suite/extensions/irc/js/lib/utils.js
@@ -74,37 +74,16 @@ if (DEBUG) {
                  } else {
                      return true;
                  }
              }
 } else {
     dd = warn = TEST = ASSERT = function (){};
 }
 
-var jsenv = new Object();
-// Netscape/Mozilla security manager, for gaining priviledges with consent.
-jsenv.HAS_SECURITYMANAGER = ((typeof netscape == "object") &&
-                             (typeof netscape.security == "object"));
-// XPCOM, one of two socket implementation providers.
-jsenv.HAS_XPCOM = ((typeof Components == "object") &&
-                   (typeof Components.classes == "object") &&
-                   (typeof Components.interfaces == "object"));
-// Rhino (JS-in-Java), the other socket implementation provider.
-// XXX Bug 435772 - we avoid any Java tests if we have XPCOM so as to avoid
-// the Java plugin instanciating itself to answer our query.
-jsenv.HAS_RHINO = !jsenv.HAS_XPCOM && (typeof defineClass == "function");
-// NSPR Event Queue, i.e. we're living in a browser/GUI-like place.
-jsenv.HAS_NSPR_EVENTQ = (typeof document == "object");
-// Specific XPCOM interfaces that we really care about.
-var ci = jsenv.HAS_XPCOM ? Components.interfaces : {};
-jsenv.HAS_STREAM_PROVIDER = ("nsIStreamProvider" in ci);
-jsenv.HAS_SERVER_SOCKETS = ("nsIServerSocket" in ci);
-jsenv.HAS_THREAD_MANAGER = ("nsIThreadManager" in ci);
-delete ci;
-
 function dumpObject (o, pfx, sep)
 {
     var p;
     var s = "";
 
     sep = (typeof sep == "undefined") ? " = " : sep;
     pfx = (typeof pfx == "undefined") ? "" : pfx;
 
@@ -546,19 +525,16 @@ function renameProperty (obj, oldname, n
 
     obj[newname] = obj[oldname];
     delete obj[oldname];
 
 }
 
 function newObject(contractID, iface)
 {
-    if (!jsenv.HAS_XPCOM)
-        return null;
-
     var rv;
     var cls = Components.classes[contractID];
 
     if (!cls)
         return null;
 
     switch (typeof iface)
     {
@@ -580,19 +556,16 @@ function newObject(contractID, iface)
     }
 
     return rv;
 
 }
 
 function getService(contractID, iface)
 {
-    if (!jsenv.HAS_XPCOM)
-        return null;
-
     var rv;
     var cls = Components.classes[contractID];
 
     if (!cls)
         return null;
 
     switch (typeof iface)
     {
@@ -652,19 +625,16 @@ function getContentDocument(frame)
     {
         // throws exception is contentDocument is gone
         return null;
     }
 }
 
 function getPriv (priv)
 {
-    if (!jsenv.HAS_SECURITYMANAGER)
-        return true;
-
     var rv = true;
 
     try
     {
         netscape.security.PrivilegeManager.enablePrivilege(priv);
     }
     catch (e)
     {
@@ -888,39 +858,32 @@ function randomString(len) {
     for (var i = 0; i < len; i++)
         rv += chars.substr(Math.floor(Math.random() * chars.length), 1);
 
     return rv;
 }
 
 function getStackTrace ()
 {
-
-    if (!jsenv.HAS_XPCOM)
-        return "No stack trace available.";
-
     var frame = Components.stack.caller;
     var str = "<top>";
 
     while (frame)
     {
         var name = frame.name ? frame.name : "[anonymous]";
         str += "\n" + name + "@" + frame.lineNumber;
         frame = frame.caller;
     }
 
     return str;
 
 }
 
 function getInterfaces (cls)
 {
-    if (!jsenv.HAS_XPCOM)
-        return null;
-
     var rv = new Object();
     var e;
 
     for (var i in Components.interfaces)
     {
         try
         {
             var ifc = Components.interfaces[i];
--- a/suite/extensions/irc/js/tests/ircbot.js
+++ b/suite/extensions/irc/js/tests/ircbot.js
@@ -20,18 +20,17 @@ function loadDeps()
     load(LIB_PATH + "http.js");
     load(LIB_PATH + "dcc.js");
     load(LIB_PATH + "irc.js");
     load(LIB_PATH + "irc-debug.js");
     load(LIB_PATH + "message-manager.js");
 
     bot.messageManager = new MessageManager();
 
-    if (!connection_init(LIB_PATH))
-        return false;
+    load(LIB_PATH + "connection-xpcom.js");
 
     return true;
 }
 
 // FIXME: Find somewhere better for these guys. //
 function toUnicode(msg, charsetOrView)
 {
     if (!msg)
@@ -59,19 +58,16 @@ function fromUnicode(msg, charsetOrView)
 
     return bot.messageManager.fromUnicode(msg, charset);
 }
 // FIXME: END //
 
 
 function initStatic()
 {
-    if (jsenv.HAS_RHINO)
-        gc = java.lang.System.gc;
-
     CIRCNetwork.prototype.INITIAL_NICK = "jsbot";
     CIRCNetwork.prototype.INITIAL_NAME = "XPJSBot";
     CIRCNetwork.prototype.INITIAL_DESC = "XPCOM Javascript bot";
     CIRCNetwork.prototype.INITIAL_CHANNEL = "#jsbot";
 
     CIRCNetwork.prototype.stayingPower = true; 
     CIRCNetwork.prototype.on433 = my_433;
     CIRCChannel.prototype.onPrivmsg = my_chan_privmsg;
--- a/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties
+++ b/suite/extensions/irc/locales/en-US/chrome/chatzilla.properties
@@ -1106,17 +1106,16 @@ msg.dccfile.err.notafile = The path spec
 msg.dccfile.err.notreadable = The file specified cannot be read.
 
 # General DCC messages.
 msg.dcc.pending.matches  = "%S pending incoming DCC offers matched.
 msg.dcc.accepted.matches = "%S DCC connections matched.
 msg.dcc.matches.help     = You must specify enough of the user's nickname to uniquely identify the request, or include the request type and even the filename if necessary.
 
 msg.dcc.not.enabled      = DCC is disabled. If you need DCC functionality, you may turn it on from the Preferences window.
-msg.dcc.not.possible     = DCC is unavailable in this version of &brandShortName; - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
 msg.dcc.err.nouser       = Must specify |nickname| or run the command from a query view.
 msg.dcc.err.accept.time  = You cannot use the short form of |/dcc-accept| within the first 10 seconds of receiving a DCC request.
 msg.dcc.err.notdcc       = Must specify |nickname| or run the command from a DCC view.
 
 # /dcc-list words and phrases.
 msg.dcclist.dir.in       = incoming
 msg.dcclist.dir.out      = outgoing (offer)
 msg.dcclist.to           = to
@@ -1166,17 +1165,16 @@ msg.si.size.6 = EiB
 msg.si.speed.0 = B/s
 msg.si.speed.1 = KiB/s
 msg.si.speed.2 = MiB/s
 msg.si.speed.3 = GiB/s
 msg.si.speed.4 = TiB/s
 msg.si.speed.5 = PiB/s
 msg.si.speed.6 = EiB/s
 
-msg.ident.server.not.possible = Ident Server is unavailable in this version of &brandShortName; - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
 msg.ident.error               = Error enabling Ident Server: %S"
 
 msg.host.password = Enter a password for the server %S:
 msg.url.key       = Enter key for url %S:
 
 msg.startup.added    = <%1$S> will now open at startup.
 msg.startup.removed  = <%1$S> will no longer open at startup.
 msg.startup.exists   = <%1$S> is currently opened at startup.
--- a/suite/extensions/irc/xul/content/commands.js
+++ b/suite/extensions/irc/xul/content/commands.js
@@ -4011,18 +4011,16 @@ function cmdFont(e)
             return;
 
         dispatch("font-size", { fontSize: val });
     }
 }
 
 function cmdDCCChat(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     if (!e.nickname && !e.user)
         return display(MSG_DCC_ERR_NOUSER);
 
     var user;
     if (e.nickname)
@@ -4040,18 +4038,16 @@ function cmdDCCChat(e)
             "DCC-CHAT");
     client.munger.getRule(".inline-buttons").enabled = false;
 
     return true;
 }
 
 function cmdDCCClose(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     // If there is no nickname specified, use current view.
     if (!e.nickname)
     {
         // Both DCC chat and file transfers can be aborted like this.
         if (e.sourceObject.TYPE.substr(0, 6) == "IRCDCC")
@@ -4086,18 +4082,16 @@ function cmdDCCClose(e)
     // Oops, couldn't figure the user's requets out, so give them some help.
     display(getMsg(MSG_DCC_ACCEPTED_MATCHES, [list.length]));
     display(MSG_DCC_MATCHES_HELP);
     return true;
 }
 
 function cmdDCCSend(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     const DIRSVC_CID = "@mozilla.org/file/directory_service;1";
     const nsIProperties = Components.interfaces.nsIProperties;
 
     if (!e.nickname && !e.user)
         return display(MSG_DCC_ERR_NOUSER);
@@ -4165,18 +4159,16 @@ function cmdDCCSend(e)
                                               getSISize(c.size), cmd]),
             "DCC-FILE");
     client.munger.getRule(".inline-buttons").enabled = false;
 
     return true;
 }
 
 function cmdDCCList(e) {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     var counts = { pending: 0, connected: 0, failed: 0 };
     var k;
 
     // Get all the DCC sessions.
     var list = client.dcc.getMatches();
@@ -4254,35 +4246,31 @@ function cmdDCCList(e) {
     }
     display(getMsg(MSG_DCCLIST_SUMMARY, [counts.pending, counts.connected,
                                          counts.failed]));
     return true;
 }
 
 function cmdDCCAutoAcceptList(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     var list = e.network.prefs["dcc.autoAccept.list"];
 
     if (list.length == 0)
         display(MSG_DCCACCEPT_DISABLED);
     else
         display(getMsg(MSG_DCCACCEPT_LIST, arraySpeak(list)));
 
     return true;
 }
 
 function cmdDCCAutoAcceptAdd(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     var list = e.network.prefs["dcc.autoAccept.list"];
 
     if (!e.user && e.server)
         e.user = e.server.getUser(e.nickname);
 
@@ -4299,18 +4287,16 @@ function cmdDCCAutoAcceptAdd(e)
         display(getMsg(MSG_DCCACCEPT_ADDERR,
                        e.user ? e.user.unicodeName : e.nickname));
     }
     return true;
 }
 
 function cmdDCCAutoAcceptDel(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     var list = e.network.prefs["dcc.autoAccept.list"];
 
     if (!e.user && e.server)
         e.user = e.server.getUser(e.nickname);
 
@@ -4335,18 +4321,16 @@ function cmdDCCAutoAcceptDel(e)
         display(getMsg(MSG_DCCACCEPT_DELERR,
                        e.user ? e.user.unicodeName : e.nickname));
 
     return true;
 }
 
 function cmdDCCAccept(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     function accept(c)
     {
         if (c.TYPE == "IRCDCCChat")
         {
             if (!c.accept())
@@ -4404,18 +4388,16 @@ function cmdDCCAccept(e)
     // Oops, couldn't figure the user's request out, so give them some help.
     display(getMsg(MSG_DCC_PENDING_MATCHES, [list.length]));
     display(MSG_DCC_MATCHES_HELP);
     return true;
 }
 
 function cmdDCCDecline(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS)
-        return display(MSG_DCC_NOT_POSSIBLE);
     if (!client.prefs["dcc.enabled"])
         return display(MSG_DCC_NOT_ENABLED);
 
     function decline(c)
     {
         // Decline the request passed in...
         c.decline();
         if (c.TYPE == "IRCDCCChat")
--- a/suite/extensions/irc/xul/content/handlers.js
+++ b/suite/extensions/irc/xul/content/handlers.js
@@ -1224,18 +1224,17 @@ function my_showtonet (e)
                     gotoIRCURL(target.url, target.e);
                     target = this.pendingURLs.pop();
                 }
                 delete this.pendingURLs;
             }
 
             // Do this after the JOINs, so they are quicker.
             // This is not time-critical code.
-            if (jsenv.HAS_SERVER_SOCKETS && client.prefs["dcc.enabled"] &&
-                this.prefs["dcc.useServerIP"])
+            if (client.prefs["dcc.enabled"] && this.prefs["dcc.useServerIP"])
             {
                 var delayFn = function(t) {
                     // This is the quickest way to get out host/IP.
                     t.pendingUserhostReply = true;
                     t.primServ.sendData("USERHOST " +
                                         t.primServ.me.encodedName + "\n");
                 };
                 setTimeout(delayFn, 1000 * Math.random(), this);
@@ -1306,18 +1305,18 @@ function my_privmsg(e)
     this.display(e.decodeParam(2), "PRIVMSG", this, e.server.me);
     client.munger.getRule(".mailto").enabled = false;
 }
 
 /* userhost reply */
 CIRCNetwork.prototype.on302 =
 function my_302(e)
 {
-    if (jsenv.HAS_SERVER_SOCKETS && client.prefs["dcc.enabled"] &&
-        this.prefs["dcc.useServerIP"] && ("pendingUserhostReply" in this))
+    if (client.prefs["dcc.enabled"] && this.prefs["dcc.useServerIP"] &&
+        ("pendingUserhostReply" in this))
     {
         var me = new RegExp("^" + this.primServ.me.encodedName + "\\*?=", "i");
         if (e.params[2].match(me))
             client.dcc.addHost(this.primServ.me.host, true);
 
         delete this.pendingUserhostReply;
         return true;
     }
@@ -1980,30 +1979,23 @@ function my_sconnect (e)
     client.munger.getRule(".inline-buttons").enabled = true;
     this.display(getMsg(MSG_CONNECTION_ATTEMPT,
                         [this.getURL(), e.server.getURL(), this.unicodeName,
                          "cancel"]), "INFO");
     client.munger.getRule(".inline-buttons").enabled = false;
 
     if (this.prefs["identd.enabled"])
     {
-        if (jsenv.HAS_SERVER_SOCKETS)
+        try
         {
-            try
-            {
-                client.ident.addNetwork(this, e.server);
-            }
-            catch (ex)
-            {
-                display(getMsg(MSG_IDENT_ERROR, formatException(ex)), MT_ERROR);
-            }
+            client.ident.addNetwork(this, e.server);
         }
-        else
+        catch (ex)
         {
-            display(MSG_IDENT_SERVER_NOT_POSSIBLE, MT_WARN);
+            display(getMsg(MSG_IDENT_ERROR, formatException(ex)), MT_ERROR);
         }
     }
 
     this.NICK_RETRIES = this.prefs["nicknameList"].length + 3;
 
     // When connection begins, autoperform has not been sent
     this.autoPerformSent = false;
 }
@@ -3084,17 +3076,17 @@ function onDCCAutoAcceptTimeout(o, folde
         o.accept(dest);
         display(getMsg(MSG_DCCFILE_ACCEPTED, o._getParams()), "DCC-FILE");
     }
 }
 
 CIRCUser.prototype.onDCCChat =
 function my_dccchat(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS || !client.prefs["dcc.enabled"])
+    if (!client.prefs["dcc.enabled"])
         return;
 
     var u = client.dcc.addUser(e.user, e.host);
     var c = client.dcc.addChat(u, e.port);
 
     var str = MSG_DCCCHAT_GOT_REQUEST;
     var cmds = getMsg(MSG_DCC_COMMAND_ACCEPT, "dcc-accept " + c.id) + " " +
                getMsg(MSG_DCC_COMMAND_DECLINE, "dcc-decline " + c.id);
@@ -3128,17 +3120,17 @@ function my_dccchat(e)
     e.set = "dcc-chat";
     e.destObject = c;
     e.destMethod = "onGotRequest";
 }
 
 CIRCUser.prototype.onDCCSend =
 function my_dccsend(e)
 {
-    if (!jsenv.HAS_SERVER_SOCKETS || !client.prefs["dcc.enabled"])
+    if (!client.prefs["dcc.enabled"])
         return;
 
     var u = client.dcc.addUser(e.user, e.host);
     var f = client.dcc.addFileTransfer(u, e.port, e.file, e.size);
 
     var str = MSG_DCCFILE_GOT_REQUEST;
     var cmds = getMsg(MSG_DCC_COMMAND_ACCEPT, "dcc-accept " + f.id) + " " +
                getMsg(MSG_DCC_COMMAND_DECLINE, "dcc-decline " + f.id);