Bug 1762688 - Enable test_imapID.js and test_imapClientid.js for imap-js. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D156291

--HG--
extra : amend_source : f1ff7edbf17b4dcf12acd5cad18bb81f7f509693
extra : absorb_source : 90aba8cda2fa5fbb3d3148b6e397efc093a03f4b
This commit is contained in:
Ping Chen 2022-09-06 20:03:04 +10:00
Родитель d5b368e0ea
Коммит a39413215f
8 изменённых файлов: 95 добавлений и 34 удалений

Просмотреть файл

@ -140,7 +140,37 @@ class ImapClient {
*/
discoverAllFolders(folder) {
this._logger.debug("discoverAllFolders", folder.URI);
this._actionListOrLsub();
let handleListResponse = res => {
this._hasTrash = res.mailboxes.some(
mailbox => mailbox.flags & ImapUtils.FLAG_IMAP_TRASH
);
if (!this._hasTrash) {
let trashFolderName = this._server.trashFolderName.toLowerCase();
let trashMailbox = res.mailboxes.find(
mailbox => mailbox.name.toLowerCase() == trashFolderName
);
if (trashMailbox) {
this._hasTrash = true;
trashMailbox.flags |= ImapUtils.FLAG_IMAP_TRASH;
}
}
for (let mailbox of res.mailboxes) {
this._serverSink.possibleImapMailbox(
mailbox.name,
mailbox.delimiter,
mailbox.flags
);
}
};
this._nextAction = res => {
this._nextAction = res => {
handleListResponse(res);
this._actionFinishFolderDiscovery();
};
this._sendTagged('LSUB "" "*"');
};
this._sendTagged('LIST "" "*"');
}
/**
@ -721,7 +751,18 @@ class ImapClient {
}
this._logger.debug(`Possible auth methods: ${this._possibleAuthMethods}`);
this._nextAuthMethod = this._possibleAuthMethods[0];
this._actionAuth();
if (this._capabilities.includes("CLIENTID") && this._server.clientid) {
this._nextAction = res => {
if (res.status == "OK") {
this._actionAuth();
} else {
this._actionDone(Cr.NS_ERROR_FAILURE);
}
};
this._sendTagged(`CLIENTID UUID ${this._server.clientid}`);
} else {
this._actionAuth();
}
};
/**
@ -827,11 +868,31 @@ class ImapClient {
this._authenticating = false;
if (res.status == "OK") {
let actionId = () => {
if (this._capabilities.includes("ID") && Services.appinfo.name) {
this._nextAction = res => {
this._server.serverIDPref = res.id;
this.onReady();
};
this._sendTagged(
`ID ("name" "${Services.appinfo.name}" "version" "${Services.appinfo.version}")`
);
} else {
this.onReady();
}
};
if (res.capabilities) {
this._capabilities = res.capabilities;
this._server.wrappedJSObject.capabilities = res.capabilities;
actionId();
} else {
this._nextAction = res => {
this._capabilities = res.capabilities;
this._server.wrappedJSObject.capabilities = res.capabilities;
actionId();
};
this._sendTagged("CAPABILITY");
}
this.onReady();
return;
}
if (
@ -1012,21 +1073,6 @@ class ImapClient {
mailbox => mailbox.flags & ImapUtils.FLAG_IMAP_INBOX
);
}
if (!this._hasTrash) {
this._hasTrash = res.mailboxes.some(
mailbox => mailbox.flags & ImapUtils.FLAG_IMAP_TRASH
);
if (!this._hasTrash) {
let trashFolderName = this._server.trashFolderName.toLowerCase();
let trashMailbox = res.mailboxes.find(
mailbox => mailbox.name.toLowerCase() == trashFolderName
);
if (trashMailbox) {
this._hasTrash = true;
trashMailbox.flags |= ImapUtils.FLAG_IMAP_TRASH;
}
}
}
for (let mailbox of res.mailboxes) {
this._serverSink.possibleImapMailbox(
mailbox.name,

Просмотреть файл

@ -50,20 +50,28 @@ class ImapIncomingServer extends MsgIncomingServer {
// nsIImapIncomingServer attributes that map directly to pref values.
this._mapAttrsToPrefs([
["Bool", "forceSelect", "force_select_imap"],
["Char", "adminUrl", "admin_url"],
["Bool", "dualUseFolders", "dual_use_folders"],
["Bool", "cleanupInboxOnExit", "cleanup_inbox_on_exit"],
["Bool", "offlineDownload", "offline_download"],
["Bool", "downloadBodiesOnGetNewMail", "download_bodies_on_get_new_mail"],
["Bool", "autoSyncOfflineStores", "autosync_offline_stores"],
["Bool", "useIdle", "use_idle"],
["Bool", "checkAllFoldersForNew", "check_all_folders_for_new"],
["Bool", "useCondStore", "use_condstore"],
["Bool", "isGMailServer", "is_gmail"],
["Bool", "useCompressDeflate", "use_compress_deflate"],
["Bool", "allowUTF8Accept", "allow_utf8_accept"],
["Bool", "autoSyncOfflineStores", "autosync_offline_stores"],
["Bool", "checkAllFoldersForNew", "check_all_folders_for_new"],
["Bool", "cleanupInboxOnExit", "cleanup_inbox_on_exit"],
["Bool", "downloadBodiesOnGetNewMail", "download_bodies_on_get_new_mail"],
["Bool", "dualUseFolders", "dual_use_folders"],
["Bool", "fetchByChunks", "fetch_by_chunks"],
["Bool", "forceSelect", "force_select_imap"],
["Bool", "isGMailServer", "is_gmail"],
["Bool", "mimePartsOnDemand", "mime_parts_on_demand"],
["Bool", "offlineDownload", "offline_download"],
["Bool", "sendID", "send_client_info"],
["Bool", "useCompressDeflate", "use_compress_deflate"],
["Bool", "useCondStore", "use_condstore"],
["Bool", "useIdle", "use_idle"],
["Char", "adminUrl", "admin_url"],
["Char", "otherUsersNamespace", "namespace.other_users"],
["Char", "personalNamespace", "namespace.personal"],
["Char", "publicNamespace", "namespace.public"],
["Char", "serverIDPref", "serverIDResponse"],
["Int", "autoSyncMaxAgeDays", "autosync_max_age_days"],
["Int", "timeOutLimits", "timeout"],
]);
}

Просмотреть файл

@ -108,6 +108,10 @@ class ImapResponse {
ImapUtils.FLAG_SUPPORT_USER_FLAG;
}
break;
case "ID":
// * ID ("name" "imap" "vendor" "Example, Inc.")
this.id = line.slice("* ID ".length);
break;
case "LIST":
case "LSUB":
// * LIST (\Subscribed \NoInferiors \UnMarked \Sent) "/" Sent

Просмотреть файл

@ -161,7 +161,10 @@ function do_check_transaction(fromServer, expected, withParams) {
}
}
Assert.equal(realTransaction.join(", "), expected.join(", "));
Assert.equal(
realTransaction.join(", ").toUpperCase(),
expected.join(", ").toUpperCase()
);
}
/**

Просмотреть файл

@ -10,10 +10,8 @@ prefs =
[test_folderOfflineFlags.js]
[test_gmailAttributes.js]
[test_imapAutoSync.js]
[test_imapClientid.js]
[test_imapHdrChunking.js]
[test_imapHighWater.js]
[test_imapID.js]
[test_imapMove.js]
[test_imapProtocols.js]
[test_imapProxy.js]

Просмотреть файл

@ -14,6 +14,7 @@
[test_gmailOfflineMsgStore.js]
[test_imapAttachmentSaves.js]
[test_imapChunks.js]
[test_imapClientid.js]
[test_imapContentLength.js]
[test_imapCopyTimeout.js]
[test_imapFilterActions.js]
@ -21,6 +22,7 @@
[test_imapFlagChange.js]
[test_imapFolderCopy.js]
[test_imapHdrStreaming.js]
[test_imapID.js]
[test_imapPasswordFailure.js]
[test_mailboxes.js]
[test_starttlsFailure.js]

Просмотреть файл

@ -8,5 +8,6 @@ prefs =
[test_ImapResponse.js]
[test_imapAuthMethods.js]
skip-if = true
[include:xpcshell-shared.ini]

Просмотреть файл

@ -12,7 +12,6 @@ prefs =
[test_imapAutoSync.js]
[test_imapHdrChunking.js]
[test_imapHighWater.js]
[test_imapID.js]
[test_imapMove.js]
[test_imapRename.js]
[test_imapSearch.js]