Bug 1586264 - Only import the used objects with ChromeUtils.import. r=aleca
authorPatrick Cloke <clokep@gmail.com>
Fri, 04 Oct 2019 09:13:58 -0400
changeset 37104 a094c4ec89ae01e6b71060ccbc7fae32e93145f6
parent 37103 1da5ee1ef0eac10558e3705dfcda0acf746f1a6d
child 37105 4e21ee135e9199761ae565612ba388b626a8df12
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersaleca
bugs1586264
Bug 1586264 - Only import the used objects with ChromeUtils.import. r=aleca
chat/components/src/imCommands.js
chat/components/src/imContacts.js
chat/components/src/imConversations.js
chat/components/src/smileProtocolHandler.js
chat/protocols/facebook/facebook.js
chat/protocols/gtalk/gtalk.js
chat/protocols/irc/irc.js
chat/protocols/jsTest/jsTestProtocol.js
chat/protocols/matrix/matrix.js
chat/protocols/odnoklassniki/odnoklassniki.js
chat/protocols/skype/skype.js
chat/protocols/twitter/twitter.js
chat/protocols/xmpp/test/test_dnsSrv.js
chat/protocols/xmpp/test/test_parseJidAndNormalization.js
chat/protocols/xmpp/test/test_xmppXml.js
chat/protocols/xmpp/xmpp.js
chat/protocols/yahoo/yahoo.js
--- a/chat/components/src/imCommands.js
+++ b/chat/components/src/imCommands.js
@@ -1,24 +1,16 @@
 /* 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/. */
 
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/commands.properties")
 );
 
 function CommandsService() {}
 CommandsService.prototype = {
   initCommands() {
--- a/chat/components/src/imContacts.js
+++ b/chat/components/src/imContacts.js
@@ -1,24 +1,16 @@
 /* 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/. */
 
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
+var { XPCOMUtils, executeSoon, ClassInfo, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/contacts.properties")
 );
 
 var gDBConnection = null;
 
 function executeAsyncThenFinalize(statement) {
--- a/chat/components/src/imConversations.js
+++ b/chat/components/src/imConversations.js
@@ -1,37 +1,18 @@
 /* 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/. */
 
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
 var { Status } = ChromeUtils.import("resource:///modules/imStatusUtils.jsm");
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
+var { XPCOMUtils, nsSimpleEnumerator, ClassInfo } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { Message } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 
 var gLastUIConvId = 0;
 var gLastPrplConvId = 0;
 
 XPCOMUtils.defineLazyGetter(this, "bundle", () =>
   Services.strings.createBundle("chrome://chat/locale/conversations.properties")
 );
 
--- a/chat/components/src/smileProtocolHandler.js
+++ b/chat/components/src/smileProtocolHandler.js
@@ -1,23 +1,19 @@
 /* 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/. */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
 );
-var {
-  smileImMarkup,
-  smileTextNode,
-  smileString,
-  getSmileRealURI,
-  getSmileyList,
-} = ChromeUtils.import("resource:///modules/imSmileys.jsm");
+var { getSmileRealURI } = ChromeUtils.import(
+  "resource:///modules/imSmileys.jsm"
+);
 
 var kSmileRegexp = /^smile:\/\//;
 
 function smileProtocolHandler() {}
 
 smileProtocolHandler.prototype = {
   scheme: "smile",
   defaultPort: -1,
--- a/chat/protocols/facebook/facebook.js
+++ b/chat/protocols/facebook/facebook.js
@@ -1,35 +1,18 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { GenericAccountPrototype, GenericProtocolPrototype } = ChromeUtils.import(
+  "resource:///modules/jsProtoHelper.jsm"
+);
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/facebook.properties")
 );
 
 function FacebookAccount(aProtoInstance, aImAccount) {
   this._init(aProtoInstance, aImAccount);
 }
--- a/chat/protocols/gtalk/gtalk.js
+++ b/chat/protocols/gtalk/gtalk.js
@@ -1,47 +1,25 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
-var {
-  XMPPConversationPrototype,
-  XMPPMUCConversationPrototype,
-  XMPPAccountBuddyPrototype,
-  XMPPAccountPrototype,
-} = ChromeUtils.import("resource:///modules/xmpp.jsm");
-var { XMPPSession, XMPPDefaultResource } = ChromeUtils.import(
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { GenericProtocolPrototype } = ChromeUtils.import(
+  "resource:///modules/jsProtoHelper.jsm"
+);
+var { XMPPAccountPrototype } = ChromeUtils.import(
+  "resource:///modules/xmpp.jsm"
+);
+var { XMPPSession } = ChromeUtils.import(
   "resource:///modules/xmpp-session.jsm"
 );
-var { Stanza, XMPPParser, SupportedFeatures } = ChromeUtils.import(
-  "resource:///modules/xmpp-xml.jsm"
-);
+var { Stanza } = ChromeUtils.import("resource:///modules/xmpp-xml.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/xmpp.properties")
 );
 
 // PlainFullBindAuth is an authentication mechanism that works like
 // the standard PLAIN mechanism but adds a client-uses-full-bind-result
 // attribute to the auth stanza to tell the Google Talk servers that we
--- a/chat/protocols/irc/irc.js
+++ b/chat/protocols/irc/irc.js
@@ -8,34 +8,28 @@ var {
   EmptyEnumerator,
   setTimeout,
   executeSoon,
   l10nHelper,
   XPCOMUtils,
   nsSimpleEnumerator,
 } = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
-var {
-  _,
-  ctcpFormatToText,
-  ctcpFormatToHTML,
-  conversationErrorMessage,
-  kListRefreshInterval,
-} = ChromeUtils.import("resource:///modules/ircUtils.jsm");
+var { _, ctcpFormatToHTML, kListRefreshInterval } = ChromeUtils.import(
+  "resource:///modules/ircUtils.jsm"
+);
 var { ircHandlers } = ChromeUtils.import("resource:///modules/ircHandlers.jsm");
 var {
   GenericAccountPrototype,
   GenericAccountBuddyPrototype,
   GenericConvIMPrototype,
   GenericConvChatPrototype,
   GenericConvChatBuddyPrototype,
   GenericConversationPrototype,
-  GenericMessagePrototype,
   GenericProtocolPrototype,
-  Message,
   TooltipInfo,
 } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 var { NormalizedMap } = ChromeUtils.import(
   "resource:///modules/NormalizedMap.jsm"
 );
 var { Socket } = ChromeUtils.import("resource:///modules/socket.jsm");
 
 ChromeUtils.defineModuleGetter(
--- a/chat/protocols/jsTest/jsTestProtocol.js
+++ b/chat/protocols/jsTest/jsTestProtocol.js
@@ -1,34 +1,19 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
+var { XPCOMUtils, setTimeout } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
 var {
   GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
   GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
   GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
 } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 
 function Conversation(aAccount) {
   this._init(aAccount);
 }
 Conversation.prototype = {
   __proto__: GenericConvIMPrototype,
   _disconnected: false,
--- a/chat/protocols/matrix/matrix.js
+++ b/chat/protocols/matrix/matrix.js
@@ -1,34 +1,20 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
+var { XPCOMUtils, nsSimpleEnumerator, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
 var {
   GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
   GenericConvChatPrototype,
   GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
   GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
 } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/matrix.properties")
 );
 
 ChromeUtils.defineModuleGetter(
   this,
--- a/chat/protocols/odnoklassniki/odnoklassniki.js
+++ b/chat/protocols/odnoklassniki/odnoklassniki.js
@@ -1,41 +1,21 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
-var {
-  XMPPConversationPrototype,
-  XMPPMUCConversationPrototype,
-  XMPPAccountBuddyPrototype,
-  XMPPAccountPrototype,
-} = ChromeUtils.import("resource:///modules/xmpp.jsm");
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { GenericProtocolPrototype } = ChromeUtils.import(
+  "resource:///modules/jsProtoHelper.jsm"
+);
+var { XMPPAccountPrototype } = ChromeUtils.import(
+  "resource:///modules/xmpp.jsm"
+);
 var { XMPPSession, XMPPDefaultResource } = ChromeUtils.import(
   "resource:///modules/xmpp-session.jsm"
 );
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/xmpp.properties")
 );
 
--- a/chat/protocols/skype/skype.js
+++ b/chat/protocols/skype/skype.js
@@ -1,41 +1,31 @@
 /* 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/. */
 
 var { httpRequest } = ChromeUtils.import("resource://gre/modules/Http.jsm");
-var {
-  copyBytes,
-  ArrayBufferToBytes,
-  BytesToArrayBuffer,
-  StringToBytes,
-  StringToArrayBuffer,
-  ArrayBufferToString,
-  ArrayBufferToHexString,
-} = ChromeUtils.import("resource:///modules/ArrayBufferUtils.jsm");
+var { StringToArrayBuffer } = ChromeUtils.import(
+  "resource:///modules/ArrayBufferUtils.jsm"
+);
 var { bigInt } = ChromeUtils.import("resource:///modules/BigInteger.jsm");
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
 var {
-  EmptyEnumerator,
   XPCOMUtils,
+  setTimeout,
   clearTimeout,
   l10nHelper,
   nsSimpleEnumerator,
+  EmptyEnumerator,
 } = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
 var {
   GenericAccountPrototype,
   GenericAccountBuddyPrototype,
   GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
   GenericProtocolPrototype,
-  Message,
   TooltipInfo,
 } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 
 // Constants used by the login process. This emulates a captured session using
 // official means.
 var kLockAndKeyAppId = "msmsgs@msnmsgr.com";
 var kLockAndKeySecret = "Q1P7W2E4J9R8U3S5";
 var kClientId = "578134";
--- a/chat/protocols/twitter/twitter.js
+++ b/chat/protocols/twitter/twitter.js
@@ -5,33 +5,29 @@
 var { httpRequest, percentEncode } = ChromeUtils.import(
   "resource://gre/modules/Http.jsm"
 );
 var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
 var {
   XPCOMUtils,
   setTimeout,
   clearTimeout,
-  executeSoon,
   nsSimpleEnumerator,
-  EmptyEnumerator,
   ClassInfo,
   l10nHelper,
   initLogModule,
 } = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
 var {
   GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
   GenericConvIMPrototype,
   GenericConvChatPrototype,
   GenericConvChatBuddyPrototype,
   GenericConversationPrototype,
   GenericMessagePrototype,
   GenericProtocolPrototype,
-  Message,
   TooltipInfo,
 } = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
 var { twttr } = ChromeUtils.import("resource:///modules/twitter-text.jsm");
 
 var NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/twitter.properties")
--- a/chat/protocols/xmpp/test/test_dnsSrv.js
+++ b/chat/protocols/xmpp/test/test_dnsSrv.js
@@ -1,29 +1,26 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { XMPPAccountPrototype } = ChromeUtils.import(
+  "resource:///modules/xmpp.jsm"
+);
+var { XMPPSession } = ChromeUtils.import(
+  "resource:///modules/xmpp-session.jsm"
+);
 
 var dns = {};
 Services.scriptloader.loadSubScript("resource:///modules/DNS.jsm", dns);
 
-var xmpp = {};
-Services.scriptloader.loadSubScript("resource:///components/xmpp.js", xmpp);
-
-var xmppSession = {};
-Services.scriptloader.loadSubScript(
-  "resource:///modules/xmpp-session.jsm",
-  xmppSession
-);
-
 function FakeXMPPSession() {}
 FakeXMPPSession.prototype = {
-  __proto__: xmppSession.XMPPSession.prototype,
-  _account: { __proto__: xmpp.XMPPAccount.prototype },
+  __proto__: XMPPSession.prototype,
+  _account: { __proto__: XMPPAccountPrototype },
   _host: null,
   _port: 0,
   connect(
     aHostOrigin,
     aPortOrigin,
     aSecurity,
     aProxy,
     aHost = aHostOrigin,
@@ -84,29 +81,29 @@ var TEST_DATA = [
     input: [],
     output: [],
     isConnectNextRecord: false,
   },
 
   // Tests XMPP is not supported if the result is one record with target ".".
   {
     input: [new dns.SRVRecord(5, 30, ".", 5222)],
-    output: xmppSession.XMPPSession.prototype.SRV_ERROR_XMPP_NOT_SUPPORTED,
+    output: XMPPSession.prototype.SRV_ERROR_XMPP_NOT_SUPPORTED,
     isConnectNextRecord: false,
   },
   {
     input: [new dns.SRVRecord(5, 30, "xmpp.instantbird.com", 5222)],
     output: [new dns.SRVRecord(5, 30, "xmpp.instantbird.com", 5222)],
     isConnectNextRecord: true,
   },
 
   // Tests error happened during SRV lookup.
   {
     input: -1,
-    output: xmppSession.XMPPSession.prototype.SRV_ERROR_LOOKUP_FAILED,
+    output: XMPPSession.prototype.SRV_ERROR_LOOKUP_FAILED,
     isConnectNextRecord: false,
   },
 ];
 
 function run_test() {
   for (let currentQuery of TEST_DATA) {
     let session = new FakeXMPPSession();
     try {
--- a/chat/protocols/xmpp/test/test_parseJidAndNormalization.js
+++ b/chat/protocols/xmpp/test/test_parseJidAndNormalization.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var xmpp = {};
-Services.scriptloader.loadSubScript("resource:///components/xmpp.js", xmpp);
+var { XMPPAccountPrototype } = ChromeUtils.import(
+  "resource:///modules/xmpp.jsm"
+);
 
 var TEST_DATA = {
   "abdelrhman@instantbird": {
     node: "abdelrhman",
     domain: "instantbird",
     jid: "abdelrhman@instantbird",
     normalized: "abdelrhman@instantbird",
   },
@@ -59,41 +59,41 @@ var TEST_DATA = {
     domain: "instantbird",
     jid: "instantbird",
     normalized: "instantbird",
   },
 };
 
 function testParseJID() {
   for (let currentJID in TEST_DATA) {
-    let jid = xmpp.XMPPAccount.prototype._parseJID(currentJID);
+    let jid = XMPPAccountPrototype._parseJID(currentJID);
     equal(jid.node, TEST_DATA[currentJID].node);
     equal(jid.domain, TEST_DATA[currentJID].domain);
     equal(jid.resource, TEST_DATA[currentJID].resource);
     equal(jid.jid, TEST_DATA[currentJID].jid);
   }
 
   run_next_test();
 }
 
 function testNormalize() {
   for (let currentJID in TEST_DATA) {
     equal(
-      xmpp.XMPPAccount.prototype.normalize(currentJID),
+      XMPPAccountPrototype.normalize(currentJID),
       TEST_DATA[currentJID].normalized
     );
   }
 
   run_next_test();
 }
 
 function testNormalizeFullJid() {
   for (let currentJID in TEST_DATA) {
     equal(
-      xmpp.XMPPAccount.prototype.normalizeFullJid(currentJID),
+      XMPPAccountPrototype.normalizeFullJid(currentJID),
       TEST_DATA[currentJID].jid
     );
   }
 
   run_next_test();
 }
 
 function run_test() {
--- a/chat/protocols/xmpp/test/test_xmppXml.js
+++ b/chat/protocols/xmpp/test/test_xmppXml.js
@@ -1,39 +1,34 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var xmppXml = {};
-Services.scriptloader.loadSubScript(
-  "resource:///modules/xmpp-xml.jsm",
-  xmppXml
-);
+var { Stanza } = ChromeUtils.import("resource:///modules/xmpp-xml.jsm");
 
 var TEST_DATA = [
   {
     input: {
       name: "message",
-      namespace: xmppXml.NS.client,
+      namespace: Stanza.NS.client,
       attributes: {
         jid: "user@domain",
         type: null,
       },
       data: [],
     },
     XmlOutput: '<message xmlns="jabber:client" jid="user@domain"/>',
     stringOutput: '<message xmlns="jabber:client" jid="user@domain"/>\n',
     isError: false,
     description: "Ignore attribute with null value",
   },
   {
     input: {
       name: "message",
-      namespace: xmppXml.NS.client,
+      namespace: Stanza.NS.client,
       attributes: {
         jid: "user@domain",
         type: undefined,
       },
       data: [],
     },
     XmlOutput: '<message xmlns="jabber:client" jid="user@domain"/>',
     stringOutput: '<message xmlns="jabber:client" jid="user@domain"/>\n',
@@ -74,17 +69,17 @@ var TEST_DATA = [
     isError: false,
     description: "Node with text content",
   },
 ];
 
 function testXMLNode() {
   for (let current of TEST_DATA) {
     try {
-      let result = xmppXml.Stanza.node(
+      let result = Stanza.node(
         current.input.name,
         current.input.namespace,
         current.input.attributes,
         current.input.data
       );
       equal(result.getXML(), current.XmlOutput, current.description);
       equal(
         result.convertToString(),
--- a/chat/protocols/xmpp/xmpp.js
+++ b/chat/protocols/xmpp/xmpp.js
@@ -1,43 +1,20 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
-var {
-  XMPPConversationPrototype,
-  XMPPMUCConversationPrototype,
-  XMPPAccountBuddyPrototype,
-  XMPPAccountPrototype,
-} = ChromeUtils.import("resource:///modules/xmpp.jsm");
-var { XMPPSession, XMPPDefaultResource } = ChromeUtils.import(
-  "resource:///modules/xmpp-session.jsm"
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { GenericProtocolPrototype } = ChromeUtils.import(
+  "resource:///modules/jsProtoHelper.jsm"
+);
+var { XMPPAccountPrototype } = ChromeUtils.import(
+  "resource:///modules/xmpp.jsm"
 );
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/xmpp.properties")
 );
 
 function XMPPAccount(aProtoInstance, aImAccount) {
   this._init(aProtoInstance, aImAccount);
--- a/chat/protocols/yahoo/yahoo.js
+++ b/chat/protocols/yahoo/yahoo.js
@@ -1,35 +1,18 @@
 /* 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/. */
 
-var {
-  XPCOMUtils,
-  setTimeout,
-  clearTimeout,
-  executeSoon,
-  nsSimpleEnumerator,
-  EmptyEnumerator,
-  ClassInfo,
-  l10nHelper,
-  initLogModule,
-} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm");
-var {
-  GenericAccountPrototype,
-  GenericAccountBuddyPrototype,
-  GenericConvIMPrototype,
-  GenericConvChatPrototype,
-  GenericConvChatBuddyPrototype,
-  GenericConversationPrototype,
-  GenericMessagePrototype,
-  GenericProtocolPrototype,
-  Message,
-  TooltipInfo,
-} = ChromeUtils.import("resource:///modules/jsProtoHelper.jsm");
+var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
+  "resource:///modules/imXPCOMUtils.jsm"
+);
+var { GenericAccountPrototype, GenericProtocolPrototype } = ChromeUtils.import(
+  "resource:///modules/jsProtoHelper.jsm"
+);
 
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/yahoo.properties")
 );
 
 function YahooAccount(aProtoInstance, aImAccount) {
   this._init(aProtoInstance, aImAccount);
 }