Bug 1762688 - Enable test_imapUrls for imap-js. r=mkmelin

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ping Chen 2022-09-14 04:43:11 +00:00
Родитель fe1ba6eb80
Коммит 8bfea5ca02
3 изменённых файлов: 30 добавлений и 32 удалений

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

@ -35,14 +35,13 @@ class BaseMessageService {
outUrl
) {
this._logger.debug("CopyMessage", messageUri, moveMessage);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let { host, folder, folderName, key } = this._decomposeMessageUri(
messageUri
);
let imapUrl = Services.io
.newURI(`imap://${host}/fetch>UID>/${folderName}>${key}`)
.QueryInterface(Ci.nsIImapUrl);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
if (urlListener) {
imapUrl
.QueryInterface(Ci.nsIMsgMailNewsUrl)
@ -73,14 +72,13 @@ class BaseMessageService {
outURL
) {
this._logger.debug("DisplayMessage", messageUri);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let { host, folder, folderName, key } = this._decomposeMessageUri(
messageUri
);
let imapUrl = Services.io
.newURI(`imap://${host}/fetch>UID>/${folderName}>${key}`)
.QueryInterface(Ci.nsIImapUrl);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let mailnewsUrl = imapUrl.QueryInterface(Ci.nsIMsgMailNewsUrl);
if (urlListener) {
mailnewsUrl.RegisterListener(urlListener);
@ -109,14 +107,13 @@ class BaseMessageService {
msgWindow
) {
this._logger.debug("SaveMessageToDisk", messageUri);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let { host, folder, folderName, key } = this._decomposeMessageUri(
messageUri
);
let imapUrl = Services.io
.newURI(`imap://${host}/fetch>UID>/${folderName}>${key}`)
.QueryInterface(Ci.nsIImapUrl);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let msgUrl = imapUrl.QueryInterface(Ci.nsIMsgMessageUrl);
msgUrl.messageFile = file;
msgUrl.AddDummyEnvelope = addDummyEnvelope;
@ -143,9 +140,15 @@ class BaseMessageService {
return Services.io.newURI(messageUri);
}
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let { host, folder, folderName, key } = this._decomposeMessageUri(
messageUri
);
let delimiter =
folder.QueryInterface(Ci.nsIMsgImapMailFolder).hierarchyDelimiter || "/";
let imapUrl = Services.io
.newURI(`imap://${host}/fetch>UID>/${folderName}>${key}`)
.newURI(
`imap://${host}:${folder.server.port}/fetch>UID>${delimiter}${folderName}>${key}`
)
.QueryInterface(Ci.nsIImapUrl);
return imapUrl;
@ -161,7 +164,9 @@ class BaseMessageService {
localOnly
) {
this._logger.debug("streamMessage", messageUri);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let { host, folder, folderName, key } = this._decomposeMessageUri(
messageUri
);
let url = `imap://${host}/fetch>UID>/${folderName}>${key}`;
if (additionalHeader) {
url += `?header=${additionalHeader}`;
@ -169,10 +174,6 @@ class BaseMessageService {
let imapUrl = Services.io.newURI(url).QueryInterface(Ci.nsIImapUrl);
imapUrl.localFetchOnly = localOnly;
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let mailnewsUrl = imapUrl.QueryInterface(Ci.nsIMsgMailNewsUrl);
mailnewsUrl.folder = folder;
mailnewsUrl.msgWindow = msgWindow;
@ -196,10 +197,7 @@ class BaseMessageService {
streamHeaders(messageUri, consumer, urlListener, localOnly) {
this._logger.debug("streamHeaders", messageUri);
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let { folder, key } = this._decomposeMessageUri(messageUri);
let hasMsgOffline = folder.hasMsgOffline(key);
if (!hasMsgOffline) {
@ -236,23 +234,23 @@ class BaseMessageService {
}
messageURIToMsgHdr(messageUri) {
let { host, folderName, key } = this._decomposeMessageUri(messageUri);
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
let { folder, key } = this._decomposeMessageUri(messageUri);
return folder.GetMessageHeader(key);
}
/**
* Parse a message uri to hostname, folder and message key.
* @param {string} uri - The imap-message:// url to parse.
* @returns {host: string, folderName: string, key: string}
* @returns {host: string, folder: nsIMsgFolder, folderName: string, key: string}
*/
_decomposeMessageUri(messageUri) {
let matches = /imap-message:\/\/([^:]+)\/(.+)#(\d+)/.exec(messageUri);
let [, host, folderName, key] = matches;
let folder = lazy.MailUtils.getOrCreateFolder(
`imap://${host}/${folderName}`
);
return { host, folderName, key };
return { host, folder, folderName, key };
}
}

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

@ -14,9 +14,6 @@ prefs =
[test_imapHighWater.js]
[test_imapStatusCloseDBs.js]
[test_imapUndo.js]
[test_imapUrls.js]
[test_largeOfflineStore.js]
skip-if = os == 'mac'
[test_listClosesDB.js]
[test_listSubscribed.js]
[test_localToImapFilter.js]

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

@ -30,5 +30,8 @@
[test_imapRename.js]
[test_imapSearch.js]
[test_imapStoreMsgOffline.js]
[test_imapUrls.js]
[test_largeOfflineStore.js]
skip-if = os == 'mac'
[test_mailboxes.js]
[test_starttlsFailure.js]