From b1fa38b0208db4610e4d0d609df6ce506fc04f49 Mon Sep 17 00:00:00 2001 From: Geoff Lankow Date: Mon, 26 Feb 2024 10:44:22 +0100 Subject: [PATCH] Bug 1881992 - ESMify IMAPpump.jsm. r=aleca Differential Revision: https://phabricator.services.mozilla.com/D202689 --HG-- rename : mailnews/test/resources/IMAPpump.jsm => mailnews/test/resources/IMAPpump.sys.mjs extra : rebase_source : 85c6afd4c31cd5f4a2c0258411fe74b053de43f3 extra : amend_source : 1966a51b0b81e4edf16eaed68fa4b35dd74d0fde --- mailnews/base/test/unit/test_imapPump.js | 4 ++-- mailnews/base/test/unit/test_saveAs.js | 4 ++-- .../test_testsuite_fakeserver_imapd_gmail.js | 4 ++-- ...estsuite_fakeserver_imapd_list-extended.js | 4 ++-- mailnews/imap/test/unit/head_server.js | 4 ++-- .../test/unit/test_filterCustomHeaders.js | 4 ++-- mailnews/moz.build | 2 +- .../search/test/unit/test_searchChaining.js | 4 ++-- .../{IMAPpump.jsm => IMAPpump.sys.mjs} | 24 ++++++------------- .../test/resources/MessageInjection.sys.mjs | 7 +++--- tools/esmify/map.json | 1 - 11 files changed, 26 insertions(+), 36 deletions(-) rename mailnews/test/resources/{IMAPpump.jsm => IMAPpump.sys.mjs} (88%) diff --git a/mailnews/base/test/unit/test_imapPump.js b/mailnews/base/test/unit/test_imapPump.js index 347029c3d5..c5b317582d 100644 --- a/mailnews/base/test/unit/test_imapPump.js +++ b/mailnews/base/test/unit/test_imapPump.js @@ -14,8 +14,8 @@ const { PromiseTestUtils } = ChromeUtils.importESModule( ); // IMAP pump -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { ImapMessage } = ChromeUtils.importESModule( "resource://testing-common/mailnews/Imapd.sys.mjs" diff --git a/mailnews/base/test/unit/test_saveAs.js b/mailnews/base/test/unit/test_saveAs.js index 78afe5601b..cd2d7d8ea6 100644 --- a/mailnews/base/test/unit/test_saveAs.js +++ b/mailnews/base/test/unit/test_saveAs.js @@ -21,8 +21,8 @@ var { mailTestUtils } = ChromeUtils.importESModule( var { ImapMessage } = ChromeUtils.importESModule( "resource://testing-common/mailnews/Imapd.sys.mjs" ); -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { TestUtils } = ChromeUtils.importESModule( "resource://testing-common/TestUtils.sys.mjs" diff --git a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js index b61fb7b791..a1f69ab49e 100644 --- a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js +++ b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js @@ -7,8 +7,8 @@ // per https://developers.google.com/google-apps/gmail/imap_extensions // IMAP pump -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { PromiseTestUtils } = ChromeUtils.importESModule( "resource://testing-common/mailnews/PromiseTestUtils.sys.mjs" diff --git a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js index d0334ed7cc..08d5153ebb 100644 --- a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js +++ b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js @@ -6,8 +6,8 @@ // extension (RFC 5258 - http://tools.ietf.org/html/rfc5258) // IMAP pump -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { PromiseTestUtils } = ChromeUtils.importESModule( "resource://testing-common/mailnews/PromiseTestUtils.sys.mjs" diff --git a/mailnews/imap/test/unit/head_server.js b/mailnews/imap/test/unit/head_server.js index 140e7c7d6e..66d9f6762f 100644 --- a/mailnews/imap/test/unit/head_server.js +++ b/mailnews/imap/test/unit/head_server.js @@ -16,8 +16,8 @@ var { mailTestUtils } = ChromeUtils.importESModule( var { localAccountUtils } = ChromeUtils.importESModule( "resource://testing-common/mailnews/LocalAccountUtils.sys.mjs" ); -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { PromiseTestUtils } = ChromeUtils.importESModule( "resource://testing-common/mailnews/PromiseTestUtils.sys.mjs" diff --git a/mailnews/imap/test/unit/test_filterCustomHeaders.js b/mailnews/imap/test/unit/test_filterCustomHeaders.js index cf033fcc2f..af13534730 100644 --- a/mailnews/imap/test/unit/test_filterCustomHeaders.js +++ b/mailnews/imap/test/unit/test_filterCustomHeaders.js @@ -17,8 +17,8 @@ var { PromiseTestUtils } = ChromeUtils.importESModule( // IMAP pump -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); add_setup(async function () { diff --git a/mailnews/moz.build b/mailnews/moz.build index 2fe3ba3311..d3618a7df9 100644 --- a/mailnews/moz.build +++ b/mailnews/moz.build @@ -60,7 +60,7 @@ TESTING_JS_MODULES.mailnews += [ "test/fakeserver/Pop3d.sys.mjs", "test/fakeserver/ServerTestUtils.sys.mjs", "test/fakeserver/Smtpd.sys.mjs", - "test/resources/IMAPpump.jsm", + "test/resources/IMAPpump.sys.mjs", "test/resources/LocalAccountUtils.sys.mjs", "test/resources/MailTestUtils.sys.mjs", "test/resources/MessageGenerator.sys.mjs", diff --git a/mailnews/search/test/unit/test_searchChaining.js b/mailnews/search/test/unit/test_searchChaining.js index 24320425b6..0ff3c477c4 100644 --- a/mailnews/search/test/unit/test_searchChaining.js +++ b/mailnews/search/test/unit/test_searchChaining.js @@ -11,8 +11,8 @@ var { MessageGenerator } = ChromeUtils.importESModule( "resource://testing-common/mailnews/MessageGenerator.sys.mjs" ); -var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" +var { IMAPPump, setupIMAPPump, teardownIMAPPump } = ChromeUtils.importESModule( + "resource://testing-common/mailnews/IMAPpump.sys.mjs" ); var { ImapMessage } = ChromeUtils.importESModule( "resource://testing-common/mailnews/Imapd.sys.mjs" diff --git a/mailnews/test/resources/IMAPpump.jsm b/mailnews/test/resources/IMAPpump.sys.mjs similarity index 88% rename from mailnews/test/resources/IMAPpump.jsm rename to mailnews/test/resources/IMAPpump.sys.mjs index 333bdea749..6bce60b6de 100644 --- a/mailnews/test/resources/IMAPpump.jsm +++ b/mailnews/test/resources/IMAPpump.sys.mjs @@ -11,26 +11,16 @@ * then. */ -var EXPORTED_SYMBOLS = ["IMAPPump", "setupIMAPPump", "teardownIMAPPump"]; - var { MailServices } = ChromeUtils.import( "resource:///modules/MailServices.jsm" ); -var { localAccountUtils } = ChromeUtils.importESModule( - "resource://testing-common/mailnews/LocalAccountUtils.sys.mjs" -); -var { nsMailServer } = ChromeUtils.importESModule( - "resource://testing-common/mailnews/Maild.sys.mjs" -); -var Imapd = ChromeUtils.importESModule( - "resource://testing-common/mailnews/Imapd.sys.mjs" -); -var { updateAppInfo } = ChromeUtils.importESModule( - "resource://testing-common/AppInfo.sys.mjs" -); +import { localAccountUtils } from "resource://testing-common/mailnews/LocalAccountUtils.sys.mjs"; +import { nsMailServer } from "resource://testing-common/mailnews/Maild.sys.mjs"; +import * as Imapd from "resource://testing-common/mailnews/Imapd.sys.mjs"; +import { updateAppInfo } from "resource://testing-common/AppInfo.sys.mjs"; // define globals -var IMAPPump = { +export var IMAPPump = { daemon: null, // the imap fake server daemon server: null, // the imap fake server incomingServer: null, // nsIMsgIncomingServer for the imap server @@ -38,7 +28,7 @@ var IMAPPump = { mailbox: null, // imap fake server mailbox }; -function setupIMAPPump(extensions) { +export function setupIMAPPump(extensions) { // Create Application info if we need it. updateAppInfo(); @@ -120,7 +110,7 @@ function setupIMAPPump(extensions) { } // This will clear not only the imap accounts but also local accounts. -function teardownIMAPPump() { +export function teardownIMAPPump() { // try to finish any pending operations const thread = Services.tm.currentThread; while (thread.hasPendingEvents()) { diff --git a/mailnews/test/resources/MessageInjection.sys.mjs b/mailnews/test/resources/MessageInjection.sys.mjs index a4a015e01f..b648eb0ea8 100644 --- a/mailnews/test/resources/MessageInjection.sys.mjs +++ b/mailnews/test/resources/MessageInjection.sys.mjs @@ -16,9 +16,10 @@ var { VirtualFolderHelper } = ChromeUtils.import( ); import { ImapMessage } from "resource://testing-common/mailnews/Imapd.sys.mjs"; -var { IMAPPump, setupIMAPPump } = ChromeUtils.import( - "resource://testing-common/mailnews/IMAPpump.jsm" -); +import { + IMAPPump, + setupIMAPPump, +} from "resource://testing-common/mailnews/IMAPpump.sys.mjs"; const SEARCH_TERM_MAP_HELPER = { subject: Ci.nsMsgSearchAttrib.Subject, diff --git a/tools/esmify/map.json b/tools/esmify/map.json index 9cec9f4722..0d65172e56 100644 --- a/tools/esmify/map.json +++ b/tools/esmify/map.json @@ -391,7 +391,6 @@ "resource://testing-common/gloda/GlodaQueryHelper.jsm": "comm/mailnews/db/gloda/test/unit/resources/GlodaQueryHelper.jsm", "resource://testing-common/gloda/GlodaTestHelper.jsm": "comm/mailnews/db/gloda/test/unit/resources/GlodaTestHelper.jsm", "resource://testing-common/gloda/GlodaTestHelperFunctions.jsm": "comm/mailnews/db/gloda/test/unit/resources/GlodaTestHelperFunctions.jsm", - "resource://testing-common/mailnews/IMAPpump.jsm": "comm/mailnews/test/resources/IMAPpump.jsm", "resource://testing-common/mailnews/testJaBaseIncomingServer.jsm": "comm/mailnews/jsaccount/test/unit/resources/testJaBaseIncomingServer.jsm", "resource://testing-common/mailnews/testJaBaseMsgFolder.jsm": "comm/mailnews/jsaccount/test/unit/resources/testJaBaseMsgFolder.jsm", "resource://testing-common/mozmill/AccountManagerHelpers.jsm": "comm/mail/test/browser/shared-modules/AccountManagerHelpers.jsm",