diff --git a/mail/components/im/IMIncomingServer.jsm b/mail/components/im/IMIncomingServer.sys.mjs similarity index 98% rename from mail/components/im/IMIncomingServer.jsm rename to mail/components/im/IMIncomingServer.sys.mjs index 602ed24a9c..aea800cec7 100644 --- a/mail/components/im/IMIncomingServer.jsm +++ b/mail/components/im/IMIncomingServer.sys.mjs @@ -2,13 +2,9 @@ * 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 EXPORTED_SYMBOLS = ["IMIncomingServer"]; +import { IMServices } from "resource:///modules/IMServices.sys.mjs"; -var { IMServices } = ChromeUtils.importESModule( - "resource:///modules/IMServices.sys.mjs" -); - -function IMIncomingServer() {} +export function IMIncomingServer() {} IMIncomingServer.prototype = { get wrappedJSObject() { diff --git a/mail/components/im/IMProtocolInfo.jsm b/mail/components/im/IMProtocolInfo.sys.mjs similarity index 94% rename from mail/components/im/IMProtocolInfo.jsm rename to mail/components/im/IMProtocolInfo.sys.mjs index 31ca76197b..975a3a4a0a 100644 --- a/mail/components/im/IMProtocolInfo.jsm +++ b/mail/components/im/IMProtocolInfo.sys.mjs @@ -2,9 +2,7 @@ * 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 EXPORTED_SYMBOLS = ["IMProtocolInfo"]; - -function IMProtocolInfo() {} +export function IMProtocolInfo() {} IMProtocolInfo.prototype = { defaultLocalPath: null, diff --git a/mail/components/im/components.conf b/mail/components/im/components.conf index c3153690f7..2d379db965 100644 --- a/mail/components/im/components.conf +++ b/mail/components/im/components.conf @@ -8,13 +8,13 @@ Classes = [ { 'cid': '{13118758-dad2-418c-a03d-1acbfed0cd01}', 'contract_ids': ['@mozilla.org/messenger/protocol/info;1?type=im'], - 'jsm': 'resource:///modules/IMProtocolInfo.jsm', + 'esModule': 'resource:///modules/IMProtocolInfo.sys.mjs', 'constructor': 'IMProtocolInfo', }, { 'cid': '{9dd7f36b-5960-4f0a-8789-f5f516bd083d}', 'contract_ids': ['@mozilla.org/messenger/server;1?type=im'], - 'jsm': 'resource:///modules/IMIncomingServer.jsm', + 'esModule': 'resource:///modules/IMIncomingServer.sys.mjs', 'constructor': 'IMIncomingServer', }, ] diff --git a/mail/components/im/content/addbuddy.js b/mail/components/im/content/addbuddy.js index 3671cb662c..b3d31b523a 100644 --- a/mail/components/im/content/addbuddy.js +++ b/mail/components/im/content/addbuddy.js @@ -5,7 +5,9 @@ var { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" ); -var { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +var { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); var addBuddy = { onload() { diff --git a/mail/components/im/content/am-im.js b/mail/components/im/content/am-im.js index de5c8a9794..20b653e5e2 100644 --- a/mail/components/im/content/am-im.js +++ b/mail/components/im/content/am-im.js @@ -5,16 +5,14 @@ // chat/content/imAccountOptionsHelper.js /* globals accountOptionsHelper */ +const { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); ChromeUtils.defineESModuleGetters(this, { + ChatEncryption: "resource:///modules/ChatEncryption.sys.mjs", OTR: "resource:///modules/OTR.sys.mjs", OTRUI: "resource:///modules/OTRUI.sys.mjs", }); -const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); -ChromeUtils.defineModuleGetter( - this, - "ChatEncryption", - "resource:///modules/ChatEncryption.jsm" -); var autoJoinPref = "autoJoin"; diff --git a/mail/components/im/content/chat-contact.js b/mail/components/im/content/chat-contact.js index 8f7ed4ffb4..f9e38cc5ed 100644 --- a/mail/components/im/content/chat-contact.js +++ b/mail/components/im/content/chat-contact.js @@ -11,7 +11,9 @@ const { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" ); - const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); + const { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" + ); /** * The MozChatContactRichlistitem widget displays contact information about user under diff --git a/mail/components/im/content/chat-conversation-info.js b/mail/components/im/content/chat-conversation-info.js index 12a1fc1c02..69eada043e 100644 --- a/mail/components/im/content/chat-conversation-info.js +++ b/mail/components/im/content/chat-conversation-info.js @@ -8,7 +8,9 @@ // Wrap in a block to prevent leaking to window scope. { - const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); + const { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" + ); ChromeUtils.defineESModuleGetters(this, { OTR: "resource:///modules/OTR.sys.mjs", diff --git a/mail/components/im/content/chat-conversation.js b/mail/components/im/content/chat-conversation.js index 3c85dfa21d..0e755b49c5 100644 --- a/mail/components/im/content/chat-conversation.js +++ b/mail/components/im/content/chat-conversation.js @@ -40,11 +40,9 @@ constructor() { super(); - ChromeUtils.defineModuleGetter( - this, - "ChatEncryption", - "resource:///modules/ChatEncryption.jsm" - ); + ChromeUtils.defineESModuleGetters(this, { + ChatEncryption: "resource:///modules/ChatEncryption.sys.mjs", + }); this.observer = { // @see {nsIObserver} diff --git a/mail/components/im/content/chat-imconv.js b/mail/components/im/content/chat-imconv.js index 15207a30be..a7662faef6 100644 --- a/mail/components/im/content/chat-imconv.js +++ b/mail/components/im/content/chat-imconv.js @@ -14,7 +14,9 @@ const { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" ); - const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); + const { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" + ); /** * The MozChatConvRichlistitem widget displays opened conversation information from the diff --git a/mail/components/im/content/chat-messenger.js b/mail/components/im/content/chat-messenger.js index 3f9a863d46..c05305d11a 100644 --- a/mail/components/im/content/chat-messenger.js +++ b/mail/components/im/content/chat-messenger.js @@ -9,8 +9,8 @@ /* globals MailToolboxCustomizeDone, openIMAccountMgr, PROTO_TREE_VIEW, Status, statusSelector, ZoomManager, gSpacesToolbar */ -var { Notifications } = ChromeUtils.import( - "resource:///modules/chatNotifications.jsm" +var { Notifications } = ChromeUtils.importESModule( + "resource:///modules/chatNotifications.sys.mjs" ); var { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" @@ -23,13 +23,9 @@ var { InlineSpellChecker } = ChromeUtils.importESModule( ); ChromeUtils.defineESModuleGetters(this, { + ChatEncryption: "resource:///modules/ChatEncryption.sys.mjs", OTRUI: "resource:///modules/OTRUI.sys.mjs", }); -ChromeUtils.defineModuleGetter( - this, - "ChatEncryption", - "resource:///modules/ChatEncryption.jsm" -); var gChatSpellChecker; var gRangeParent; @@ -1859,9 +1855,11 @@ var chatHandler = { document.getElementById("conversationsGroup").sortComparator = (a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()); - const { allContacts, onlineContacts, ChatCore } = ChromeUtils.import( - "resource:///modules/chatHandler.jsm" - ); + const { + allContacts, + onlineContacts, + ChatCore, + } = ChromeUtils.importESModule("resource:///modules/chatHandler.sys.mjs"); this.allContacts = allContacts; this.onlineContacts = onlineContacts; this.ChatCore = ChatCore; diff --git a/mail/components/im/content/imAccountWizard.js b/mail/components/im/content/imAccountWizard.js index ec748b8ea3..7d5a2eab87 100644 --- a/mail/components/im/content/imAccountWizard.js +++ b/mail/components/im/content/imAccountWizard.js @@ -11,7 +11,9 @@ var { IMServices } = ChromeUtils.importESModule( var { MailServices } = ChromeUtils.import( "resource:///modules/MailServices.jsm" ); -var { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +var { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); var PREF_EXTENSIONS_GETMOREPROTOCOLSURL = "extensions.getMoreProtocolsURL"; diff --git a/mail/components/im/content/imStatusSelector.js b/mail/components/im/content/imStatusSelector.js index beff2a61c8..69bbc2776a 100644 --- a/mail/components/im/content/imStatusSelector.js +++ b/mail/components/im/content/imStatusSelector.js @@ -8,7 +8,9 @@ var { Status } = ChromeUtils.importESModule( var { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" ); -var { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +var { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); var statusSelector = { observe(aSubject, aTopic, aMsg) { diff --git a/mail/components/im/content/joinchat.js b/mail/components/im/content/joinchat.js index 696bb25215..ae4029eb5a 100644 --- a/mail/components/im/content/joinchat.js +++ b/mail/components/im/content/joinchat.js @@ -5,7 +5,9 @@ var { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" ); -var { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +var { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); var autoJoinPref = "autoJoin"; diff --git a/mail/components/im/modules/ChatEncryption.jsm b/mail/components/im/modules/ChatEncryption.sys.mjs similarity index 98% rename from mail/components/im/modules/ChatEncryption.jsm rename to mail/components/im/modules/ChatEncryption.sys.mjs index 2ce472d7f8..1b78d1f581 100644 --- a/mail/components/im/modules/ChatEncryption.jsm +++ b/mail/components/im/modules/ChatEncryption.sys.mjs @@ -2,8 +2,6 @@ * 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/. */ -const EXPORTED_SYMBOLS = ["ChatEncryption"]; - const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); @@ -28,7 +26,7 @@ const STATE_STRING = { [Ci.prplIConversation.ENCRYPTION_TRUSTED]: "private", }; -const ChatEncryption = { +export const ChatEncryption = { /** * If OTR is enabled. * diff --git a/mail/components/im/modules/GlodaIMSearcher.jsm b/mail/components/im/modules/GlodaIMSearcher.sys.mjs similarity index 99% rename from mail/components/im/modules/GlodaIMSearcher.jsm rename to mail/components/im/modules/GlodaIMSearcher.sys.mjs index bdaebe3b66..f97519ddea 100644 --- a/mail/components/im/modules/GlodaIMSearcher.jsm +++ b/mail/components/im/modules/GlodaIMSearcher.sys.mjs @@ -2,8 +2,6 @@ * 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/. */ -const EXPORTED_SYMBOLS = ["GlodaIMSearcher"]; - const { Gloda } = ChromeUtils.import( "resource:///modules/gloda/GlodaPublic.jsm" ); @@ -192,7 +190,7 @@ function scoreOffsets(aMessage, aContext) { * mechanism to explicitly score the IM conversations given the search context in * addition to the more generic score adjusting rules. */ -function GlodaIMSearcher(aListener, aSearchString, aAndTerms) { +export function GlodaIMSearcher(aListener, aSearchString, aAndTerms) { this.listener = aListener; this.searchString = aSearchString; @@ -204,6 +202,7 @@ function GlodaIMSearcher(aListener, aSearchString, aAndTerms) { this.scores = null; } + GlodaIMSearcher.prototype = { /** * Number of messages to retrieve initially. diff --git a/mail/components/im/modules/chatHandler.jsm b/mail/components/im/modules/chatHandler.sys.mjs similarity index 93% rename from mail/components/im/modules/chatHandler.jsm rename to mail/components/im/modules/chatHandler.sys.mjs index c462900821..939c34e27f 100644 --- a/mail/components/im/modules/chatHandler.jsm +++ b/mail/components/im/modules/chatHandler.sys.mjs @@ -2,19 +2,16 @@ * 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/. */ -const EXPORTED_SYMBOLS = ["allContacts", "onlineContacts", "ChatCore"]; +import { IMServices } from "resource:///modules/IMServices.sys.mjs"; -const { IMServices } = ChromeUtils.importESModule( - "resource:///modules/IMServices.sys.mjs" -); const { MailServices } = ChromeUtils.import( "resource:///modules/MailServices.jsm" ); -var allContacts = {}; -var onlineContacts = {}; +export var allContacts = {}; +export var onlineContacts = {}; -var ChatCore = { +export var ChatCore = { initialized: false, _initializing: false, init() { diff --git a/mail/components/im/modules/chatIcons.jsm b/mail/components/im/modules/chatIcons.sys.mjs similarity index 98% rename from mail/components/im/modules/chatIcons.jsm rename to mail/components/im/modules/chatIcons.sys.mjs index 60b36c3e54..d5e716a142 100644 --- a/mail/components/im/modules/chatIcons.jsm +++ b/mail/components/im/modules/chatIcons.sys.mjs @@ -2,9 +2,7 @@ * 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/. */ -const EXPORTED_SYMBOLS = ["ChatIcons"]; - -var ChatIcons = { +export var ChatIcons = { /** * Get the icon URI for the given protocol. * diff --git a/mail/components/im/modules/chatNotifications.jsm b/mail/components/im/modules/chatNotifications.sys.mjs similarity index 97% rename from mail/components/im/modules/chatNotifications.jsm rename to mail/components/im/modules/chatNotifications.sys.mjs index a61a3425a5..e699d447e8 100644 --- a/mail/components/im/modules/chatNotifications.jsm +++ b/mail/components/im/modules/chatNotifications.sys.mjs @@ -2,11 +2,8 @@ * 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/. */ -const EXPORTED_SYMBOLS = ["Notifications"]; +import { IMServices } from "resource:///modules/IMServices.sys.mjs"; -const { IMServices } = ChromeUtils.importESModule( - "resource:///modules/IMServices.sys.mjs" -); const { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" ); @@ -16,13 +13,13 @@ const { PluralForm } = ChromeUtils.import( const { clearTimeout, setTimeout } = ChromeUtils.import( "resource://gre/modules/Timer.jsm" ); -const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +import { ChatIcons } from "resource:///modules/chatIcons.sys.mjs"; // Time in seconds: it is the minimum time of inactivity // needed to show the bundled notification. var kTimeToWaitForMoreMsgs = 3; -var Notifications = { +export var Notifications = { get ellipsis() { let ellipsis = "[\u2026]"; diff --git a/mail/components/im/modules/index_im.jsm b/mail/components/im/modules/index_im.sys.mjs similarity index 99% rename from mail/components/im/modules/index_im.jsm rename to mail/components/im/modules/index_im.sys.mjs index fe9d31d4cf..0be468fe9b 100644 --- a/mail/components/im/modules/index_im.jsm +++ b/mail/components/im/modules/index_im.sys.mjs @@ -2,8 +2,6 @@ * 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/. */ -const EXPORTED_SYMBOLS = []; - var CC = Components.Constructor; const { Gloda } = ChromeUtils.import( @@ -18,15 +16,11 @@ const { GlodaConstants } = ChromeUtils.import( const { GlodaIndexer, IndexingJob } = ChromeUtils.import( "resource:///modules/gloda/GlodaIndexer.jsm" ); -const { IMServices } = ChromeUtils.importESModule( - "resource:///modules/IMServices.sys.mjs" -); +import { IMServices } from "resource:///modules/IMServices.sys.mjs"; const { MailServices } = ChromeUtils.import( "resource:///modules/MailServices.jsm" ); -const { FileUtils } = ChromeUtils.importESModule( - "resource://gre/modules/FileUtils.sys.mjs" -); +import { FileUtils } from "resource://gre/modules/FileUtils.sys.mjs"; const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); diff --git a/mail/components/im/moz.build b/mail/components/im/moz.build index 2ce1328c3f..3780532058 100644 --- a/mail/components/im/moz.build +++ b/mail/components/im/moz.build @@ -4,18 +4,18 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. EXTRA_JS_MODULES += [ - "IMIncomingServer.jsm", - "IMProtocolInfo.jsm", - "modules/ChatEncryption.jsm", - "modules/chatHandler.jsm", - "modules/chatIcons.jsm", - "modules/chatNotifications.jsm", - "modules/GlodaIMSearcher.jsm", - "modules/index_im.jsm", + "IMIncomingServer.sys.mjs", + "IMProtocolInfo.sys.mjs", + "modules/ChatEncryption.sys.mjs", + "modules/chatHandler.sys.mjs", + "modules/chatIcons.sys.mjs", + "modules/chatNotifications.sys.mjs", + "modules/GlodaIMSearcher.sys.mjs", + "modules/index_im.sys.mjs", ] TESTING_JS_MODULES += [ - "test/TestProtocol.jsm", + "test/TestProtocol.sys.mjs", ] JAR_MANIFESTS += ["jar.mn"] diff --git a/mail/components/im/test/TestProtocol.jsm b/mail/components/im/test/TestProtocol.sys.mjs similarity index 94% rename from mail/components/im/test/TestProtocol.jsm rename to mail/components/im/test/TestProtocol.sys.mjs index 8676be15a2..dfb5338e19 100644 --- a/mail/components/im/test/TestProtocol.jsm +++ b/mail/components/im/test/TestProtocol.sys.mjs @@ -2,13 +2,7 @@ * 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 EXPORTED_SYMBOLS = [ - "registerTestProtocol", - "unregisterTestProtocol", - "TestProtocol", -]; - -var { +import { GenericAccountPrototype, GenericConvChatPrototype, GenericConvIMPrototype, @@ -17,10 +11,9 @@ var { GenericConvChatBuddyPrototype, GenericMessagePrototype, TooltipInfo, -} = ChromeUtils.importESModule("resource:///modules/jsProtoHelper.sys.mjs"); -var { nsSimpleEnumerator } = ChromeUtils.importESModule( - "resource:///modules/imXPCOMUtils.sys.mjs" -); +} from "resource:///modules/jsProtoHelper.sys.mjs"; + +import { nsSimpleEnumerator } from "resource:///modules/imXPCOMUtils.sys.mjs"; function Message(who, text, properties, conversation) { this._init(who, text, properties, conversation); @@ -255,7 +248,7 @@ Account.prototype = { remove() {}, }; -function TestProtocol() {} +export function TestProtocol() {} TestProtocol.prototype = { __proto__: GenericProtocolPrototype, get id() { @@ -295,7 +288,7 @@ TestProtocol.prototype = { classID: Components.ID("{a4617631-b8b8-4053-8afa-5c4c43498280}"), }; -function registerTestProtocol() { +export function registerTestProtocol() { Services.catMan.addCategoryEntry( "im-protocol-plugin", TestProtocol.prototype.id, @@ -305,7 +298,7 @@ function registerTestProtocol() { ); } -function unregisterTestProtocol() { +export function unregisterTestProtocol() { Services.catMan.deleteCategoryEntry( "im-protocol-plugin", TestProtocol.prototype.id, diff --git a/mail/components/im/test/browser/browser_chatNotifications.js b/mail/components/im/test/browser/browser_chatNotifications.js index e8c91e1d49..a3a7cd6d01 100644 --- a/mail/components/im/test/browser/browser_chatNotifications.js +++ b/mail/components/im/test/browser/browser_chatNotifications.js @@ -9,7 +9,9 @@ const { MockRegistrar } = ChromeUtils.import( "resource://testing-common/MockRegistrar.jsm" ); -const { ChatIcons } = ChromeUtils.import("resource:///modules/chatIcons.jsm"); +const { ChatIcons } = ChromeUtils.importESModule( + "resource:///modules/chatIcons.sys.mjs" +); let originalAlertsServiceCID; let alertShown; diff --git a/mail/components/im/test/browser/head.js b/mail/components/im/test/browser/head.js index 17be96f8a4..cd910d7fed 100644 --- a/mail/components/im/test/browser/head.js +++ b/mail/components/im/test/browser/head.js @@ -2,8 +2,11 @@ * 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 { registerTestProtocol, unregisterTestProtocol } = ChromeUtils.import( - "resource://testing-common/TestProtocol.jsm" +var { + registerTestProtocol, + unregisterTestProtocol, +} = ChromeUtils.importESModule( + "resource://testing-common/TestProtocol.sys.mjs" ); var { IMServices } = ChromeUtils.importESModule( "resource:///modules/IMServices.sys.mjs" diff --git a/mail/components/im/test/components.conf b/mail/components/im/test/components.conf index d39f70ba28..3f8c09fc09 100644 --- a/mail/components/im/test/components.conf +++ b/mail/components/im/test/components.conf @@ -8,7 +8,7 @@ Classes = [ { 'cid': '{a4617631-b8b8-4053-8afa-5c4c43498280}', 'contract_ids': ['@mozilla.org/chat/mochitest;1'], - 'jsm': 'resource://testing-common/TestProtocol.jsm', + 'esModule': 'resource://testing-common/TestProtocol.sys.mjs', 'constructor': 'TestProtocol', }, ]