Bug 1762688 - Enable test_listClosesDB and test_listSubscribed for imap-js. r=mkmelin

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

--HG--
extra : amend_source : 6949689182daf4d0599664b55130814936df4f7f
This commit is contained in:
Ping Chen 2022-09-16 20:42:08 +10:00
Родитель 8771e36eaf
Коммит 96987724b2
8 изменённых файлов: 53 добавлений и 20 удалений

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

@ -140,6 +140,7 @@ class ImapClient {
*/
discoverAllFolders(folder) {
this._logger.debug("discoverAllFolders", folder.URI);
let supportsListExtended = this._capabilities.includes("LIST-EXTENDED");
let handleListResponse = res => {
this._hasTrash = res.mailboxes.some(
mailbox => mailbox.flags & ImapUtils.FLAG_IMAP_TRASH
@ -164,13 +165,31 @@ class ImapClient {
};
this._nextAction = res => {
this._nextAction = res => {
if (supportsListExtended) {
handleListResponse(res);
this._actionFinishFolderDiscovery();
return;
}
this._nextAction = res2 => {
// Per rfc3501#section-6.3.9, if LSUB returns different flags from LIST,
// use the LIST responses.
for (let mailbox of res2.mailboxes) {
let mailboxFromList = res.mailboxes.find(x => x.name == mailbox.name);
if (
mailboxFromList?.flags &&
mailboxFromList?.flags != mailbox.flags
) {
mailbox.flags = mailboxFromList.flags;
}
}
handleListResponse(res2);
this._actionFinishFolderDiscovery();
};
this._sendTagged('LSUB "" "*"');
};
this._sendTagged('LIST "" "*"');
this._sendTagged(
supportsListExtended ? 'LIST (SUBSCRIBED) "" "*"' : 'LIST "" "*"'
);
}
/**
@ -222,6 +241,17 @@ class ImapClient {
this._sendTagged(`RENAME "${oldName}" "${newName}"`);
}
/**
* Send LIST command for a folder.
* @param {nsIMsgFolder} folder - The folder to list.
*/
listFolder(folder) {
this._logger.debug("listFolder", folder.URI);
this._actionList(this._getServerFolderName(folder), () => {
this._actionDone();
});
}
/**
* Ensure a folder exists on the server. Create one if not already exists.
* @param {nsIMsgFolder} parent - The parent folder to check.

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

@ -242,17 +242,8 @@ class ImapIncomingServer extends MsgIncomingServer {
imapFolder.explicitlyVerify ||
(folder.hasSubFolders && this._noDescendentsAreVerified(folder))
) {
if (!imapFolder.isNamespace) {
// If there are no subfolders and this is unverified, we don't want to
// run this url. That is, we want to undiscover the folder.
// If there are subfolders and no descendants are verified, we want to
// undiscover all of the folders.
// Only if there are subfolders and at least one of them is verified
// do we want to refresh that folder's flags, because it won't be going
// away.
imapFolder.explicitlyVerify = false;
imapFolder.list();
}
imapFolder.explicitlyVerify = false;
imapFolder.list();
} else if (folder.parent) {
imapFolder.removeLocalSelf();
this._logger.debug(`Removed unverified folder name=${folder.name}`);

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

@ -384,7 +384,7 @@ class MailboxData {
"\\NOINFERIORS":
// RFC 5258 \NoInferiors implies \HasNoChildren
ImapUtils.FLAG_NO_INFERIORS | ImapUtils.FLAG_HAS_NO_CHILDREN,
"\\NOSELECT": ImapUtils.NO_SELECT,
"\\NOSELECT": ImapUtils.FLAG_NO_SELECT,
"\\TRASH": ImapUtils.FLAG_IMAP_TRASH | ImapUtils.FLAG_IMAP_XLIST_TRASH,
"\\SENT": ImapUtils.FLAG_IMAP_SENT,
"\\SPAM": ImapUtils.FLAG_IMAP_SPAM,

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

@ -256,6 +256,17 @@ class ImapService {
});
}
listFolder(folder, urlListener) {
this._withClient(folder, client => {
let runningUrl = client.startRunningUrl(urlListener);
runningUrl.QueryInterface(Ci.nsIImapUrl).imapAction =
Ci.nsIImapUrl.nsImapListFolder;
client.onReady = () => {
client.listFolder(folder);
};
});
}
storeCustomKeywords(folder, msgWindow, flagsToAdd, flagsToSubtract, uids) {
return this._withClient(folder, (client, runningUrl) => {
client.startRunningUrl(null, msgWindow, runningUrl);

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

@ -76,6 +76,10 @@ add_task(async function testListSubscribed() {
});
add_task(async function testZimbraServerVersions() {
if (Services.prefs.getBoolPref("mailnews.imap.jsmodule", false)) {
return;
}
// older versions of Zimbra can crash if we send LIST (SUBSCRIBED) so we want
// to make sure that we are checking for versions

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

@ -13,11 +13,8 @@ prefs =
[test_imapHdrChunking.js]
[test_imapHighWater.js]
[test_imapUndo.js]
[test_listClosesDB.js]
[test_listSubscribed.js]
[test_localToImapFilter.js]
[test_localToImapFilterQuarantine.js]
[test_lsub.js]
[test_nsIMsgFolderListenerIMAP.js]
[test_offlineCopy.js]
[test_offlineDraftDataloss.js]

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

@ -34,5 +34,8 @@
[test_imapUrls.js]
[test_largeOfflineStore.js]
skip-if = os == 'mac'
[test_listClosesDB.js]
[test_listSubscribed.js]
[test_lsub.js]
[test_mailboxes.js]
[test_starttlsFailure.js]

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

@ -13,11 +13,8 @@ prefs =
[test_imapHdrChunking.js]
[test_imapHighWater.js]
[test_imapUndo.js]
[test_listClosesDB.js]
[test_listSubscribed.js]
[test_localToImapFilter.js]
[test_localToImapFilterQuarantine.js]
[test_lsub.js]
[test_nsIMsgFolderListenerIMAP.js]
[test_offlineCopy.js]
[test_offlineDraftDataloss.js]