--- a/.eslintignore
+++ b/.eslintignore
@@ -57,18 +57,16 @@ editor/ui/dialogs/content/EditorSaveAsCh
editor/ui/dialogs/content/EdLinkChecker.js
editor/ui/dialogs/content/EdLinkChecker.xul
editor/ui/dialogs/content/EdSnapToGrid.js
editor/ui/dialogs/content/EdSnapToGrid.xul
editor/ui/texzilla/**
# mailnews exclusions
mailnews/mailnews.js
-mailnews/build/*
-mailnews/compose/*
mailnews/db/*
mailnews/imap/*
mailnews/import/*
mailnews/intl/*
mailnews/jsaccount/*
mailnews/mime/*
# mailnews/extensions exclusions
--- a/mailnews/compose/content/askSendFormat.js
+++ b/mailnews/compose/content/askSendFormat.js
@@ -5,34 +5,32 @@
var gParam = null;
document.addEventListener("dialogaccept", Send);
/**
* This dialog should be opened with arguments like e.g.
* {action: nsIMsgCompSendFormat.AskUser, convertible: nsIMsgCompConvertible.Yes}
*/
-function Startup()
-{
+function Startup() {
gParam = window.arguments[0];
const msgCompSendFormat = Ci.nsIMsgCompSendFormat;
const msgCompConvertible = Ci.nsIMsgCompConvertible;
var bundle = document.getElementById("askSendFormatStringBundle");
// If the user hits the close box, we will abort.
gParam.abort = true;
// Set the question label
var mailSendFormatExplanation = document.getElementById("mailSendFormatExplanation");
var icon = document.getElementById("convertDefault");
- switch (gParam.convertible)
- {
+ switch (gParam.convertible) {
case msgCompConvertible.Altering:
mailSendFormatExplanation.textContent = bundle.getString("convertibleAltering");
icon.className = "question-icon";
break;
case msgCompConvertible.No:
mailSendFormatExplanation.textContent = bundle.getString("convertibleNo");
icon.className = "alert-icon";
break;
@@ -40,21 +38,19 @@ function Startup()
mailSendFormatExplanation.textContent = bundle.getString("convertibleYes");
// XXX change this to use class message-icon once bug 512173 is fixed
icon.className = "question-icon";
break;
}
// Set the default radio array value and recommendation.
var group = document.getElementById("mailDefaultHTMLAction");
- if (gParam.action != msgCompSendFormat.AskUser)
- {
+ if (gParam.action != msgCompSendFormat.AskUser) {
group.value = gParam.action;
group.selectedItem.label += " " + bundle.getString("recommended");
}
}
-function Send()
-{
+function Send() {
// gParam.action should be an integer for when it is returned to MsgComposeCommands.js
gParam.action = parseInt(document.getElementById("mailDefaultHTMLAction").value);
gParam.abort = false;
}
--- a/mailnews/compose/content/sendProgress.js
+++ b/mailnews/compose/content/sendProgress.js
@@ -14,26 +14,23 @@ var msgProgress = null;
// random global variables...
var itsASaveOperation = false;
var gSendProgressStringBundle;
document.addEventListener("dialogcancel", onCancel);
// all progress notifications are done through the nsIWebProgressListener implementation...
var progressListener = {
- onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
- {
- if (aStateFlags & Ci.nsIWebProgressListener.STATE_START)
- {
+ onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
+ if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
// Set no value to progress meter when undetermined.
dialog.progress.removeAttribute("value");
}
- if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
- {
+ if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
// we are done sending/saving the message...
// Indicate completion in status area.
var msg;
if (itsASaveOperation)
msg = gSendProgressStringBundle.getString("messageSaved");
else
msg = gSendProgressStringBundle.getString("messageSent");
dialog.status.setAttribute("value", msg);
@@ -42,84 +39,72 @@ var progressListener = {
dialog.progress.setAttribute("value", 100);
var percentMsg = gSendProgressStringBundle.getFormattedString("percentMsg", [100]);
dialog.progressText.setAttribute("value", percentMsg);
window.close();
}
},
- onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
- {
+ onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {
// Calculate percentage.
var percent;
- if (aMaxTotalProgress > 0)
- {
+ if (aMaxTotalProgress > 0) {
percent = Math.round(aCurTotalProgress / aMaxTotalProgress * 100);
if (percent > 100)
percent = 100;
// Advance progress meter.
dialog.progress.value = percent;
// Update percentage label on progress meter.
var percentMsg = gSendProgressStringBundle.getFormattedString("percentMsg", [percent]);
dialog.progressText.value = percentMsg;
- }
- else
- {
+ } else {
// Progress meter should show no value in this case.
dialog.progress.removeAttribute("value");
}
},
- onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags)
- {
+ onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
// we can ignore this notification
},
- onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
- {
+ onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
if (aMessage != "")
dialog.status.setAttribute("value", aMessage);
},
- onSecurityChange: function(aWebProgress, aRequest, state)
- {
+ onSecurityChange(aWebProgress, aRequest, state) {
// we can ignore this notification
},
- onContentBlockingEvent: function(aWebProgress, aRequest, aEvent)
- {
+ onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
// we can ignore this notification
},
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener",
"nsISupportsWeakReference"]),
};
-function onLoad()
-{
+function onLoad() {
// Set global variables.
let subject = "";
gSendProgressStringBundle = document.getElementById("sendProgressStringBundle");
msgProgress = window.arguments[0];
- if (!msgProgress)
- {
+ if (!msgProgress) {
Cu.reportError("Invalid argument to sendProgress.xul.");
window.close();
return;
}
- if (window.arguments[1])
- {
+ if (window.arguments[1]) {
let progressParams = window.arguments[1].QueryInterface(Ci.nsIMsgComposeProgressParams);
- if (progressParams)
- {
+ if (progressParams) {
itsASaveOperation = (progressParams.deliveryMode != nsIMsgCompDeliverMode.Now);
subject = progressParams.subject;
}
}
if (subject) {
let title = itsASaveOperation ? "titleSaveMsgSubject" : "titleSendMsgSubject";
document.title = gSendProgressStringBundle.getFormattedString(title, [subject]);
@@ -132,35 +117,29 @@ function onLoad()
dialog.status = document.getElementById("dialog.status");
dialog.progress = document.getElementById("dialog.progress");
dialog.progressText = document.getElementById("dialog.progressText");
// set our web progress listener on the helper app launcher
msgProgress.registerListener(progressListener);
}
-function onUnload()
-{
- if (msgProgress)
- {
- try
- {
+function onUnload() {
+ if (msgProgress) {
+ try {
msgProgress.unregisterListener(progressListener);
msgProgress = null;
} catch (e) {}
}
}
// If the user presses cancel, tell the app launcher and close the dialog...
-function onCancel(event)
-{
+function onCancel(event) {
// Cancel app launcher.
- try
- {
+ try {
msgProgress.processCanceledByUser = true;
- } catch (e)
- {
+ } catch (e) {
return;
}
// Don't close up dialog, the backend will close the dialog when everything will be aborted.
event.preventDefault();
}
--- a/mailnews/compose/src/nsSMTPProtocolHandler.js
+++ b/mailnews/compose/src/nsSMTPProtocolHandler.js
@@ -15,31 +15,31 @@ function makeProtocolHandler(aProtocol,
scheme: aProtocol,
defaultPort: aDefaultPort,
protocolFlags: nsIProtocolHandler.URI_NORELATIVE |
nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
nsIProtocolHandler.URI_NON_PERSISTABLE |
nsIProtocolHandler.ALLOWS_PROXY |
nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT,
- newURI: function (aSpec, aOriginCharset, aBaseURI) {
+ newURI(aSpec, aOriginCharset, aBaseURI) {
var url = Cc["@mozilla.org/messengercompose/smtpurl;1"]
.createInstance(Ci.nsIURI);
if (url instanceof Ci.nsISmtpUrl)
url.init(aSpec);
return url;
},
- newChannel: function(aURI, aLoadInfo) {
+ newChannel(aURI, aLoadInfo) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
- allowPort: function (port, scheme) {
+ allowPort(port, scheme) {
return port == aDefaultPort;
- }
+ },
};
}
function nsSMTPProtocolHandler() {}
nsSMTPProtocolHandler.prototype =
makeProtocolHandler("smtp",
Ci.nsISmtpUrl.DEFAULT_SMTP_PORT,
new file mode 100644
--- /dev/null
+++ b/mailnews/compose/test/unit/.eslintrc.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = {
+ "extends": "plugin:mozilla/xpcshell-test",
+
+ "rules": {
+ "func-names": "off",
+ "mozilla/import-headjs-globals": "error",
+ "no-unused-vars": ["error", {
+ "args": "none",
+ "vars": "all",
+ }],
+ },
+};
--- a/mailnews/compose/test/unit/head_compose.js
+++ b/mailnews/compose/test/unit/head_compose.js
@@ -12,16 +12,18 @@ var {getAppInfo, newAppInfo, updateAppIn
updateAppInfo();
// Ensure the profile directory is set up
do_get_profile();
var gDEPTH = "../../../../";
// Import the required setup scripts.
+
+/* import-globals-from ../../../test/resources/abSetup.js */
load("../../../resources/abSetup.js");
// Import the smtp server scripts
var {
nsMailServer,
gThreadManager,
fsDebugNone,
fsDebugAll,
@@ -33,29 +35,27 @@ var {
SMTP_RFC2821_handler,
} = ChromeUtils.import("resource://testing-common/mailnews/smtpd.js");
var {
AuthPLAIN,
AuthLOGIN,
AuthCRAM,
} = ChromeUtils.import("resource://testing-common/mailnews/auth.js");
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-
var gDraftFolder;
// Setup the daemon and server
function setupServerDaemon(handler) {
if (!handler)
- handler = function (d) { return new SMTP_RFC2821_handler(d); };
+ handler = function(d) { return new SMTP_RFC2821_handler(d); };
var server = new nsMailServer(handler, new smtpDaemon());
return server;
}
-function getBasicSmtpServer(port=1, hostname="localhost") {
+function getBasicSmtpServer(port = 1, hostname = "localhost") {
let server = localAccountUtils.create_outgoing_server(port, "user",
"password", hostname);
// Override the default greeting so we get something predicitable
// in the ELHO message
Services.prefs.setCharPref("mail.smtpserver.default.hello_argument", "test");
return server;
@@ -71,89 +71,90 @@ function getSmtpIdentity(senderName, smt
}
var test;
function do_check_transaction(real, expected) {
// real.them may have an extra QUIT on the end, where the stream is only
// closed after we have a chance to process it and not them. We therefore
// excise this from the list
- if (real.them[real.them.length-1] == "QUIT")
+ if (real.them[real.them.length - 1] == "QUIT")
real.them.pop();
Assert.equal(real.them.join(","), expected.join(","));
dump("Passed test " + test + "\n");
}
// This listener is designed just to call OnStopCopy() when its OnStopCopy
// function is called - the rest of the functions are unneeded for a lot of
// tests (but we can't use asyncCopyListener because we need the
// nsIMsgSendListener interface as well).
var copyListener = {
// nsIMsgSendListener
- onStartSending: function (aMsgID, aMsgSize) {},
- onProgress: function (aMsgID, aProgress, aProgressMax) {},
- onStatus: function (aMsgID, aMsg) {},
- onStopSending: function (aMsgID, aStatus, aMsg, aReturnFile) {},
- onGetDraftFolderURI: function (aFolderURI) {},
- onSendNotPerformed: function (aMsgID, aStatus) {},
+ onStartSending(aMsgID, aMsgSize) {},
+ onProgress(aMsgID, aProgress, aProgressMax) {},
+ onStatus(aMsgID, aMsg) {},
+ onStopSending(aMsgID, aStatus, aMsg, aReturnFile) {},
+ onGetDraftFolderURI(aFolderURI) {},
+ onSendNotPerformed(aMsgID, aStatus) {},
// nsIMsgCopyServiceListener
- OnStartCopy: function () {},
- OnProgress: function (aProgress, aProgressMax) {},
- SetMessageKey: function (aKey) {},
- GetMessageId: function (aMessageId) {},
- OnStopCopy: function (aStatus) {
+ OnStartCopy() {},
+ OnProgress(aProgress, aProgressMax) {},
+ SetMessageKey(aKey) {},
+ GetMessageId(aMessageId) {},
+ OnStopCopy(aStatus) {
+ /* globals OnStopCopy */
OnStopCopy(aStatus);
},
// QueryInterface
QueryInterface: ChromeUtils.generateQI(["nsIMsgSendListener",
"nsIMsgCopyServiceListener"]),
};
var progressListener = {
- onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
+ onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
this.resolve(mailTestUtils.firstMsgHdr(gDraftFolder));
},
- onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress,
+ onProgressChange(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {},
- onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {},
- onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {},
- onSecurityChange: function(aWebProgress, aRequest, state) {},
- onContentBlockingEvent: function(aWebProgress, aRequest, aEvent) {},
+ onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {},
+ onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {},
+ onSecurityChange(aWebProgress, aRequest, state) {},
+ onContentBlockingEvent(aWebProgress, aRequest, aEvent) {},
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener",
"nsISupportsWeakReference"]),
};
function createMessage(aAttachment) {
let fields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
let attachments = [];
if (aAttachment) {
let attachment = Cc["@mozilla.org/messengercompose/attachment;1"]
.createInstance(Ci.nsIMsgAttachment);
if (aAttachment instanceof Ci.nsIFile) {
attachment.url = "file://" + aAttachment.path;
- attachment.contentType = 'text/plain';
+ attachment.contentType = "text/plain";
attachment.name = aAttachment.leafName;
} else {
attachment.url = "data:,sometext";
attachment.name = aAttachment;
}
attachments = [attachment];
}
return richCreateMessage(fields, attachments);
}
-function richCreateMessage(fields, attachments=[], identity=null,
- account=null) {
+function richCreateMessage(fields, attachments = [], identity = null,
+ account = null) {
let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
.createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
let msgCompose = MailServices.compose.initCompose(params);
if (identity === null)
identity = getSmtpIdentity(null, getBasicSmtpServer());
@@ -188,23 +189,23 @@ function richCreateMessage(fields, attac
progress.registerListener(progressListener);
msgCompose.SendMsg(Ci.nsIMsgSend.nsMsgSaveAsDraft, identity,
account ? account.key : "", null,
progress);
return promise;
}
function getAttachmentFromContent(aContent) {
- function getBoundaryStringFromContent(aContent) {
+ function getBoundaryStringFromContent() {
let found = aContent.match(/Content-Type: multipart\/mixed;\s+boundary="(.*?)"/);
Assert.notEqual(found, null);
Assert.equal(found.length, 2);
return found[1];
- };
+ }
let boundary = getBoundaryStringFromContent(aContent);
let regex = new RegExp("\\r\\n\\r\\n--" + boundary + "\\r\\n" +
"([\\s\\S]*?)\\r\\n" +
"--" + boundary + "--", "m");
let attachments = aContent.match(regex);
Assert.notEqual(attachments, null);
Assert.equal(attachments.length, 2);
--- a/mailnews/compose/test/unit/test_attachment.js
+++ b/mailnews/compose/test/unit/test_attachment.js
@@ -1,25 +1,25 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for attachment file name.
*/
-var input0 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"+
- "`abcdefghijklmnopqrstuvwxyz{|}~"+
- "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"+
- "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"+
- "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"+
- "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"+
- "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"+
- "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff.txt"
+var input0 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
+ "`abcdefghijklmnopqrstuvwxyz{|}~" +
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" +
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" +
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" +
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" +
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" +
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff.txt";
// ascii only
-var input1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"+
- "`abcdefghijklmnopqrstuvwxyz{|}~.txt"
+var input1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
+ "`abcdefghijklmnopqrstuvwxyz{|}~.txt";
var expectedCD0 = ["Content-Disposition: attachment;",
" filename*0*=UTF-8''%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31;",
" filename*1*=%32%33%34%35%36%37%38%39%3A%3B%3C%3D%3E%3F%40%41%42%43%44%45;",
" filename*2*=%46%47%48%49%4A%4B%4C%4D%4E%4F%50%51%52%53%54%55%56%57%58%59;",
" filename*3*=%5A%5B%5C%5D%5E%5F%60%61%62%63%64%65%66%67%68%69%6A%6B%6C%6D;",
" filename*4*=%6E%6F%70%71%72%73%74%75%76%77%78%79%7A%7B%7C%7D%7E%C2%A0%C2;",
" filename*5*=%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2;",
@@ -29,57 +29,57 @@ var expectedCD0 = ["Content-Disposition:
" filename*9*=%89%C3%8A%C3%8B%C3%8C%C3%8D%C3%8E%C3%8F%C3%90%C3%91%C3%92%C3;",
" filename*10*=%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%9B%C3%9C;",
" filename*11*=%C3%9D%C3%9E%C3%9F%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3;",
" filename*12*=%A6%C3%A7%C3%A8%C3%A9%C3%AA%C3%AB%C3%AC%C3%AD%C3%AE%C3%AF;",
" filename*13*=%C3%B0%C3%B1%C3%B2%C3%B3%C3%B4%C3%B5%C3%B6%C3%B7%C3%B8%C3;",
" filename*14*=%B9%C3%BA%C3%BB%C3%BC%C3%BD%C3%BE%C3%BF%2E%74%78%74",
""].join("\r\n");
-var expectedCD1 = "Content-Disposition: attachment;\r\n"+
- ' filename*0=" !\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";\r\n'+
+var expectedCD1 = "Content-Disposition: attachment;\r\n" +
+ ' filename*0=" !\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";\r\n' +
' filename*1="[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.txt"\r\n';
var ParamFoldingPref = {
RFC2047: 0,
RFC2047WithCRLF: 1,
- RFC2231: 2
-}
+ RFC2231: 2,
+};
var expectedCTList0 = {
- RFC2047: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
- ' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?='+
- '=?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?='+
- '=?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?='+
- '=?UTF-8?B?wrLCs8K0wrXCtsK3wrjCucK6wrvCvMK9wr7Cv8OAw4HDgsODw4TDhcOG?='+
- '=?UTF-8?B?w4fDiMOJw4rDi8OMw43DjsOPw5DDkcOSw5PDlMOVw5bDl8OYw5nDmsOb?='+
- '=?UTF-8?B?w5zDncOew5/DoMOhw6LDo8Okw6XDpsOnw6jDqcOqw6vDrMOtw67Dr8Ow?='+
+ RFC2047: "Content-Type: text/plain; charset=US-ASCII;\r\n" +
+ ' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?=' +
+ "=?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?=" +
+ "=?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?=" +
+ "=?UTF-8?B?wrLCs8K0wrXCtsK3wrjCucK6wrvCvMK9wr7Cv8OAw4HDgsODw4TDhcOG?=" +
+ "=?UTF-8?B?w4fDiMOJw4rDi8OMw43DjsOPw5DDkcOSw5PDlMOVw5bDl8OYw5nDmsOb?=" +
+ "=?UTF-8?B?w5zDncOew5/DoMOhw6LDo8Okw6XDpsOnw6jDqcOqw6vDrMOtw67Dr8Ow?=" +
'=?UTF-8?B?w7HDssOzw7TDtcO2w7fDuMO5w7rDu8O8w73DvsO/LnR4dA==?="\r\n',
- RFC2047WithCRLF: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
- ' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?=\r\n'+
- ' =?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?=\r\n'+
- ' =?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?=\r\n'+
- ' =?UTF-8?B?wrLCs8K0wrXCtsK3wrjCucK6wrvCvMK9wr7Cv8OAw4HDgsODw4TDhcOG?=\r\n'+
- ' =?UTF-8?B?w4fDiMOJw4rDi8OMw43DjsOPw5DDkcOSw5PDlMOVw5bDl8OYw5nDmsOb?=\r\n'+
- ' =?UTF-8?B?w5zDncOew5/DoMOhw6LDo8Okw6XDpsOnw6jDqcOqw6vDrMOtw67Dr8Ow?=\r\n'+
+ RFC2047WithCRLF: "Content-Type: text/plain; charset=US-ASCII;\r\n" +
+ ' name="=?UTF-8?B?ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJ?=\r\n' +
+ " =?UTF-8?Q?JKLMNOPQRSTUVWXYZ=5b=5c=5d=5e=5f=60abcdefghijklmnopqrstuvwx?=\r\n" +
+ " =?UTF-8?B?eXp7fH1+wqDCocKiwqPCpMKlwqbCp8KowqnCqsKrwqzCrcKuwq/CsMKx?=\r\n" +
+ " =?UTF-8?B?wrLCs8K0wrXCtsK3wrjCucK6wrvCvMK9wr7Cv8OAw4HDgsODw4TDhcOG?=\r\n" +
+ " =?UTF-8?B?w4fDiMOJw4rDi8OMw43DjsOPw5DDkcOSw5PDlMOVw5bDl8OYw5nDmsOb?=\r\n" +
+ " =?UTF-8?B?w5zDncOew5/DoMOhw6LDo8Okw6XDpsOnw6jDqcOqw6vDrMOtw67Dr8Ow?=\r\n" +
' =?UTF-8?B?w7HDssOzw7TDtcO2w7fDuMO5w7rDu8O8w73DvsO/LnR4dA==?="\r\n',
- RFC2231: 'Content-Type: text/plain; charset=US-ASCII\r\n'
-}
+ RFC2231: "Content-Type: text/plain; charset=US-ASCII\r\n",
+};
var expectedCTList1 = {
- RFC2047: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
+ RFC2047: "Content-Type: text/plain; charset=US-ASCII;\r\n" +
' name="!\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.txt"\r\n',
- RFC2047WithCRLF: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
+ RFC2047WithCRLF: "Content-Type: text/plain; charset=US-ASCII;\r\n" +
' name="!\\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.txt"\r\n',
- RFC2231: 'Content-Type: text/plain; charset=US-ASCII\r\n'
-}
+ RFC2231: "Content-Type: text/plain; charset=US-ASCII\r\n",
+};
function checkAttachment(expectedCD, expectedCT) {
let msgData = mailTestUtils
.loadMessageToString(gDraftFolder, mailTestUtils.firstMsgHdr(gDraftFolder));
let pos = msgData.indexOf("Content-Disposition:");
Assert.notEqual(pos, -1);
let contentDisposition = msgData.substr(pos);
pos = 0;
@@ -123,16 +123,16 @@ async function testInput1() {
Services.prefs.setIntPref("mail.strictly_mime.parm_folding", ParamFoldingPref[folding]);
await createMessage(input1);
checkAttachment(expectedCD1, expectedCTList1[folding]);
}
}
var tests = [
testInput0,
- testInput1
-]
+ testInput1,
+];
function run_test() {
localAccountUtils.loadLocalMailAccount();
tests.forEach(x => add_task(x));
run_next_test();
}
--- a/mailnews/compose/test/unit/test_autoReply.js
+++ b/mailnews/compose/test/unit/test_autoReply.js
@@ -78,87 +78,83 @@ add_task(async function copy_gTemplateMa
let promiseCopyListener = new PromiseTestUtils.PromiseCopyListener();
// Copy gTemplateMailFile2 into the Templates folder.
MailServices.copy.CopyFileMessage(gTemplateMailFile2,
gTemplateFolder, null, true, 0, "",
promiseCopyListener, null);
await promiseCopyListener.promise;
});
-/// Test that a reply is NOT sent when the message is not addressed to "me".
+// Test that a reply is NOT sent when the message is not addressed to "me".
add_task(function testReplyingToUnaddressedFails() {
try {
testReply(0); // mail 0 is not to us!
do_throw("Replied to a message not addressed to us!");
- }
- catch (e) {
+ } catch (e) {
if (e.result != Cr.NS_ERROR_ABORT)
throw e;
// Ok! We didn't reply to the message not specifically addressed to
// us (from@foo.invalid).
}
});
-/// Test that a reply is sent when the message is addressed to "me".
+// Test that a reply is sent when the message is addressed to "me".
add_task(function testReplyingToAdressedWorksLatin1() {
try {
testReply(1); // mail 1 is addressed to us, using template-latin1
- }
- catch (e) {
- do_throw("Didn't reply properly to a message addressed to us! " + e);
+ } catch (e) {
+ do_throw("Didn't reply properly to a message addressed to us! " + e);
}
});
-/// Test that a reply is sent when the message is addressed to "me".
+// Test that a reply is sent when the message is addressed to "me".
add_task(function testReplyingToAdressedWorksUTF8() {
try {
testReply(1, 1); // mail 1 is addressed to us, template-utf8
- }
- catch (e) {
- do_throw("Didn't reply properly to a message addressed to us! " + e);
+ } catch (e) {
+ do_throw("Didn't reply properly to a message addressed to us! " + e);
}
});
-/// Test that a reply is NOT even tried when the message has no From.
+// Test that a reply is NOT even tried when the message has no From.
add_task(function testReplyingToMailWithNoFrom() {
try {
testReply(2); // mail 2 has no From
do_throw("Shouldn't even have tried to reply reply to the message " +
"with no From and no Reply-To");
- }
- catch (e) {
+ } catch (e) {
if (e.result != Cr.NS_ERROR_FAILURE)
throw e;
}
});
-/// Test reply with template.
+// Test reply with template.
function testReply(aHrdIdx, aTemplateHdrIdx = 0) {
let smtpServer = getBasicSmtpServer();
smtpServer.port = gServer.port;
let identity = getSmtpIdentity(kSender, smtpServer);
localAccountUtils.msgAccount.addIdentity(identity);
let msgHdr = mailTestUtils.getMsgHdrN(localAccountUtils.inboxFolder, aHrdIdx);
- info("Msg#" + aHrdIdx + " author=" + msgHdr.author + ", recipients=" +
+ info("Msg#" + aHrdIdx + " author=" + msgHdr.author + ", recipients=" +
msgHdr.recipients);
let templateHdr = mailTestUtils.getMsgHdrN(gTemplateFolder, aTemplateHdrIdx);
// See <method name="getTemplates"> in searchWidgets.xml
let msgTemplateUri = gTemplateFolder.URI +
"?messageId=" + templateHdr.messageId +
"&subject=" + templateHdr.mime2DecodedSubject;
MailServices.compose.replyWithTemplate(msgHdr, msgTemplateUri, null,
localAccountUtils.incomingServer);
gServer.performTest();
let headers, body;
[headers, body] = MimeParser.extractHeadersAndBody(gServer._daemon.post);
- //dump("xxxmagnus gServer._daemon.post=" + gServer._daemon.post + "\n");
+ // dump("xxxmagnus gServer._daemon.post=" + gServer._daemon.post + "\n");
Assert.ok(headers.get("Subject").startsWith("Auto: "));
Assert.equal(headers.get("Auto-submitted"), "auto-replied");
Assert.equal(headers.get("In-Reply-To"), "<" + msgHdr.messageId + ">");
Assert.equal(headers.get("References"), "<" + msgHdr.messageId + ">");
// XXX: something's wrong with how the fake server gets the data.
// The text gets converted to UTF-8 (regardless of what it is) at some point.
// Suspect a bug with how BinaryInputStream handles the strings.
if (templateHdr.Charset == "windows-1252") {
--- a/mailnews/compose/test/unit/test_bug155172.js
+++ b/mailnews/compose/test/unit/test_bug155172.js
@@ -1,20 +1,23 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Authentication tests for SMTP.
*/
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/alertTestUtils.js");
load("../../../resources/passwordStorage.js");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
var gNewPassword = null;
+/* exported confirmEx, promptPasswordPS */// for alertTestUtils.js
function confirmEx(aDialogTitle, aText, aButtonFlags, aButton0Title,
aButton1Title, aButton2Title, aCheckMsg, aCheckState) {
// Just return 2 which will is pressing button 2 - enter a new password.
return 2;
}
function promptPasswordPS(aParent, aDialogTitle, aText, aPassword,
aCheckMsg, aCheckState) {
@@ -28,17 +31,17 @@ var kIdentityMail = "identity@foo.invali
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "test.smtp@fakeserver";
// kPasswordSaved is the one defined in signons-smtp.json, the other one
// is intentionally wrong.
var kPasswordWrong = "wrong";
var kPasswordSaved = "smtptest";
-add_task(async function () {
+add_task(async function() {
registerAlertTestUtils();
function createHandler(d) {
var handler = new SMTP_RFC2821_handler(d);
// Username needs to match the login information stored in the signons json
// file.
handler.kUsername = kUsername;
handler.kPassword = kPasswordWrong;
@@ -86,23 +89,18 @@ add_task(async function () {
var transaction = server.playTransaction();
do_check_transaction(transaction, ["EHLO test",
"AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPasswordSaved),
"AUTH LOGIN",
"AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPasswordWrong),
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=159",
"RCPT TO:<" + kTo + ">",
"DATA"]);
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
});
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_bug235432.js
+++ b/mailnews/compose/test/unit/test_bug235432.js
@@ -10,37 +10,36 @@ var testmail = do_get_file("data/message
var expectedTemporaryFile;
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var msgSend = Cc["@mozilla.org/messengercompose/send;1"]
.createInstance(Ci.nsIMsgSend);
-var gCopyListener =
-{
+var gCopyListener = {
callbackFunction: null,
copiedMessageHeaderKeys: [],
- OnStartCopy: function() {},
- OnProgress: function(aProgress, aProgressMax) {},
- SetMessageKey: function(aKey) {
+ OnStartCopy() {},
+ OnProgress(aProgress, aProgressMax) {},
+ SetMessageKey(aKey) {
try {
this.copiedMessageHeaderKeys.push(aKey);
} catch (ex) {
dump(ex);
}
},
- GetMessageId: function(aMessageId) {},
- OnStopCopy: function(aStatus) {
+ GetMessageId(aMessageId) {},
+ OnStopCopy(aStatus) {
if (this.callbackFunction) {
mailTestUtils.do_timeout_function(0, this.callbackFunction,
null,
[ this.copiedMessageHeaderKeys, aStatus ]);
}
- }
+ },
};
/**
* copyFileMessageInLocalFolder
* A utility wrapper of nsIMsgCopyService.CopyFileMessage to copy a message
* into local inbox folder.
*
* @param aMessageFile An instance of nsIFile to copy.
@@ -87,16 +86,17 @@ function createExpectedTemporaryFile() {
});
let expectedFile = createTemporaryFile();
expectedFile.remove(false);
return expectedFile;
}
+/* exported OnStopCopy */// for head_compose.js
function OnStopCopy(aStatus) {
msgSend.abort();
Assert.ok(!expectedTemporaryFile.exists());
do_test_finished();
}
@@ -106,46 +106,45 @@ function run_test() {
}
function send_message_later(aMessageHeaderKeys, aStatus) {
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
.createInstance(Ci.nsIMsgComposeParams);
params.composeFields = compFields;
- let msgCompose = MailServices.compose.initCompose(params);
localAccountUtils.rootFolder.createLocalSubfolder("Drafts");
let smtpServer = getBasicSmtpServer();
let identity = getSmtpIdentity(kSender, smtpServer);
compFields.from = identity.email;
compFields.to = kTo;
let msgHdr = localAccountUtils.inboxFolder.GetMessageHeader(aMessageHeaderKeys[0]);
let messageUri = localAccountUtils.inboxFolder.getUriForMsg(msgHdr);
let attachment = Cc["@mozilla.org/messengercompose/attachment;1"]
.createInstance(Ci.nsIMsgAttachment);
attachment.url = messageUri;
- attachment.contentType = 'message/rfc822';
- attachment.name = 'Attachment e-mail';
+ attachment.contentType = "message/rfc822";
+ attachment.name = "Attachment e-mail";
compFields.addAttachment(attachment);
expectedTemporaryFile = createExpectedTemporaryFile();
msgSend.createAndSendMessage(null,
identity,
"",
compFields,
false,
false,
Ci.nsIMsgSend.nsMsgQueueForLater,
null,
- 'text/plain',
- 'bodyText\n',
+ "text/plain",
+ "bodyText\n",
null,
null,
null,
null,
copyListener,
null,
"",
Ci.nsIMsgCompType.New);
--- a/mailnews/compose/test/unit/test_bug474774.js
+++ b/mailnews/compose/test/unit/test_bug474774.js
@@ -1,21 +1,18 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Tests bug 474774 - assertions when saving send later and when sending with
* FCC switched off.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var type = null;
-var test = null;
var server;
var smtpServer;
-var sentFolder;
var originalData;
var finished = false;
var identity = null;
var testFile = do_get_file("data/429891_testcase.eml");
var kTestFileSender = "from_A@foo.invalid";
var kTestFileRecipient = "to_A@foo.invalid";
@@ -29,32 +26,30 @@ var msgSendLater = Cc["@mozilla.org/mess
// sequence and ensures the data is correct.
function msll() {
}
msll.prototype = {
_initialTotal: 0,
// nsIMsgSendLaterListener
- onStartSending: function (aTotalMessageCount) {
+ onStartSending(aTotalMessageCount) {
this._initialTotal = 1;
Assert.equal(msgSendLater.sendingMessages, true);
},
- onMessageStartSending: function (aCurrentMessage, aTotalMessageCount,
- aMessageHeader, aIdentity) {
+ onMessageStartSending(aCurrentMessage, aTotalMessageCount, aMessageHeader, aIdentity) {
},
- onMessageSendProgress: function (aCurrentMessage, aTotalMessageCount,
- aMessageSendPercent, aMessageCopyPercent) {
+ onMessageSendProgress(aCurrentMessage, aTotalMessageCount,
+ aMessageSendPercent, aMessageCopyPercent) {
// XXX Enable this function
},
- onMessageSendError: function (aCurrentMessage, aMessageHeader, aStatus,
- aMsg) {
+ onMessageSendError(aCurrentMessage, aMessageHeader, aStatus, aMsg) {
do_throw("onMessageSendError should not have been called, status: " + aStatus);
},
- onStopSending: function (aStatus, aMsg, aTotalTried, aSuccessful) {
+ onStopSending(aStatus, aMsg, aTotalTried, aSuccessful) {
print("msll onStopSending\n");
try {
Assert.equal(aSuccessful, 1);
Assert.equal(aStatus, 0);
Assert.equal(aTotalTried, 1);
Assert.equal(this._initialTotal, 1);
Assert.equal(msgSendLater.sendingMessages, false);
@@ -75,21 +70,21 @@ msll.prototype = {
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
do_test_finished();
- }
+ },
};
-function OnStopCopy(aStatus)
-{
+/* exported OnStopCopy */// for head_compose.js
+function OnStopCopy(aStatus) {
do_test_finished();
try {
Assert.equal(aStatus, 0);
// Check this is false before we start sending
Assert.equal(msgSendLater.sendingMessages, false);
@@ -122,25 +117,22 @@ function OnStopCopy(aStatus)
while (thread.hasPendingEvents())
thread.processNextEvent(true);
finished = true;
}
}
// This function does the actual send later
-function sendMessageLater()
-{
+function sendMessageLater() {
do_test_finished();
// Set up the SMTP server.
server = setupServerDaemon();
- type = "sendMessageLater";
-
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
try {
// Start the fake SMTP server
server.start();
smtpServer.port = server.port;
// A test to check that we are sending files correctly, including checking
@@ -151,22 +143,22 @@ function sendMessageLater()
msgSendLater.addListener(messageListener);
// Send the unsent message
msgSendLater.sendUnsentMessages(identity);
server.performTest();
- do_timeout(10000, function()
- {if (!finished) do_throw('Notifications of message send/copy not received');}
- );
+ do_timeout(10000, function() {
+ if (!finished)
+ do_throw("Notifications of message send/copy not received");
+ });
do_test_pending();
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
@@ -189,17 +181,17 @@ function run_test() {
smtpServer = getBasicSmtpServer(0);
identity = getSmtpIdentity(kIdentityMail, smtpServer);
account.addIdentity(identity);
account.defaultIdentity = identity;
account.incomingServer = incomingServer;
MailServices.accounts.defaultAccount = account;
- sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
+ localAccountUtils.rootFolder.createLocalSubfolder("Sent");
identity.doFcc = false;
// Now prepare to actually "send" the message later, i.e. dump it in the
// unsent messages folder.
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_detectAttachmentCharset.js
+++ b/mailnews/compose/test/unit/test_detectAttachmentCharset.js
@@ -1,15 +1,14 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for auto-detecting attachment file charset.
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
function checkAttachmentCharset(expectedCharset) {
let msgData = mailTestUtils
.loadMessageToString(gDraftFolder, mailTestUtils.firstMsgHdr(gDraftFolder));
let attachmentData = getAttachmentFromContent(msgData);
Assert.equal(expectedCharset, getContentCharset(attachmentData));
}
@@ -64,18 +63,18 @@ async function testWindows1252() {
var tests = [
testUTF8,
testUTF16BE,
testUTF16LE,
testShiftJIS,
testISO2022JP,
testKOI8R,
- testWindows1252
-]
+ testWindows1252,
+];
function run_test() {
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
Services.prefs.setIntPref("mail.strictly_mime.parm_folding", 0);
tests.forEach(x => add_task(x));
run_next_test();
--- a/mailnews/compose/test/unit/test_expandMailingLists.js
+++ b/mailnews/compose/test/unit/test_expandMailingLists.js
@@ -6,26 +6,24 @@
var MsgComposeContractID = "@mozilla.org/messengercompose/compose;1";
var MsgComposeParamsContractID = "@mozilla.org/messengercompose/composeparams;1";
var MsgComposeFieldsContractID = "@mozilla.org/messengercompose/composefields;1";
var nsIMsgCompose = Ci.nsIMsgCompose;
var nsIMsgComposeParams = Ci.nsIMsgComposeParams;
var nsIMsgCompFields = Ci.nsIMsgCompFields;
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
/**
* Helper to check population worked as expected.
* @param aTo - text in the To field
* @param aCheckTo - the expected To addresses (after possible list population)
*/
-function checkPopulate(aTo, aCheckTo)
-{
+function checkPopulate(aTo, aCheckTo) {
let msgCompose = Cc[MsgComposeContractID]
.createInstance(nsIMsgCompose);
// Set up some basic fields for compose.
let fields = Cc[MsgComposeFieldsContractID]
.createInstance(nsIMsgCompFields);
fields.to = aTo;
@@ -69,21 +67,20 @@ function run_test() {
checkPopulate("family <family>", "Simpson <homer@example.com>, Marge <marge@example.com>, " +
"\"lisa@example.com\" <lisa@example.com>, Bart <bart@foobar.invalid>, Maggie <maggie@example.com>");
checkPopulate("parents <parents>", "Simpson <homer@example.com>, Marge <marge@example.com>");
checkPopulate("kids <kids>", "\"lisa@example.com\" <lisa@example.com>, Bart <bart@foobar.invalid>, " +
"Maggie <maggie@example.com>");
checkPopulate("older-kids <older-kids>", "\"lisa@example.com\" <lisa@example.com>, Bart <bart@foobar.invalid>");
checkPopulate("bad-kids <bad-kids>", "\"lisa@example.com\" <lisa@example.com>, Bart <bart@foobar.invalid>, " +
"Maggie <maggie@example.com>");
- checkPopulate("bad-younger-kids <bad-younger-kids>", "Maggie <maggie@example.com>, "+
+ checkPopulate("bad-younger-kids <bad-younger-kids>", "Maggie <maggie@example.com>, " +
"\"lisa@example.com\" <lisa@example.com>, Bart <bart@foobar.invalid>");
// Test we don't mistake an email address for a list, with a few variations.
checkPopulate("Simpson <homer@example.com>", "Simpson <homer@example.com>");
checkPopulate("simpson <homer@example.com>", "simpson <homer@example.com>");
checkPopulate("simpson <homer@not-in-ab.invalid>", "simpson <homer@not-in-ab.invalid>");
checkPopulate("Marge <marge@example.com>", "Marge <marge@example.com>");
checkPopulate("marge <marge@example.com>", "marge <marge@example.com>");
checkPopulate("marge <marge@not-in-ab.invalid>", "marge <marge@not-in-ab.invalid>");
-
-};
+}
--- a/mailnews/compose/test/unit/test_longLines.js
+++ b/mailnews/compose/test/unit/test_longLines.js
@@ -1,15 +1,14 @@
/*
* Test ensuring that messages with "long lines" are transmitted correctly.
* Most of this test was copied from test_messageHeaders.js.
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
const {MimeParser} = ChromeUtils.import("resource:///modules/mimeParser.jsm");
var CompFields = CC("@mozilla.org/messengercompose/composefields;1",
Ci.nsIMsgCompFields);
// Copied from jsmime.js.
function stringToTypedArray(buffer) {
var typedarray = new Uint8Array(buffer.length);
@@ -47,34 +46,38 @@ function checkDraftHeadersAndBody(expect
let decodedBody = new TextDecoder(charset).decode(strView);
Assert.equal(decodedBody, expectedBody);
}
}
function checkMessageHeaders(msgData, expectedHeaders, partNum = "") {
let seen = false;
let handler = {
- startPart: function (part, headers) {
+ startPart(part, headers) {
if (part != partNum)
return;
seen = true;
for (let header in expectedHeaders) {
let expected = expectedHeaders[header];
- if (expected === undefined)
+ if (expected === undefined) {
Assert.ok(!headers.has(header));
- else {
+ } else {
let value = headers.getRawHeader(header);
Assert.equal(value.length, 1);
value[0] = value[0].replace(/boundary=[^;]*(;|$)/, "boundary=.");
Assert.equal(value[0], expected);
}
}
- }
+ },
};
- MimeParser.parseSync(msgData, handler, {onerror: function (e) { throw e; }});
+ MimeParser.parseSync(msgData, handler, {
+ onerror(e) {
+ throw e;
+ },
+ });
Assert.ok(seen);
}
// Create a line with 600 letters 'a' with acute accent, encoded as
// two bytes c3a1 in UTF-8.
let longMultibyteLine = "\u00E1".repeat(600);
// And here a line with a Korean character, encoded as three bytes
@@ -107,75 +110,75 @@ async function testBodyWithLongLine() {
let htmlMessage = "<html><head>" +
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" +
"</head><body>" + longMultibyteLine + "</body></html>";
fields.body = htmlMessage;
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "base64"
+ "Content-Transfer-Encoding": "base64",
},
htmlMessage
);
// Again, but this time as plain text.
fields.body = htmlMessage;
fields.forcePlainText = true;
fields.useMultipartAlternative = false;
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "base64"
+ "Content-Transfer-Encoding": "base64",
},
longMultibyteLine + newline // Expected body: The message without the tags.
);
// Now CJK.
fields.forcePlainText = false;
htmlMessage = "<html><head>" +
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" +
"</head><body>" + longMultibyteLineCJK + "</body></html>";
fields.body = htmlMessage;
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "base64"
+ "Content-Transfer-Encoding": "base64",
},
htmlMessage
);
// Again, but this time as plain text.
fields.body = htmlMessage;
fields.forcePlainText = true;
fields.useMultipartAlternative = false;
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "base64"
+ "Content-Transfer-Encoding": "base64",
},
longMultibyteLineCJK + newline // Expected body: The message without the tags.
);
// Now a special test for ISO-2022-JP.
fields.characterSet = "ISO-2022-JP";
fields.forcePlainText = false;
htmlMessage = "<html><head>" +
"<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-2022-JP\">" +
"</head><body>" + longMultibyteLineJapanese + "</body></html>";
fields.body = htmlMessage;
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/html; charset=ISO-2022-JP",
- "Content-Transfer-Encoding": "base64"
+ "Content-Transfer-Encoding": "base64",
},
htmlMessage,
"ISO-2022-JP"
);
// Again, but this time as plain text.
fields.body = htmlMessage;
fields.forcePlainText = true;
@@ -190,39 +193,39 @@ async function testBodyWithLongLine() {
expectedBody = expectedBody + longMultibyteLineJapanese.substr(i, 36) + " \r\n";
lastIndex = i + 36;
}
expectedBody += longMultibyteLineJapanese.substr(lastIndex) + "\r\n";
checkDraftHeadersAndBody(
{
"Content-Type": "text/plain; charset=ISO-2022-JP; format=flowed; delsp=yes",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
},
expectedBody,
"ISO-2022-JP"
);
// Again, but this time not flowed.
fields.body = htmlMessage;
Services.prefs.setBoolPref("mailnews.send_plaintext_flowed", false);
await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody(
{
"Content-Type": "text/plain; charset=ISO-2022-JP",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
},
expectedBody.replace(/ /g, ""), // No spaces expected this time.
"ISO-2022-JP"
);
}
var tests = [
testBodyWithLongLine,
-]
+];
function run_test() {
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
tests.forEach(x => add_task(x));
run_next_test();
}
--- a/mailnews/compose/test/unit/test_mailtoURL.js
+++ b/mailnews/compose/test/unit/test_mailtoURL.js
@@ -1,19 +1,17 @@
/*
* Test suite for mailto: URLs
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var nsIMailtoUrl = Ci.nsIMailtoUrl;
var COMPOSE_HTML = Ci.nsIMsgCompFormat.HTML;
var COMPOSE_DEFAULT = Ci.nsIMsgCompFormat.Default;
function run_test() {
-
function test(aTest) {
var uri = Services.io.newURI(aTest.url);
uri = uri.QueryInterface(Ci.nsIMailtoUrl);
var to = {}, cc = {}, bcc = {}, subject = {}, body = {}, html = {},
reference = {}, newsgroup = {}, composeformat = {};
uri.getMessageContents(to, cc, bcc, subject, body, html, reference,
newsgroup, composeformat);
@@ -40,17 +38,17 @@ function run_test() {
// Test cloning reparses the url by checking the to field.
let uri = Services.io.newURI(tests[0].url).QueryInterface(Ci.nsIMailtoUrl);
var to = {}, cc = {}, bcc = {}, subject = {}, body = {}, html = {},
reference = {}, newsgroup = {}, composeformat = {};
uri.getMessageContents(to, cc, bcc, subject, body, html, reference,
newsgroup, composeformat);
Assert.equal(to.value, tests[0].to);
-};
+}
var tests = [
{
url: "mailto:one@example.com",
to: "one@example.com",
cc: "",
bcc: "",
subject: "",
@@ -59,35 +57,34 @@ var tests = [
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:two@example.com?",
to: "two@example.com",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
+ newshost: "",
},
/* the heirarchical-part address shouldn't be mime-decoded */
{
url: "mailto:%3D%3FUTF-8%3FQ%3Fthree%3F%3D@example.com",
to: "=?UTF-8?Q?three?=@example.com",
cc: "",
bcc: "",
subject: "",
@@ -96,17 +93,17 @@ var tests = [
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
+ newshost: "",
},
/* a to=address should be mime-decoded */
{
url: "mailto:?to=%3D%3FUTF-8%3FQ%3Ffour%3F%3D@example.com",
to: "four@example.com",
cc: "",
bcc: "",
subject: "",
@@ -115,651 +112,615 @@ var tests = [
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:fivea@example.com?to=%3D%3FUTF-8%3FQ%3Ffiveb%3F%3D@example.com",
to: "fivea@example.com, fiveb@example.com",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:sixa@example.com?to=sixb@example.com&to=sixc@example.com",
to: "sixa@example.com, sixb@example.com, sixc@example.com",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?cc=seven@example.com",
to: "",
cc: "seven@example.com",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?cc=%3D%3FUTF-8%3FQ%3Feight%3F%3D@example.com",
to: "",
cc: "eight@example.com",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?bcc=nine@example.com",
to: "",
cc: "",
bcc: "nine@example.com",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?bcc=%3D%3FUTF-8%3FQ%3Ften%3F%3D@example.com",
to: "",
cc: "",
bcc: "ten@example.com",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?subject=foo",
to: "",
cc: "",
bcc: "",
subject: "foo",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?subject=%62%61%72",
to: "",
cc: "",
bcc: "",
subject: "bar",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?subject=%3D%3Futf-8%3FQ%3F%3DC2%3DA1encoded_subject%21%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "¡encoded subject!",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?body=one%20body",
to: "",
cc: "",
bcc: "",
subject: "",
body: "one body",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?body=two%20bodies&body=two%20lines",
to: "",
cc: "",
bcc: "",
subject: "",
body: "two bodies\ntwo lines",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?html-part=html%20part",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "html part",
reference: "",
newsgroup: "",
composeformat: COMPOSE_HTML,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?html-body=html%20body",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "html body",
reference: "",
newsgroup: "",
composeformat: COMPOSE_HTML,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?html-part=html%20part&html-body=html-body%20trumps%20earlier%20html-part",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "html-body trumps earlier html-part",
reference: "",
newsgroup: "",
composeformat: COMPOSE_HTML,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?references=%3Cref1%40example.com%3E",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "<ref1@example.com>",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?in-reply-to=%3Crepl1%40example.com%3E",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "<repl1@example.com>",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?references=%3Cref2%40example.com%3E" +
"&in-reply-to=%3Crepl2%40example.com%3E",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "<ref2@example.com> <repl2@example.com>",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?references=%3Cref3%40example.com%3E%20%3Crepl3%40example.com%3E" +
"&in-reply-to=%3Crepl3%40example.com%3E",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "<ref3@example.com> <repl3@example.com>",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?newsgroups=mozilla.dev.apps.thunderbird",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "mozilla.dev.apps.thunderbird",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?newsgroups=%3D%3FUTF-8%3FQ%3Fmozilla.test.multimedia%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "mozilla.test.multimedia",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?from=notlikely@example.com",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "notlikely@example.com",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?from=%3D%3FUTF-8%3FQ%3Fme@example.com%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "me@example.com",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?followup-to=mozilla.dev.planning",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "mozilla.dev.planning",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?followup-to=%3D%3FUTF-8%3FQ%3Fmozilla.test%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "mozilla.test",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?organization=very%20little",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "very little",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?organization=%3D%3FUTF-8%3FQ%3Fmicroscopic%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "microscopic",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?reply-to=notme@example.com",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "notme@example.com",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?reply-to=%3D%3FUTF-8%3FB%3Fw4VrZQ%3D%3D%3F%3D%20%3Cake@example.org%3E",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "Ã…ke <ake@example.org>",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?priority=1%20(People%20Are%20Dying!!1!)",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "1 (People Are Dying!!1!)",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?priority=%3D%3FUTF-8%3FQ%3F4%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "4",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?newshost=news.mozilla.org",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: "news.mozilla.org"
- },
- {
+ newshost: "news.mozilla.org",
+ }, {
url: "mailto:?newshost=%3D%3FUTF-8%3FQ%3Fnews.example.org%3F%3D",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: "news.example.org"
- },
- {
+ newshost: "news.example.org",
+ }, {
url: "mailto:?%74%4F=to&%73%55%62%4A%65%43%74=subject&%62%4F%64%59=body&%63%43=cc&%62%43%63=bcc",
to: "to",
cc: "cc",
bcc: "bcc",
subject: "subject",
body: "body",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:to1?%74%4F=to2&to=to3&subject=&%73%55%62%4A%65%43%74=subject&%62%4F%64%59=line1&body=line2&%63%43=cc1&cc=cc2&%62%43%63=bcc1&bcc=bcc2",
to: "to1, to2, to3",
cc: "cc1, cc2",
bcc: "bcc1, bcc2",
subject: "subject",
body: "line1\nline2",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:?nto=1&nsubject=2&nbody=3&ncc=4&nbcc=5",
to: "",
cc: "",
bcc: "",
subject: "",
body: "",
html: "",
reference: "",
newsgroup: "",
composeformat: COMPOSE_DEFAULT,
from: "",
followupto: "",
organization: "",
replyto: "",
priority: "",
- newshost: ""
- },
- {
+ newshost: "",
+ }, {
url: "mailto:%CE%B1?cc=%CE%B2&bcc=%CE%B3&subject=%CE%B4&body=%CE%B5" +
"&html-body=%CE%BE&newsgroups=%CE%B6&from=%CE%B7&followup-to=%CE%B8" +
"&organization=%CE%B9&reply-to=%CE%BA&priority=%CE%BB&newshost=%CE%BC",
to: "α",
cc: "β",
bcc: "γ",
subject: "δ",
body: "ε",
@@ -767,11 +728,11 @@ var tests = [
reference: "", // we expect this field to be ASCII-only
newsgroup: "ζ",
composeformat: COMPOSE_HTML,
from: "η",
followupto: "θ",
organization: "ι",
replyto: "κ",
priority: "λ",
- newshost: "μ"
+ newshost: "μ",
},
];
--- a/mailnews/compose/test/unit/test_messageHeaders.js
+++ b/mailnews/compose/test/unit/test_messageHeaders.js
@@ -51,34 +51,38 @@ function checkDraftHeaders(expectedHeade
let msgData = mailTestUtils
.loadMessageToString(gDraftFolder, mailTestUtils.firstMsgHdr(gDraftFolder));
checkMessageHeaders(msgData, expectedHeaders, partNum);
}
function checkMessageHeaders(msgData, expectedHeaders, partNum = "") {
let seen = false;
let handler = {
- startPart: function (part, headers) {
+ startPart(part, headers) {
if (part != partNum)
return;
seen = true;
for (let header in expectedHeaders) {
let expected = expectedHeaders[header];
- if (expected === undefined)
+ if (expected === undefined) {
Assert.ok(!headers.has(header));
- else {
+ } else {
let value = headers.getRawHeader(header);
Assert.equal(value.length, 1);
value[0] = value[0].replace(/boundary=[^;]*(;|$)/, "boundary=.");
Assert.equal(value[0], expected);
}
}
- }
+ },
};
- MimeParser.parseSync(msgData, handler, {onerror: function (e) { throw e; }});
+ MimeParser.parseSync(msgData, handler, {
+ onerror(e) {
+ throw e;
+ },
+ });
Assert.ok(seen);
}
async function testEnvelope() {
let fields = new CompFields();
let identity = getSmtpIdentity("from@tinderbox.invalid",
getBasicSmtpServer());
identity.fullName = "Me";
@@ -143,17 +147,17 @@ async function testIDNEnvelope() {
fields.replyTo = "Charles <charles@" + domain + ">";
fields.subject = "This is an obscure reference";
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
// The identity sets the from field here.
"From": "from@tinderbox.invalid",
"To": "Nobody <nobody@" + utf8Domain + ">",
"Cc": "Alex <alex@" + utf8Domain + ">",
- "Bcc": "Boris <boris@" + utf8Domain +">",
+ "Bcc": "Boris <boris@" + utf8Domain + ">",
"Reply-To": "Charles <charles@" + utf8Domain + ">",
"Subject": "This is an obscure reference",
});
}
async function testDraftInfo() {
let fields = new CompFields();
let identity = getSmtpIdentity("from@tinderbox.invalid",
@@ -319,51 +323,51 @@ async function testContentHeaders() {
Services.prefs.setIntPref("mail.strictly_mime.parm_folding", 2);
let fields = new CompFields();
fields.body = "A body";
let identity = getSmtpIdentity("from@tinderbox.invalid",
getBasicSmtpServer());
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
});
// non-ASCII body should be 8-bit...
fields.body = "Archæologist";
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "8bit"
+ "Content-Transfer-Encoding": "8bit",
});
// What if we change the message charset?
fields.characterSet = "ISO-8859-1";
fields.body = "Archæologist";
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
"Content-Type": "text/html; charset=ISO-8859-1",
- "Content-Transfer-Encoding": "8bit"
+ "Content-Transfer-Encoding": "8bit",
});
// Attachments
fields.body = "";
let plainAttachment = makeAttachment({
url: "data:text/plain,oïl",
- name: "attachment.txt"
+ name: "attachment.txt",
});
let plainAttachmentHeaders = {
"Content-Type": "text/plain; charset=UTF-8",
"Content-Transfer-Encoding": "base64",
"Content-Disposition": "attachment; filename=\"attachment.txt\"",
};
await richCreateMessage(fields, [plainAttachment], identity);
checkDraftHeaders({
"Content-Type": "text/html; charset=ISO-8859-1",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1");
checkDraftHeaders(plainAttachmentHeaders, "2");
plainAttachment.name = "oïl.txt";
plainAttachmentHeaders["Content-Disposition"] =
"attachment; filename*=ISO-8859-1''%6F%EF%6C%2E%74%78%74";
await richCreateMessage(fields, [plainAttachment], identity);
checkDraftHeaders(plainAttachmentHeaders, "2");
@@ -382,17 +386,17 @@ async function testContentHeaders() {
"Content-Type": "text/html",
"Content-Disposition": "attachment; filename=\"attachment.html\"",
"Content-Base": '"data:text/html,<html></html>"',
"Content-Location": '"data:text/html,<html></html>"',
};
await richCreateMessage(fields, [httpAttachment], identity);
checkDraftHeaders({
"Content-Base": undefined,
- "Content-Location": undefined
+ "Content-Location": undefined,
}, "1");
checkDraftHeaders(httpAttachmentHeaders, "2");
fields.characterSet = "UTF-8";
let cloudAttachment = makeAttachment({
url: Services.io.newFileURI(do_get_file("data/test-UTF-8.txt")).spec,
sendViaCloud: true,
cloudProviderKey: "akey",
@@ -409,77 +413,77 @@ async function testContentHeaders() {
checkDraftHeaders(cloudAttachmentHeaders, "2");
// Some multipart/alternative tests.
fields.body = "Some text";
fields.forcePlainText = false;
fields.useMultipartAlternative = true;
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
- "Content-Type": "multipart/alternative; boundary=."
+ "Content-Type": "multipart/alternative; boundary=.",
});
checkDraftHeaders({
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1");
checkDraftHeaders({
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "2");
// multipart/mixed
// + multipart/alternative
// + text/plain
// + text/html
// + text/plain attachment
await richCreateMessage(fields, [plainAttachment], identity);
checkDraftHeaders({
- "Content-Type": "multipart/mixed; boundary=."
+ "Content-Type": "multipart/mixed; boundary=.",
});
checkDraftHeaders({
- "Content-Type": "multipart/alternative; boundary=."
+ "Content-Type": "multipart/alternative; boundary=.",
}, "1");
checkDraftHeaders({
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1.1");
checkDraftHeaders({
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1.2");
checkDraftHeaders(plainAttachmentHeaders, "2");
// Three attachments, and a multipart/alternative. Oh the humanity!
await richCreateMessage(fields,
[plainAttachment, httpAttachment, cloudAttachment], identity);
checkDraftHeaders({
- "Content-Type": "multipart/mixed; boundary=."
+ "Content-Type": "multipart/mixed; boundary=.",
});
checkDraftHeaders({
- "Content-Type": "multipart/alternative; boundary=."
+ "Content-Type": "multipart/alternative; boundary=.",
}, "1");
checkDraftHeaders({
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1.1");
checkDraftHeaders({
"Content-Type": "text/html; charset=UTF-8",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
}, "1.2");
checkDraftHeaders(cloudAttachmentHeaders, "2");
checkDraftHeaders(plainAttachmentHeaders, "3");
checkDraftHeaders(httpAttachmentHeaders, "4");
// Test a request for plain text with text/html.
fields.forcePlainText = true;
fields.useMultipartAlternative = false;
await richCreateMessage(fields, [], identity);
checkDraftHeaders({
"Content-Type": "text/plain; charset=UTF-8; format=flowed",
- "Content-Transfer-Encoding": "7bit"
+ "Content-Transfer-Encoding": "7bit",
});
}
async function testSentMessage() {
let server = setupServerDaemon();
let daemon = server._daemon;
server.start();
try {
@@ -495,21 +499,21 @@ async function testSentMessage() {
"From": "test@tinderbox.invalid",
"To": "Nobody <nobody@tinderbox.invalid>",
"Cc": "Alex <alex@tinderbox.invalid>",
"Bcc": undefined,
"Reply-To": "Charles <charles@tinderbox.invalid>",
"X-Mozilla-Status": undefined,
"X-Mozilla-Keys": undefined,
"X-Mozilla-Draft-Info": undefined,
- "Fcc": undefined
+ "Fcc": undefined,
});
await sendMessage({"bcc": "Somebody <test@tinderbox.invalid"}, identity);
checkMessageHeaders(daemon.post, {
- "To": "undisclosed-recipients: ;"
+ "To": "undisclosed-recipients: ;",
});
await sendMessage({
"to": "Somebody <test@tinderbox.invalid>",
"returnReceipt": true,
"receiptHeaderType": Ci.nsIMsgMdnGenerator.eDntRrtType,
}, identity);
checkMessageHeaders(daemon.post, {
"Disposition-Notification-To": "test@tinderbox.invalid",
@@ -539,16 +543,16 @@ var tests = [
testI18NEnvelope,
testIDNEnvelope,
testDraftInfo,
testOtherHeaders,
testNewsgroups,
testSendHeaders,
testContentHeaders,
testSentMessage,
-]
+];
function run_test() {
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
tests.forEach(x => add_task(x));
run_next_test();
}
--- a/mailnews/compose/test/unit/test_nsIMsgCompFields.js
+++ b/mailnews/compose/test/unit/test_nsIMsgCompFields.js
@@ -1,13 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-/// Test that nsIMsgCompFields works properly
+// Test that nsIMsgCompFields works properly
var nsMsgCompFields = Components.Constructor(
"@mozilla.org/messengercompose/composefields;1",
Ci.nsIMsgCompFields);
function check_headers(enumerator, container) {
let checkValues = new Set(container.map(header => header.toLowerCase()));
for (let value of enumerator) {
--- a/mailnews/compose/test/unit/test_nsMsgCompose1.js
+++ b/mailnews/compose/test/unit/test_nsMsgCompose1.js
@@ -1,42 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Tests nsMsgCompose expandMailingLists.
*/
-var MsgComposeContractID = "@mozilla.org/messengercompose/compose;1";
-var MsgComposeParamsContractID = "@mozilla.org/messengercompose/composeparams;1";
-var MsgComposeFieldsContractID = "@mozilla.org/messengercompose/composefields;1";
-var nsIMsgCompose = Ci.nsIMsgCompose;
-var nsIMsgComposeParams = Ci.nsIMsgComposeParams;
-var nsIMsgCompFields = Ci.nsIMsgCompFields;
-
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
/**
* Helper to check population worked as expected.
* @param aTo - text in the To field
* @param aCheckTo - the expected To addresses (after possible ist population)
*/
-function checkPopulate(aTo, aCheckTo)
-{
- var msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+function checkPopulate(aTo, aCheckTo) {
+ var msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some basic fields for compose.
- var fields = Cc[MsgComposeFieldsContractID]
- .createInstance(nsIMsgCompFields);
+ var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+ .createInstance(Ci.nsIMsgCompFields);
fields.to = aTo;
// Set up some params
- var params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ var params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
msgCompose.expandMailingLists();
let addresses = fields.getHeader("To");
let checkEmails = MailServices.headerParser.parseDecodedHeader(aCheckTo);
@@ -57,44 +49,44 @@ function run_test() {
testAB = do_get_file("../../../data/abLists2.mab");
// Copy the file to the profile directory for a CAB
testAB.copyTo(do_get_profile(), kCABData.fileName);
// Test - Check we can initialize with fewest specified
// parameters and don't fail/crash like we did in bug 411646.
- var msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+ var msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some params
- var params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ var params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
msgCompose.initialize(params);
// Test - expandMailingLists basic functionality.
// Re-initialize
- msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+ msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some basic fields for compose.
- var fields = Cc[MsgComposeFieldsContractID]
- .createInstance(nsIMsgCompFields);
+ var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+ .createInstance(Ci.nsIMsgCompFields);
// These aren't in the address book copied above.
fields.from = "test1@foo1.invalid";
fields.to = "test2@foo1.invalid";
fields.cc = "test3@foo1.invalid";
fields.bcc = "test4@foo1.invalid";
// Set up some params
- params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
msgCompose.expandMailingLists();
Assert.equal(fields.to, "test2@foo1.invalid");
Assert.equal(fields.cc, "test3@foo1.invalid");
@@ -142,9 +134,9 @@ function run_test() {
"test4@foo.invalid,test4@com.invalid");
checkPopulate("TestList3 <TestList3>, ListTest1 <ListTest1>",
"test5@foo.invalid,test1@com.invalid,test2@com.invalid,test3@com.invalid");
// test bug 254519 rfc 2047 encoding
checkPopulate("=?iso-8859-1?Q?Sure=F6name=2C_Forename_Dr=2E?= <pb@bieringer.invalid>",
"\"Sure\u00F6name, Forename Dr.\" <pb@bieringer.invalid>");
-};
+}
--- a/mailnews/compose/test/unit/test_nsMsgCompose2.js
+++ b/mailnews/compose/test/unit/test_nsMsgCompose2.js
@@ -1,59 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for nsMsgCompose functions relating to send listeners.
*/
-var MsgComposeContractID = "@mozilla.org/messengercompose/compose;1";
-var nsIMsgCompose = Ci.nsIMsgCompose;
-
-var gMsgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+var gMsgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
var numSendListenerFunctions = 6;
var gSLAll = new Array(numSendListenerFunctions + 1);
function sendListener() {}
sendListener.prototype = {
mReceived: 0,
mAutoRemoveItem: 0,
- onStartSending: function (aMsgID, aMsgSize) {
+ onStartSending(aMsgID, aMsgSize) {
this.mReceived |= 0x01;
if (this.mAutoRemoveItem == 0x01)
gMsgCompose.removeMsgSendListener(this);
},
- onProgress: function (aMsgID, aProgress, aProgressMax) {
+ onProgress(aMsgID, aProgress, aProgressMax) {
this.mReceived |= 0x02;
if (this.mAutoRemoveItem == 0x02)
gMsgCompose.removeMsgSendListener(this);
},
- onStatus: function (aMsgID, aMsg) {
+ onStatus(aMsgID, aMsg) {
this.mReceived |= 0x04;
if (this.mAutoRemoveItem == 0x04)
gMsgCompose.removeMsgSendListener(this);
},
- onStopSending: function (aMsgID, aStatus, aMsg, aReturnFile) {
+ onStopSending(aMsgID, aStatus, aMsg, aReturnFile) {
this.mReceived |= 0x08;
if (this.mAutoRemoveItem == 0x08)
gMsgCompose.removeMsgSendListener(this);
},
- onGetDraftFolderURI: function (aFolderURI) {
+ onGetDraftFolderURI(aFolderURI) {
this.mReceived |= 0x10;
if (this.mAutoRemoveItem == 0x10)
gMsgCompose.removeMsgSendListener(this);
},
- onSendNotPerformed: function (aMsgID, aStatus) {
+ onSendNotPerformed(aMsgID, aStatus) {
this.mReceived |= 0x20;
if (this.mAutoRemoveItem == 0x20)
gMsgCompose.removeMsgSendListener(this);
- }
+ },
};
function NotifySendListeners() {
gMsgCompose.onStartSending(null, null);
gMsgCompose.onProgress(null, null, null);
gMsgCompose.onStatus(null, null);
gMsgCompose.onStopSending(null, null, null, null);
gMsgCompose.onGetDraftFolderURI(null);
@@ -107,9 +104,9 @@ function run_test() {
Assert.equal(gSLAll[i].mReceived, 0);
else
Assert.equal(gSLAll[i].mReceived, 0x3F);
}
// Test - Remove main listener
gMsgCompose.removeMsgSendListener(gSLAll[numSendListenerFunctions]);
-};
+}
--- a/mailnews/compose/test/unit/test_nsMsgCompose3.js
+++ b/mailnews/compose/test/unit/test_nsMsgCompose3.js
@@ -1,55 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for increasing the popularity of contacts via
* expandMailingLists.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var MsgComposeContractID = "@mozilla.org/messengercompose/compose;1";
-var MsgComposeParamsContractID = "@mozilla.org/messengercompose/composeparams;1";
-var MsgComposeFieldsContractID = "@mozilla.org/messengercompose/composefields;1";
-
var TESTS = [
{
email: "em@test.invalid",
// TB 2 stored popularity as hex, so we need to check correct handling.
prePopularity: "a",
- postPopularity: "11"
+ postPopularity: "11",
},
{
email: "e@test.invalid",
prePopularity: "0",
- postPopularity: "1"
+ postPopularity: "1",
},
{
email: "e@test.invalid",
prePopularity: "1",
- postPopularity: "2"
+ postPopularity: "2",
},
{
email: "em@test.invalid",
prePopularity: "11",
- postPopularity: "12"
- }
+ postPopularity: "12",
+ },
];
-function checkPopulate(aTo, aCheckTo)
-{
- let msgCompose = Cc[MsgComposeContractID].createInstance(Ci.nsIMsgCompose);
+function checkPopulate(aTo, aCheckTo) {
+ let msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some basic fields for compose.
- let fields = Cc[MsgComposeFieldsContractID].createInstance(Ci.nsIMsgCompFields);
+ let fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+ .createInstance(Ci.nsIMsgCompFields);
fields.to = aTo;
// Set up some params
- let params = Cc[MsgComposeParamsContractID]
+ let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
.createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
Assert.ok(!msgCompose.expandMailingLists());
@@ -80,9 +77,9 @@ function run_test() {
// Now we've run check populate, check the popularityIndex has increased.
card = AB.cardForEmailAddress(TESTS[i].email);
Assert.ok(!!card);
// Thunderbird 2 stored its popularityIndexes as hex, hence when we read it
// now we're going to get a hex value. The AB has a value of "a".
Assert.equal(card.getProperty("PopularityIndex", -1), TESTS[i].postPopularity);
}
-};
+}
--- a/mailnews/compose/test/unit/test_nsMsgCompose4.js
+++ b/mailnews/compose/test/unit/test_nsMsgCompose4.js
@@ -1,47 +1,37 @@
/**
* Tests nsMsgCompose determineHTMLAction.
*/
-var MsgComposeContractID = "@mozilla.org/messengercompose/compose;1";
-var MsgComposeParamsContractID = "@mozilla.org/messengercompose/composeparams;1";
-var MsgComposeFieldsContractID = "@mozilla.org/messengercompose/composefields;1";
-var nsIMsgCompose = Ci.nsIMsgCompose;
-var nsIMsgComposeParams = Ci.nsIMsgComposeParams;
-var nsIMsgCompConvertible = Ci.nsIMsgCompConvertible;
-var nsIMsgCompFields = Ci.nsIMsgCompFields;
-var SendFormat = Ci.nsIMsgCompSendFormat;
-
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
/**
* Helper to check population worked as expected.
* @param aTo text in the To field
* @param aNewsgroups text for the Newsgroups field
* @param aSendFormat |nsIMsgCompSendFormat| format to send
* @param aConvertible |nsIMsgCompConvertible| parameter to check (defaults to
* nsIMsgCompConvertible.No if undefined)
*/
function checkPopulate(aTo, aNewsgroups, aSendFormat,
- aConvertible=nsIMsgCompConvertible.No)
-{
- var msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+ aConvertible = Ci.nsIMsgCompConvertible.No) {
+ var msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some basic fields for compose.
- var fields = Cc[MsgComposeFieldsContractID]
- .createInstance(nsIMsgCompFields);
+ var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+ .createInstance(Ci.nsIMsgCompFields);
fields.to = aTo;
fields.newsgroups = aNewsgroups;
// Set up some params
- var params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ var params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
msgCompose.expandMailingLists();
Assert.equal(msgCompose.determineHTMLAction(aConvertible), aSendFormat);
}
@@ -56,105 +46,103 @@ function run_test() {
testAB = do_get_file("../../../data/abLists2.mab");
// Copy the file to the profile directory for a CAB
testAB.copyTo(do_get_profile(), kCABData.fileName);
// Test - Check we can initialize with fewest specified
// parameters and don't fail/crash like we did in bug 411646.
- var msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+ var msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some params
- var params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ var params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
msgCompose.initialize(params);
// Test - determineHTMLAction basic functionality.
// Re-initialize
- msgCompose = Cc[MsgComposeContractID]
- .createInstance(nsIMsgCompose);
+ msgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
+ .createInstance(Ci.nsIMsgCompose);
// Set up some basic fields for compose.
- var fields = Cc[MsgComposeFieldsContractID]
- .createInstance(nsIMsgCompFields);
+ var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+ .createInstance(Ci.nsIMsgCompFields);
// These aren't in the address book copied above.
fields.from = "test1@foo1.invalid";
fields.to = "test2@foo1.invalid";
fields.cc = "test3@foo1.invalid";
fields.bcc = "test4@foo1.invalid";
// Set up some params
- params = Cc[MsgComposeParamsContractID]
- .createInstance(nsIMsgComposeParams);
+ params = Cc["@mozilla.org/messengercompose/composeparams;1"]
+ .createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
- var nonHTMLRecipients = new Object();
-
- Services.prefs.setIntPref("mail.default_html_action", SendFormat.AskUser);
- Assert.equal(msgCompose.determineHTMLAction(nsIMsgCompConvertible.No),
- SendFormat.AskUser);
+ Services.prefs.setIntPref("mail.default_html_action", Ci.nsIMsgCompSendFormat.AskUser);
+ Assert.equal(msgCompose.determineHTMLAction(Ci.nsIMsgCompConvertible.No),
+ Ci.nsIMsgCompSendFormat.AskUser);
Assert.equal(fields.to, "test2@foo1.invalid");
Assert.equal(fields.cc, "test3@foo1.invalid");
Assert.equal(fields.bcc, "test4@foo1.invalid");
// Test - determineHTMLAction with plain text.
- checkPopulate("test4@foo.invalid", "", SendFormat.PlainText);
+ checkPopulate("test4@foo.invalid", "", Ci.nsIMsgCompSendFormat.PlainText);
// Test - determineHTMLAction with html.
- checkPopulate("test5@foo.invalid", "", SendFormat.HTML);
+ checkPopulate("test5@foo.invalid", "", Ci.nsIMsgCompSendFormat.HTML);
// Test - determineHTMLAction with a list of three items.
- checkPopulate("TestList1 <TestList1>", "", SendFormat.AskUser);
- checkPopulate("TestList1 <TestList1>", "", SendFormat.PlainText,
- nsIMsgCompConvertible.Plain);
+ checkPopulate("TestList1 <TestList1>", "", Ci.nsIMsgCompSendFormat.AskUser);
+ checkPopulate("TestList1 <TestList1>", "", Ci.nsIMsgCompSendFormat.PlainText,
+ Ci.nsIMsgCompConvertible.Plain);
// Test - determineHTMLAction with a list of one item.
- checkPopulate("TestList2 <TestList2>", "", SendFormat.PlainText);
+ checkPopulate("TestList2 <TestList2>", "", Ci.nsIMsgCompSendFormat.PlainText);
- checkPopulate("TestList3 <TestList3>", "", SendFormat.HTML);
+ checkPopulate("TestList3 <TestList3>", "", Ci.nsIMsgCompSendFormat.HTML);
// Test determineHTMLAction w/ mailnews.html_domains set.
Services.prefs.setCharPref("mailnews.html_domains", "foo.invalid,bar.invalid");
checkPopulate("htmlformat@foo.invalid,unknownformat@nonfoo.invalid", "",
- SendFormat.AskUser);
+ Ci.nsIMsgCompSendFormat.AskUser);
Services.prefs.clearUserPref("mailnews.html_domains");
// Test determineHTMLAction w/ mailnews.plaintext_domains set.
Services.prefs.setCharPref("mailnews.plaintext_domains", "foo.invalid,bar.invalid");
checkPopulate("plainformat@foo.invalid,unknownformat@nonfoo.invalid", "",
- SendFormat.AskUser);
+ Ci.nsIMsgCompSendFormat.AskUser);
checkPopulate("plainformat@foo.invalid,plainformat@cc.bar.invalid", "",
- SendFormat.PlainText);
+ Ci.nsIMsgCompSendFormat.PlainText);
Services.prefs.clearUserPref("mailnews.plaintext_domains");
// Test - determineHTMLAction with items from multiple address books.
checkPopulate("TestList1 <TestList1>, test3@com.invalid", "",
- SendFormat.AskUser);
+ Ci.nsIMsgCompSendFormat.AskUser);
checkPopulate("TestList2 <TestList2>, ListTest2 <ListTest2>", "",
- SendFormat.PlainText);
+ Ci.nsIMsgCompSendFormat.PlainText);
checkPopulate("TestList3 <TestList3>, ListTest1 <ListTest1>", "",
- SendFormat.AskUser);
+ Ci.nsIMsgCompSendFormat.AskUser);
// test bug 254519 rfc 2047 encoding
checkPopulate("=?iso-8859-1?Q?Sure=F6name=2C_Forename__Dr=2E?= <pb@bieringer.invalid>", "",
- SendFormat.AskUser);
+ Ci.nsIMsgCompSendFormat.AskUser);
// Try some fields with newsgroups
- checkPopulate("test4@foo.invalid", "mozilla.test", SendFormat.AskUser);
- checkPopulate("test5@foo.invalid", "mozilla.test", SendFormat.AskUser);
- checkPopulate("", "mozilla.test", SendFormat.AskUser);
-};
+ checkPopulate("test4@foo.invalid", "mozilla.test", Ci.nsIMsgCompSendFormat.AskUser);
+ checkPopulate("test5@foo.invalid", "mozilla.test", Ci.nsIMsgCompSendFormat.AskUser);
+ checkPopulate("", "mozilla.test", Ci.nsIMsgCompSendFormat.AskUser);
+}
--- a/mailnews/compose/test/unit/test_nsSmtpService1.js
+++ b/mailnews/compose/test/unit/test_nsSmtpService1.js
@@ -71,17 +71,17 @@ function run_test() {
smtpServerArray[2].username = "";
// Now check them
smtpServers = smtpService.servers;
var found = [false, false, false];
while (smtpServers.hasMoreElements()) {
- var smtpServer = smtpServers.getNext();
+ smtpServer = smtpServers.getNext();
for (i = 0; i < 3; ++i)
if (smtpServer == smtpServerArray[i])
found[i] = true;
}
Assert.equal(found, "true,true,true");
@@ -102,9 +102,9 @@ function run_test() {
// Test - Delete the servers
for (i = 0; i < 3; ++i)
smtpService.deleteServer(smtpServerArray[i]);
smtpServers = smtpService.servers;
Assert.ok(!smtpServers.hasMoreElements());
-};
+}
--- a/mailnews/compose/test/unit/test_sendBackground.js
+++ b/mailnews/compose/test/unit/test_sendBackground.js
@@ -1,58 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Tests sending a message in the background (checks auto-send works).
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var type = null;
-var test = null;
var server;
-var sentFolder;
var originalData;
var finished = false;
var identity = null;
var testFile1 = do_get_file("data/429891_testcase.eml");
var testFile2 = do_get_file("data/message1.eml");
var kTestFile1Sender = "from_A@foo.invalid";
var kTestFile1Recipient = "to_A@foo.invalid";
var kIdentityMail = "identity@foo.invalid";
-var kTo = "to@foo.invalid";
var gMsgSendLater;
// This listener handles the post-sending of the actual message and checks the
// sequence and ensures the data is correct.
function msll() {
}
msll.prototype = {
_initialTotal: 0,
// nsIMsgSendLaterListener
- onStartSending: function (aTotal) {
+ onStartSending(aTotal) {
this._initialTotal = 1;
Assert.equal(gMsgSendLater.sendingMessages, true);
Assert.equal(aTotal, 1);
},
- onMessageStartSending: function (aCurrentMessage, aTotalMessageCount,
- aMessageHeader, aIdentity) {
+ onMessageStartSending(aCurrentMessage, aTotalMessageCount, aMessageHeader, aIdentity) {
},
- onMessageSendProgress: function (aCurrentMessage, aTotalMessageCount,
- aMessageSendPercent, aMessageCopyPercent) {
+ onMessageSendProgress(aCurrentMessage, aTotalMessageCount,
+ aMessageSendPercent, aMessageCopyPercent) {
},
- onMessageSendError: function (aCurrentMessage, aMessageHeader, aStatus,
- aMsg) {
+ onMessageSendError(aCurrentMessage, aMessageHeader, aStatus, aMsg) {
do_throw("onMessageSendError should not have been called, status: " + aStatus);
},
- onStopSending: function (aStatus, aMsg, aTotalTried, aSuccessful) {
+ onStopSending(aStatus, aMsg, aTotalTried, aSuccessful) {
do_test_finished();
print("msll onStopSending\n");
try {
Assert.equal(aStatus, 0);
Assert.equal(aTotalTried, 1);
Assert.equal(aSuccessful, 1);
Assert.equal(this._initialTotal, 1);
Assert.equal(gMsgSendLater.sendingMessages, false);
@@ -76,17 +70,17 @@ msll.prototype = {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
- }
+ },
};
function run_test() {
// The point of this test - send in background.
Services.prefs.setBoolPref("mailnews.sendInBackground", true);
// Ensure we have a local mail account, an normal account and appropriate
@@ -114,17 +108,17 @@ function run_test() {
var smtpServer = getBasicSmtpServer(server.port);
identity = getSmtpIdentity(kIdentityMail, smtpServer);
account.addIdentity(identity);
account.defaultIdentity = identity;
account.incomingServer = incomingServer;
MailServices.accounts.defaultAccount = account;
- sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
+ localAccountUtils.rootFolder.createLocalSubfolder("Sent");
Assert.equal(identity.doFcc, true);
// Now prepare to actually "send" the message later, i.e. dump it in the
// unsent messages folder.
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
@@ -134,22 +128,19 @@ function run_test() {
// Sender and recipient are required for sendMessageFile but SMTP
// transaction values will be used directly from mail body.
compFields.from = "irrelevant@foo.invalid";
compFields.to = "irrelevant@foo.invalid";
var msgSend = Cc["@mozilla.org/messengercompose/send;1"]
.createInstance(Ci.nsIMsgSend);
- type = "sendMessageLater";
-
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
try {
-
// A test to check that we are sending files correctly, including checking
// what the server receives and what we output.
test = "sendMessageLater";
var messageListener = new msll();
gMsgSendLater.addListener(messageListener);
@@ -162,22 +153,22 @@ function run_test() {
// mailnews.sendInBackground set, nsMsgSendLater should just send it for
// us.
msgSend.sendMessageFile(identity, "", compFields, testFile1,
false, false, Ci.nsIMsgSend.nsMsgDeliverBackground,
null, null, null, null);
server.performTest();
- do_timeout(10000, function()
- {if (!finished) do_throw('Notifications of message send/copy not received');}
- );
+ do_timeout(10000, function() {
+ if (!finished)
+ do_throw("Notifications of message send/copy not received");
+ });
do_test_pending();
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
--- a/mailnews/compose/test/unit/test_sendMailAddressIDN.js
+++ b/mailnews/compose/test/unit/test_sendMailAddressIDN.js
@@ -1,174 +1,151 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Tests sending messages to addresses with non-ASCII characters.
*/
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
load("../../../resources/alertTestUtils.js");
-var type = null;
var test = null;
var server;
var finished = false;
var sentFolder;
var originalData;
var expectedAlertMessage;
var kSender = "from@foo.invalid";
var kToASCII = "to@foo.invalid";
var kToValid = "to@v\u00E4lid.foo.invalid";
var kToValidACE = "to@xn--vlid-loa.foo.invalid";
var kToInvalid = "b\u00F8rken.to@invalid.foo.invalid";
var kToInvalidWithoutDomain = "b\u00F8rken.to";
var NS_ERROR_BUT_DONT_SHOW_ALERT = 0x805530ef;
-
-// nsIPrompt
-function alert(aDialogText, aText)
-{
+/* exported alert */// for alertTestUtils.js
+function alert(aDialogText, aText) {
// ignore without domain situation (this is crash test)
if (test == kToInvalidWithoutDomain)
return;
// we should only get here for the kToInvalid test case
Assert.equal(test, kToInvalid);
Assert.equal(aText, expectedAlertMessage);
}
// message listener implementations
-function msgListener(aRecipient)
-{
+function msgListener(aRecipient) {
this.rcpt = aRecipient;
}
-msgListener.prototype =
-{
+msgListener.prototype = {
// nsIMsgSendListener
- onStartSending: function (aMsgID, aMsgSize) {},
- onProgress: function (aMsgID, aProgress, aProgressMax) {},
- onStatus: function (aMsgID, aMsg) {},
- onStopSending: function (aMsgID, aStatus, aMsg, aReturnFile)
- {
- try
- {
+ onStartSending(aMsgID, aMsgSize) {},
+ onProgress(aMsgID, aProgress, aProgressMax) {},
+ onStatus(aMsgID, aMsg) {},
+ onStopSending(aMsgID, aStatus, aMsg, aReturnFile) {
+ try {
Assert.equal(aStatus, 0);
do_check_transaction(server.playTransaction(),
["EHLO test",
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=" + originalData.length,
"RCPT TO:<" + this.rcpt + ">",
"DATA"]);
// Compare data file to what the server received
Assert.equal(originalData, server._daemon.post);
- }
- catch (e)
- {
+ } catch (e) {
do_throw(e);
- }
- finally
- {
+ } finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(false);
}
},
- onGetDraftFolderURI: function (aFolderURI) {},
- onSendNotPerformed: function (aMsgID, aStatus) {},
+ onGetDraftFolderURI(aFolderURI) {},
+ onSendNotPerformed(aMsgID, aStatus) {},
// nsIMsgCopyServiceListener
- OnStartCopy: function () {},
- OnProgress: function (aProgress, aProgressMax) {},
- SetMessageKey: function (aKey) {},
- GetMessageId: function (aMessageId) {},
- OnStopCopy: function (aStatus)
- {
+ OnStartCopy() {},
+ OnProgress(aProgress, aProgressMax) {},
+ SetMessageKey(aKey) {},
+ GetMessageId(aMessageId) {},
+ OnStopCopy(aStatus) {
Assert.equal(aStatus, 0);
- try
- {
+ try {
// Now do a comparison of what is in the sent mail folder
let msgData = mailTestUtils
.loadMessageToString(sentFolder, mailTestUtils.firstMsgHdr(sentFolder));
// Skip the headers etc that mailnews adds
var pos = msgData.indexOf("From:");
Assert.notEqual(pos, -1);
msgData = msgData.substr(pos);
Assert.equal(originalData, msgData);
- }
- catch (e)
- {
+ } catch (e) {
do_throw(e);
- }
- finally
- {
+ } finally {
finished = true;
do_test_finished();
}
},
// QueryInterface
QueryInterface: ChromeUtils.generateQI(["nsIMsgSendListener",
"nsIMsgCopyServiceListener"]),
-}
+};
-function DoSendTest(aRecipient, aRecipientExpected, aExceptionExpected)
-{
+function DoSendTest(aRecipient, aRecipientExpected, aExceptionExpected) {
server = setupServerDaemon();
server.start();
var smtpServer = getBasicSmtpServer(server.port);
var identity = getSmtpIdentity(kSender, smtpServer);
Assert.equal(identity.doFcc, true);
// Random test file with data we don't actually care about. ;-)
var testFile = do_get_file("data/message1.eml");
originalData = IOUtils.loadFileToString(testFile);
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
var exceptionCaught = 0;
- try
- {
+ try {
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
compFields.from = identity.email;
compFields.to = aRecipient;
var msgSend = Cc["@mozilla.org/messengercompose/send;1"]
.createInstance(Ci.nsIMsgSend);
msgSend.sendMessageFile(identity, "", compFields, testFile,
false, false, Ci.nsIMsgSend.nsMsgDeliverNow,
null, new msgListener(aRecipientExpected), null, null);
server.performTest();
- do_timeout(10000, function()
- {if (!finished) do_throw('Notifications of message send/copy not received');}
- );
+ do_timeout(10000, function() {
+ if (!finished)
+ do_throw("Notifications of message send/copy not received");
+ });
do_test_pending();
- }
- catch (e)
- {
+ } catch (e) {
exceptionCaught = e.result;
- }
- finally
- {
+ } finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
Assert.equal(exceptionCaught, aExceptionExpected);
}
-function run_test()
-{
- type = "sendMailAddressIDN";
+function run_test() {
registerAlertTestUtils();
var composeProps = Services.strings.createBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties");
expectedAlertMessage = composeProps.GetStringFromName("errorIllegalLocalPart")
.replace("%s", kToInvalid);
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
MailServices.accounts.setSpecialFolders();
--- a/mailnews/compose/test/unit/test_sendMailMessage.js
+++ b/mailnews/compose/test/unit/test_sendMailMessage.js
@@ -3,30 +3,25 @@
* Protocol tests for SMTP.
*
* This test currently consists of verifying the correct protocol sequence
* between mailnews and SMTP server. It does not check the data of the message
* either side of the link, it will be extended later to do that.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var test = null;
var server;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "testsmtp";
var kPassword = "smtptest";
-var kTestFileSender = "from_B@foo.invalid";
-var kTestFileRecipient = "to_B@foo.invalid";
-
function test_RFC2821() {
-
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
server.start();
var smtpServer = getBasicSmtpServer(server.port);
@@ -59,17 +54,17 @@ function test_RFC2821() {
Services.prefs.setBoolPref("mail.smtp.useSenderForSmtpMailFrom", true);
MailServices.smtp.sendMailMessage(testFile, kTo, identity, kSender,
null, null, null, null,
false, {}, {});
server.performTest();
- var transaction = server.playTransaction();
+ transaction = server.playTransaction();
do_check_transaction(transaction, ["EHLO test",
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=159",
"RCPT TO:<" + kTo + ">",
"DATA"]);
server.resetTest();
// This time with auth.
@@ -84,17 +79,17 @@ function test_RFC2821() {
Services.prefs.setBoolPref("mail.smtp.useSenderForSmtpMailFrom", false);
MailServices.smtp.sendMailMessage(testFile, kTo, identity, kSender,
null, null, null, null,
false, {}, {});
server.performTest();
- var transaction = server.playTransaction();
+ transaction = server.playTransaction();
do_check_transaction(transaction, ["EHLO test",
"AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPassword),
"MAIL FROM:<" + kIdentityMail + "> BODY=8BITMIME SIZE=159",
"RCPT TO:<" + kTo + ">",
"DATA"]);
server.resetTest();
@@ -102,23 +97,22 @@ function test_RFC2821() {
Services.prefs.setBoolPref("mail.smtp.useSenderForSmtpMailFrom", true);
MailServices.smtp.sendMailMessage(testFile, kTo, identity, kSender,
null, null, null, null,
false, {}, {});
server.performTest();
- var transaction = server.playTransaction();
+ transaction = server.playTransaction();
do_check_transaction(transaction, ["EHLO test",
"AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPassword),
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=159",
"RCPT TO:<" + kTo + ">",
"DATA"]);
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
--- a/mailnews/compose/test/unit/test_sendMessageFile.js
+++ b/mailnews/compose/test/unit/test_sendMessageFile.js
@@ -8,37 +8,35 @@
* - Correct saving of the message to the sent folder.
*
* Originally written to test bug 429891 where saving to the sent folder was
* mangling the message.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var type = null;
-var test = null;
var server;
var sentFolder;
var originalData;
var finished = false;
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
function msl() {}
msl.prototype = {
// nsIMsgSendListener
- onStartSending: function (aMsgID, aMsgSize) {
+ onStartSending(aMsgID, aMsgSize) {
},
- onProgress: function (aMsgID, aProgress, aProgressMax) {
+ onProgress(aMsgID, aProgress, aProgressMax) {
},
- onStatus: function (aMsgID, aMsg) {
+ onStatus(aMsgID, aMsg) {
},
- onStopSending: function (aMsgID, aStatus, aMsg, aReturnFile) {
+ onStopSending(aMsgID, aStatus, aMsg, aReturnFile) {
try {
Assert.equal(aStatus, 0);
do_check_transaction(server.playTransaction(),
["EHLO test",
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=" + originalData.length,
"RCPT TO:<" + kTo + ">",
"DATA"]);
@@ -50,31 +48,31 @@ msl.prototype = {
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(false);
}
},
- onGetDraftFolderURI: function (aFolderURI) {
+ onGetDraftFolderURI(aFolderURI) {
},
- onSendNotPerformed: function (aMsgID, aStatus) {
+ onSendNotPerformed(aMsgID, aStatus) {
},
// nsIMsgCopyServiceListener
- OnStartCopy: function () {
+ OnStartCopy() {
},
- OnProgress: function (aProgress, aProgressMax) {
+ OnProgress(aProgress, aProgressMax) {
},
- SetMessageKey: function (aKey) {
+ SetMessageKey(aKey) {
},
- GetMessageId: function (aMessageId) {
+ GetMessageId(aMessageId) {
},
- OnStopCopy: function (aStatus) {
+ OnStopCopy(aStatus) {
Assert.equal(aStatus, 0);
try {
// Now do a comparison of what is in the sent mail folder
let msgData = mailTestUtils
.loadMessageToString(sentFolder, mailTestUtils.firstMsgHdr(sentFolder));
// Skip the headers etc that mailnews adds
var pos = msgData.indexOf("From:");
@@ -89,23 +87,21 @@ msl.prototype = {
finished = true;
do_test_finished();
}
},
// QueryInterface
QueryInterface: ChromeUtils.generateQI(["nsIMsgSendListener",
"nsIMsgCopyServiceListener"]),
-}
+};
function run_test() {
server = setupServerDaemon();
- type = "sendMessageFile";
-
// Test file - for bug 429891
var testFile = do_get_file("data/429891_testcase.eml");
originalData = IOUtils.loadFileToString(testFile);
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
MailServices.accounts.setSpecialFolders();
@@ -139,22 +135,22 @@ function run_test() {
var messageListener = new msl();
msgSend.sendMessageFile(identity, "", compFields, testFile,
false, false, Ci.nsIMsgSend.nsMsgDeliverNow,
null, messageListener, null, null);
server.performTest();
- do_timeout(10000, function()
- {if (!finished) do_throw('Notifications of message send/copy not received');}
- );
+ do_timeout(10000, function() {
+ if (!finished)
+ do_throw("Notifications of message send/copy not received");
+ });
do_test_pending();
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
--- a/mailnews/compose/test/unit/test_sendMessageLater.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater.js
@@ -8,61 +8,55 @@
* - Correct saving of the message to the sent folder.
*
* Originally written to test bug 429891 where saving to the sent folder was
* mangling the message.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var type = null;
-var test = null;
var server;
var smtpServer;
-var sentFolder;
var originalData;
var finished = false;
var identity = null;
var testFile = do_get_file("data/429891_testcase.eml");
var kTestFileSender = "from_A@foo.invalid";
var kTestFileRecipient = "to_A@foo.invalid";
var kIdentityMail = "identity@foo.invalid";
-var kToEncodedDisplayName = "=?UTF-8?B?RnLDqcOpZGxlLCBUZXN0?="; // "Fréédle, Test"
var msgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"]
.getService(Ci.nsIMsgSendLater);
// This listener handles the post-sending of the actual message and checks the
// sequence and ensures the data is correct.
function msll() {
}
msll.prototype = {
_initialTotal: 0,
_startedSending: false,
// nsIMsgSendLaterListener
- onStartSending: function (aTotalMessageCount) {
+ onStartSending(aTotalMessageCount) {
this._initialTotal = 1;
Assert.equal(msgSendLater.sendingMessages, true);
},
- onMessageStartSending: function (aCurrentMessage, aTotalMessageCount,
- aMessageHeader, aIdentity) {
+ onMessageStartSending(aCurrentMessage, aTotalMessageCount, aMessageHeader, aIdentity) {
this._startedSending = true;
},
- onMessageSendProgress: function (aCurrentMessage, aTotalMessageCount,
- aMessageSendPercent, aMessageCopyPercent) {
+ onMessageSendProgress(aCurrentMessage, aTotalMessageCount,
+ aMessageSendPercent, aMessageCopyPercent) {
// XXX Enable this function
},
- onMessageSendError: function (aCurrentMessage, aMessageHeader, aStatus,
- aMsg) {
+ onMessageSendError(aCurrentMessage, aMessageHeader, aStatus, aMsg) {
do_throw("onMessageSendError should not have been called, status: " + aStatus);
},
- onStopSending: function (aStatus, aMsg, aTotalTried, aSuccessful) {
+ onStopSending(aStatus, aMsg, aTotalTried, aSuccessful) {
do_test_finished();
print("msll onStopSending\n");
try {
Assert.equal(this._startedSending, true);
Assert.equal(aStatus, 0);
Assert.equal(aTotalTried, 1);
Assert.equal(aSuccessful, 1);
Assert.equal(this._initialTotal, 1);
@@ -83,19 +77,20 @@ msll.prototype = {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
- }
+ },
};
+/* exported OnStopCopy */// for head_compose.js
function OnStopCopy(aStatus) {
dump("OnStopCopy()\n");
try {
Assert.equal(aStatus, 0);
// Check this is false before we start sending
Assert.equal(msgSendLater.sendingMessages, false);
@@ -130,23 +125,20 @@ function OnStopCopy(aStatus) {
while (thread.hasPendingEvents())
thread.processNextEvent(true);
finished = true;
}
}
// This function does the actual send later
-function sendMessageLater()
-{
+function sendMessageLater() {
// Set up the SMTP server.
server = setupServerDaemon();
- type = "sendMessageLater";
-
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
try {
// Start the fake SMTP server
server.start();
smtpServer.port = server.port;
// A test to check that we are sending files correctly, including checking
@@ -157,19 +149,20 @@ function sendMessageLater()
msgSendLater.addListener(messageListener);
// Send the unsent message
msgSendLater.sendUnsentMessages(identity);
server.performTest();
- do_timeout(10000, function()
- {if (!finished) do_throw('Notifications of message send/copy not received');}
- );
+ do_timeout(10000, function() {
+ if (!finished)
+ do_throw("Notifications of message send/copy not received");
+ });
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
@@ -195,17 +188,17 @@ function run_test() {
smtpServer = getBasicSmtpServer(1);
identity = getSmtpIdentity(kIdentityMail, smtpServer);
account.addIdentity(identity);
account.defaultIdentity = identity;
account.incomingServer = incomingServer;
MailServices.accounts.defaultAccount = account;
- sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
+ localAccountUtils.rootFolder.createLocalSubfolder("Sent");
Assert.equal(identity.doFcc, true);
// Now prepare to actually "send" the message later, i.e. dump it in the
// unsent messages folder.
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_sendMessageLater2.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater2.js
@@ -7,99 +7,87 @@
* from one send later instance, however due to the fact we use one connection
* per message sent, it is very difficult to consistently get the fake server
* reconected in time for the next connection. Thus, sending of multiple
* messages is currently disabled (but commented out for local testing if
* required), when we fix bug 136871 we should be able to enable the multiple
* messages option.
*/
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
load("../../../resources/logHelper.js");
load("../../../resources/asyncTestUtils.js");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var test = "sendMessageLater";
var server = null;
var smtpServer;
var gSentFolder;
-var originalData;
var identity = null;
-var gMsgFile =
-[
+var gMsgFile = [
do_get_file("data/message1.eml"),
- do_get_file("data/429891_testcase.eml")
+ do_get_file("data/429891_testcase.eml"),
];
-var kTestFileSender =
-[
+var kTestFileSender = [
"from_B@foo.invalid",
- "from_A@foo.invalid"
+ "from_A@foo.invalid",
];
-var kTestFileRecipient =
-[
+var kTestFileRecipient = [
"to_B@foo.invalid",
- "to_A@foo.invalid"
+ "to_A@foo.invalid",
];
var gMsgFileData = [];
var gMsgOrder = [];
-var gCurTestNum = 0;
var gLastSentMessage = 0;
-// gMessageSendStatus
-// 0 = initial value
-// 1 = send completed before exiting sendUnsentMessages
-// 2 = sendUnsentMessages has exited.
-var gMessageSendStatus = 0;
-
var kIdentityMail = "identity@foo.invalid";
var msgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"]
.getService(Ci.nsIMsgSendLater);
// This listener handles the post-sending of the actual message and checks the
// sequence and ensures the data is correct.
function msll() {
}
msll.prototype = {
- checkMessageSend: function(aCurrentMessage) {
+ checkMessageSend(aCurrentMessage) {
do_check_transaction(server.playTransaction(),
["EHLO test",
"MAIL FROM:<" + kTestFileSender[gMsgOrder[aCurrentMessage - 1]] + "> BODY=8BITMIME SIZE=" + gMsgFileData[gMsgOrder[aCurrentMessage - 1]].length,
"RCPT TO:<" + kTestFileRecipient[gMsgOrder[aCurrentMessage - 1]] + ">",
"DATA"]);
// Compare data file to what the server received
Assert.equal(gMsgFileData[gMsgOrder[aCurrentMessage - 1]], server._daemon.post);
},
// nsIMsgSendLaterListener
- onStartSending: function (aTotalMessageCount) {
+ onStartSending(aTotalMessageCount) {
Assert.equal(aTotalMessageCount, gMsgOrder.length);
Assert.equal(msgSendLater.sendingMessages, true);
},
- onMessageStartSending: function (aCurrentMessage, aTotalMessageCount,
- aMessageHeader, aIdentity) {
+ onMessageStartSending(aCurrentMessage, aTotalMessageCount, aMessageHeader, aIdentity) {
if (gLastSentMessage > 0)
this.checkMessageSend(aCurrentMessage);
Assert.equal(gLastSentMessage + 1, aCurrentMessage);
gLastSentMessage = aCurrentMessage;
},
- onMessageSendProgress: function (aCurrentMessage, aTotalMessageCount,
- aMessageSendPercent, aMessageCopyPercent) {
+ onMessageSendProgress(aCurrentMessage, aTotalMessageCount,
+ aMessageSendPercent, aMessageCopyPercent) {
Assert.equal(aTotalMessageCount, gMsgOrder.length);
Assert.equal(gLastSentMessage, aCurrentMessage);
Assert.equal(msgSendLater.sendingMessages, true);
},
- onMessageSendError: function (aCurrentMessage, aMessageHeader, aStatus,
- aMsg) {
+ onMessageSendError(aCurrentMessage, aMessageHeader, aStatus, aMsg) {
do_throw("onMessageSendError should not have been called, status: " + aStatus);
},
- onStopSending: function (aStatus, aMsg, aTotalTried, aSuccessful) {
+ onStopSending(aStatus, aMsg, aTotalTried, aSuccessful) {
try {
Assert.equal(aStatus, 0);
Assert.equal(aTotalTried, aSuccessful);
Assert.equal(msgSendLater.sendingMessages, false);
// Check that the send later service now thinks we don't have messages to
// send.
Assert.equal(msgSendLater.hasUnsentMessages(identity), false);
@@ -110,42 +98,41 @@ msll.prototype = {
do_throw(e);
}
// The extra timeout here is to work around an issue where sometimes
// the sendUnsentMessages is completely synchronous up until onStopSending
// and sometimes it isn't. This protects us for the synchronous case to
// allow the sendUnsentMessages function to complete and exit before we
// call async_driver.
do_timeout(0, async_driver);
- }
+ },
};
+/* exported OnStopCopy */// for head_compose.js
// This function is used to find out when the copying of the message to the
// unsent message folder is completed, and hence can fire off the actual
// sending of the message.
-function OnStopCopy(aStatus)
-{
+function OnStopCopy(aStatus) {
Assert.equal(aStatus, 0);
// Check this is false before we start sending
Assert.equal(msgSendLater.sendingMessages, false);
// Check that the send later service thinks we have messages to send.
Assert.equal(msgSendLater.hasUnsentMessages(identity), true);
// Check we have a message in the unsent message folder
Assert.equal(gSentFolder.getTotalMessages(false), gMsgOrder.length);
// Start the next step after a brief time so that functions can finish
// properly
async_driver();
}
-function sendMessageLater(aTestFileIndex)
-{
+function sendMessageLater(aTestFileIndex) {
gMsgOrder.push(aTestFileIndex);
// Prepare to actually "send" the message later, i.e. dump it in the
// unsent messages folder.
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
@@ -160,47 +147,39 @@ function sendMessageLater(aTestFileIndex
.createInstance(Ci.nsIMsgSend);
msgSend.sendMessageFile(identity, "", compFields, gMsgFile[aTestFileIndex],
false, false, Ci.nsIMsgSend.nsMsgQueueForLater,
null, copyListener, null, null);
return false;
}
-function resetCounts()
-{
+function resetCounts() {
gMsgOrder = [];
gLastSentMessage = 0;
}
// This function does the actual send later
-function sendUnsentMessages()
-{
- gMessageSendStatus = 0;
+function sendUnsentMessages() {
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
try {
// Start the fake SMTP server
server.start();
smtpServer.port = server.port;
// Send the unsent message
msgSendLater.sendUnsentMessages(identity);
server.performTest();
} catch (e) {
do_throw(e);
}
return false;
}
-function runServerTest()
-{
- server.performTest();
-}
-
function* actually_run_test() {
dump("in actually_run_test\n");
dump("Copy Message from file to folder\n");
yield async_run({func: sendMessageLater, args: [0]});
dump("Send unsent message\n");
yield async_run({func: sendUnsentMessages});
--- a/mailnews/compose/test/unit/test_sendMessageLater3.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater3.js
@@ -3,81 +3,76 @@
* Protocol tests for SMTP.
*
* For trying to send a message later with no server connected, this test
* verifies:
* - A correct status response.
* - A correct state at the end of attempting to send.
*/
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
load("../../../resources/alertTestUtils.js");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var type = null;
-var test = null;
-var server;
-var sentFolder;
-var transaction;
var originalData;
-var finished = false;
var identity = null;
var testFile = do_get_file("data/429891_testcase.eml");
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var msgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"]
.getService(Ci.nsIMsgSendLater);
+/* exported alert */// for alertTestUtils.js
function alert(aDialogTitle, aText) {
dump("Hiding Alert {\n" + aText + "\n} End Alert\n");
}
// This listener handles the post-sending of the actual message and checks the
// sequence and ensures the data is correct.
function msll() {
}
msll.prototype = {
_initialTotal: 0,
_errorRaised: false,
// nsIMsgSendLaterListener
- onStartSending: function (aTotal) {
+ onStartSending(aTotal) {
this._initialTotal = 1;
Assert.equal(msgSendLater.sendingMessages, true);
},
- onMessageStartSending: function (aCurrentMessage, aTotalMessageCount,
- aMessageHeader, aIdentity) {
+ onMessageStartSending(aCurrentMessage, aTotalMessageCount, aMessageHeader, aIdentity) {
},
- onMessageSendProgress: function (aCurrentMessage, aTotalMessageCount,
- aMessageSendPercent, aMessageCopyPercent) {
+ onMessageSendProgress(aCurrentMessage, aTotalMessageCount,
+ aMessageSendPercent, aMessageCopyPercent) {
},
- onMessageSendError: function (aCurrentMessage, aMessageHeader, aStatus,
- aMsg) {
+ onMessageSendError(aCurrentMessage, aMessageHeader, aStatus, aMsg) {
this._errorRaised = true;
},
- onStopSending: function (aStatus, aMsg, aTotal, aSuccessful) {
+ onStopSending(aStatus, aMsg, aTotal, aSuccessful) {
print("msll onStopSending\n");
// NS_ERROR_SMTP_SEND_FAILED_REFUSED is 2153066798
Assert.equal(aStatus, 2153066798);
Assert.equal(aTotal, 1);
Assert.equal(aSuccessful, 0);
Assert.equal(this._initialTotal, 1);
Assert.equal(this._errorRaised, true);
Assert.equal(msgSendLater.sendingMessages, false);
// Check that the send later service still thinks we have messages to send.
Assert.equal(msgSendLater.hasUnsentMessages(identity), true);
do_test_finished();
- }
+ },
};
+/* exported OnStopCopy */// for head_compose.js
function OnStopCopy(aStatus) {
Assert.equal(aStatus, 0);
// Check this is false before we start sending
Assert.equal(msgSendLater.sendingMessages, false);
let folder = msgSendLater.getUnsentMessagesFolder(identity);
@@ -100,18 +95,17 @@ function OnStopCopy(aStatus) {
// Check the data is matching.
Assert.equal(originalData, msgData);
do_timeout(0, sendMessageLater);
}
// This function does the actual send later
-function sendMessageLater()
-{
+function sendMessageLater() {
// No server for this test, just attempt to send unsent and wait.
var messageListener = new msll();
msgSendLater.addListener(messageListener);
// Send the unsent message
msgSendLater.sendUnsentMessages(identity);
}
@@ -137,17 +131,17 @@ function run_test() {
var smtpServer = getBasicSmtpServer();
identity = getSmtpIdentity(kSender, smtpServer);
account.addIdentity(identity);
account.defaultIdentity = identity;
account.incomingServer = incomingServer;
MailServices.accounts.defaultAccount = account;
- sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
+ localAccountUtils.rootFolder.createLocalSubfolder("Sent");
identity.doFcc = false;
// Now prepare to actually "send" the message later, i.e. dump it in the
// unsent messages folder.
var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_sendObserver.js
+++ b/mailnews/compose/test/unit/test_sendObserver.js
@@ -1,32 +1,30 @@
/*
* Tests that the mail-set-sender observer, used by extensions to modify the
* outgoing server, works.
*
* This is adapted from test_messageHeaders.js
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var {MimeParser} = ChromeUtils.import("resource:///modules/mimeParser.jsm");
var CompFields = CC("@mozilla.org/messengercompose/composefields;1",
Ci.nsIMsgCompFields);
// nsIObserver implementation.
var gData = "";
var observer = {
- observe: function (aSubject, aTopic, aData) {
+ observe(aSubject, aTopic, aData) {
if (aTopic == "mail-set-sender") {
Assert.ok(aSubject instanceof Ci.nsIMsgCompose);
gData = aData;
}
- }
-}
+ },
+};
add_task(async function testObserver() {
let fields = new CompFields();
let identity = getSmtpIdentity("from@tinderbox.invalid",
getBasicSmtpServer());
identity.fullName = "Observer Tester";
fields.to = "Emile <nobody@tinderbox.invalid>";
fields.cc = "Alex <alex@tinderbox.invalid>";
--- a/mailnews/compose/test/unit/test_smtp8bitMime.js
+++ b/mailnews/compose/test/unit/test_smtp8bitMime.js
@@ -3,42 +3,39 @@
* 8BITMIME tests for SMTP.
*
* This test verifies that 8BITMIME is sent to the server only if the server
* advertises it AND if mail.strictly_mime doesn't force us to send 7bit.
* It does not check the data of the message on either side of the link.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var test = null;
var server;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
// aStrictMime: Test if mail.strictly_mime omits the BODY=8BITMIME attribute.
// aServer8bit: Test if BODY=8BITMIME is only sent if advertised by the server.
function test_8bitmime(aStrictMime, aServer8bit) {
-
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
server.start();
var smtpServer = getBasicSmtpServer(server.port);
var identity = getSmtpIdentity(kIdentityMail, smtpServer);
// Handle the server in a try/catch/finally loop so that we always will stop
// the server if something fails.
try {
-
test = "Strictly MIME" + (aStrictMime ? "on (7bit" : "off (8bit") +
", 8BITMIME " + (aServer8bit ? "" : "not ") + "advertised)";
Services.prefs.setBoolPref("mail.strictly_mime", aStrictMime);
MailServices.smtp.sendMailMessage(testFile, kTo, identity, kSender,
null, null, null, null,
false, {}, {});
@@ -49,18 +46,16 @@ function test_8bitmime(aStrictMime, aSer
do_check_transaction(transaction, ["EHLO test",
"MAIL FROM:<" + kSender +
(!aStrictMime && aServer8bit ?
"> BODY=8BITMIME SIZE=159" : "> SIZE=159"),
"RCPT TO:<" + kTo + ">",
"DATA"]);
server.resetTest();
-
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
--- a/mailnews/compose/test/unit/test_smtpAuthMethods.js
+++ b/mailnews/compose/test/unit/test_smtpAuthMethods.js
@@ -18,53 +18,57 @@ var kPassword = "wilma";
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var MAILFROM = "MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=159";
var RCPTTO = "RCPT TO:<" + kTo + ">";
var AUTHPLAIN = "AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPassword);
var tests = [
- { title: "Cleartext password, with server supporting AUTH PLAIN, LOGIN, and CRAM",
- clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
- serverAuthMethods : [ "PLAIN", "LOGIN", "CRAM-MD5" ],
- expectSuccess : true,
- transaction: [ "EHLO test", AUTHPLAIN, MAILFROM, RCPTTO, "DATA" ] },
- { title: "Cleartext password, with server only supporting AUTH LOGIN",
- clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
- serverAuthMethods : [ "LOGIN" ],
- expectSuccess : true,
- transaction: [ "EHLO test", "AUTH LOGIN", MAILFROM, RCPTTO, "DATA" ] },
- { title: "Encrypted password, with server supporting AUTH PLAIN, LOGIN and CRAM",
- clientAuthMethod : Ci.nsMsgAuthMethod.passwordEncrypted,
- serverAuthMethods : [ "PLAIN", "LOGIN", "CRAM-MD5" ],
- expectSuccess : true,
- transaction: [ "EHLO test", "AUTH CRAM-MD5", MAILFROM, RCPTTO, "DATA" ] },
- { title: "Encrypted password, with server only supporting AUTH PLAIN (must fail)",
- clientAuthMethod : Ci.nsMsgAuthMethod.passwordEncrypted,
- serverAuthMethods : [ "PLAIN" ],
- expectSuccess : false,
- transaction: [ "EHLO test"] },
- { title: "Any secure method, with server supporting AUTH PLAIN, LOGIN and CRAM",
- clientAuthMethod : Ci.nsMsgAuthMethod.secure,
- serverAuthMethods : [ "PLAIN" , "LOGIN", "CRAM-MD5" ],
- expectSuccess : true,
- transaction: [ "EHLO test", "AUTH CRAM-MD5", MAILFROM, RCPTTO, "DATA" ] },
- { title: "Any secure method, with server only supporting AUTH PLAIN (must fail)",
- clientAuthMethod : Ci.nsMsgAuthMethod.secure,
- serverAuthMethods : [ "PLAIN" ],
- expectSuccess : false,
- transaction: [ "EHLO test" ] },
+ {
+ title: "Cleartext password, with server supporting AUTH PLAIN, LOGIN, and CRAM",
+ clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+ serverAuthMethods: [ "PLAIN", "LOGIN", "CRAM-MD5" ],
+ expectSuccess: true,
+ transaction: [ "EHLO test", AUTHPLAIN, MAILFROM, RCPTTO, "DATA" ],
+ }, {
+ title: "Cleartext password, with server only supporting AUTH LOGIN",
+ clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+ serverAuthMethods: [ "LOGIN" ],
+ expectSuccess: true,
+ transaction: [ "EHLO test", "AUTH LOGIN", MAILFROM, RCPTTO, "DATA" ],
+ }, {
+ title: "Encrypted password, with server supporting AUTH PLAIN, LOGIN and CRAM",
+ clientAuthMethod: Ci.nsMsgAuthMethod.passwordEncrypted,
+ serverAuthMethods: [ "PLAIN", "LOGIN", "CRAM-MD5" ],
+ expectSuccess: true,
+ transaction: [ "EHLO test", "AUTH CRAM-MD5", MAILFROM, RCPTTO, "DATA" ],
+ }, {
+ title: "Encrypted password, with server only supporting AUTH PLAIN (must fail)",
+ clientAuthMethod: Ci.nsMsgAuthMethod.passwordEncrypted,
+ serverAuthMethods: [ "PLAIN" ],
+ expectSuccess: false,
+ transaction: [ "EHLO test"],
+ }, {
+ title: "Any secure method, with server supporting AUTH PLAIN, LOGIN and CRAM",
+ clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+ serverAuthMethods: [ "PLAIN", "LOGIN", "CRAM-MD5" ],
+ expectSuccess: true,
+ transaction: [ "EHLO test", "AUTH CRAM-MD5", MAILFROM, RCPTTO, "DATA" ],
+ }, {
+ title: "Any secure method, with server only supporting AUTH PLAIN (must fail)",
+ clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+ serverAuthMethods: [ "PLAIN" ],
+ expectSuccess: false,
+ transaction: [ "EHLO test" ],
+ },
];
-
-
function nextTest() {
- if (tests.length == 0)
- {
+ if (tests.length == 0) {
// this is sync, so we run into endTest() at the end of run_test() now
return;
}
server.resetTest();
var curTest = tests.shift();
test = curTest.title;
dump("NEXT test: " + curTest.title + "\n");
@@ -106,17 +110,16 @@ function run_test() {
smtpServer.socketType = Ci.nsMsgSocketType.plain;
smtpServer.username = kUsername;
smtpServer.password = kPassword;
identity = getSmtpIdentity(kIdentityMail, smtpServer);
testFile = do_get_file("data/message1.eml");
nextTest();
-
} catch (e) {
do_throw(e);
} finally {
endTest();
}
}
function endTest() {
--- a/mailnews/compose/test/unit/test_smtpPassword.js
+++ b/mailnews/compose/test/unit/test_smtpPassword.js
@@ -1,41 +1,42 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Authentication tests for SMTP.
*/
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/passwordStorage.js");
var server;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "testsmtp";
// Password needs to match the login information stored in the signons json
// file.
var kPassword = "smtptest";
-add_task(async function () {
+add_task(async function() {
function createHandler(d) {
var handler = new SMTP_RFC2821_handler(d);
// Username needs to match the login information stored in the signons json
// file.
handler.kUsername = kUsername;
handler.kPassword = kPassword;
handler.kAuthRequired = true;
return handler;
}
server = setupServerDaemon(createHandler);
// Prepare files for passwords (generated by a script in bug 1018624).
- await setupForPassword("signons-mailnews1.8.json")
+ await setupForPassword("signons-mailnews1.8.json");
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
// Handle the server in a try/catch/finally loop so that we always will stop
@@ -60,23 +61,18 @@ add_task(async function () {
server.performTest();
var transaction = server.playTransaction();
do_check_transaction(transaction, ["EHLO test",
"AUTH PLAIN " + AuthPLAIN.encodeLine(kUsername, kPassword),
"MAIL FROM:<" + kSender + "> BODY=8BITMIME SIZE=159",
"RCPT TO:<" + kTo + ">",
"DATA"]);
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
});
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_smtpPassword2.js
+++ b/mailnews/compose/test/unit/test_smtpPassword2.js
@@ -1,39 +1,39 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
* Extra tests for SMTP passwords (forgetPassword)
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/passwordStorage.js");
var kUser1 = "testsmtp";
var kUser2 = "testsmtpa";
var kProtocol = "smtp";
var kHostname = "localhost";
var kServerUrl = kProtocol + "://" + kHostname;
-add_task(async function () {
+add_task(async function() {
// Prepare files for passwords (generated by a script in bug 1018624).
- await setupForPassword("signons-mailnews1.8-multiple.json")
+ await setupForPassword("signons-mailnews1.8-multiple.json");
// Set up the basic accounts and folders.
localAccountUtils.loadLocalMailAccount();
var smtpServer1 = getBasicSmtpServer();
var smtpServer2 = getBasicSmtpServer();
smtpServer1.authMethod = 3;
smtpServer1.username = kUser1;
smtpServer2.authMethod = 3;
smtpServer2.username = kUser2;
- var i;
var count = {};
// Test - Check there are two logins to begin with.
let logins = Services.logins.findLogins(count, kServerUrl, null, kServerUrl);
Assert.equal(count.value, 2);
// These will either be one way around or the other.
@@ -57,12 +57,8 @@ add_task(async function () {
smtpServer2.forgetPassword();
logins = Services.logins.findLogins(count, kServerUrl, null, kServerUrl);
// There should be no login left.
Assert.equal(count.value, 0);
Assert.equal(logins.length, 0);
});
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_smtpPasswordFailure1.js
+++ b/mailnews/compose/test/unit/test_smtpPasswordFailure1.js
@@ -7,35 +7,36 @@
* - Check cancel does what it should do.
*
* XXX Due to problems with the fakeserver + smtp not using one connection for
* multiple sends, the rest of this test is in test_smtpPasswordFailure2.js.
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/alertTestUtils.js");
load("../../../resources/passwordStorage.js");
var server;
var attempt = 0;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "testsmtp";
// Login information needs to match the login information stored in the signons
// json file.
var kInvalidPassword = "smtptest";
var kValidPassword = "smtptest1";
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx */// for alertTestUtils.js
+function alert(aDialogText, aText) {
// The first few attempts may prompt about the password problem, the last
// attempt shouldn't.
Assert.ok(attempt < 4);
// Log the fact we've got an alert, but we don't need to test anything here.
dump("Alert Title: " + aDialogText + "\nAlert Text: " + aText + "\n");
}
@@ -51,30 +52,30 @@ function confirmEx(aDialogTitle, aText,
dump("\nCancelling login attempt\n");
return 1;
default:
do_throw("unexpected attempt number " + attempt);
return 1;
}
}
-add_task(async function () {
+add_task(async function() {
function createHandler(d) {
var handler = new SMTP_RFC2821_handler(d);
// Username needs to match the login information stored in the signons json
// file.
handler.kUsername = kUsername;
handler.kPassword = kValidPassword;
handler.kAuthRequired = true;
return handler;
}
server = setupServerDaemon(createHandler);
// Prepare files for passwords (generated by a script in bug 1018624).
- await setupForPassword("signons-mailnews1.8.json")
+ await setupForPassword("signons-mailnews1.8.json");
registerAlertTestUtils();
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
@@ -120,12 +121,8 @@ add_task(async function () {
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
});
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_smtpPasswordFailure2.js
+++ b/mailnews/compose/test/unit/test_smtpPasswordFailure2.js
@@ -7,35 +7,36 @@
*
* XXX Due to problems with the fakeserver + smtp not using one connection for
* multiple sends, the first part of this test is in
* test_smtpPasswordFailure2.js.
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/alertTestUtils.js");
load("../../../resources/passwordStorage.js");
var server;
var attempt = 0;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "testsmtp";
// Password needs to match the login information stored in the signons json
// file.
var kInvalidPassword = "smtptest";
var kValidPassword = "smtptest1";
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptPasswordPS */// for alertTestUtils.js
+function alert(aDialogText, aText) {
// The first few attempts may prompt about the password problem, the last
// attempt shouldn't.
Assert.ok(attempt < 4);
// Log the fact we've got an alert, but we don't need to test anything here.
dump("Alert Title: " + aDialogText + "\nAlert Text: " + aText + "\n");
}
@@ -61,31 +62,31 @@ function promptPasswordPS(aParent, aDial
if (attempt == 2) {
aPassword.value = kValidPassword;
aCheckState.value = true;
return true;
}
return false;
}
-add_task(async function () {
+add_task(async function() {
function createHandler(d) {
var handler = new SMTP_RFC2821_handler(d);
// Username needs to match the login information stored in the signons json
// file.
handler.kUsername = kUsername;
handler.kPassword = kValidPassword;
handler.kAuthRequired = true;
handler.kAuthSchemes = [ "PLAIN", "LOGIN" ]; // make match expected transaction below
return handler;
}
server = setupServerDaemon(createHandler);
// Prepare files for passwords (generated by a script in bug 1018624).
- await setupForPassword("signons-mailnews1.8.json")
+ await setupForPassword("signons-mailnews1.8.json");
registerAlertTestUtils();
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
@@ -137,23 +138,18 @@ add_task(async function () {
let logins = Services.logins
.findLogins(count, "smtp://localhost", null,
"smtp://localhost");
Assert.equal(count.value, 1);
Assert.equal(logins[0].username, kUsername);
Assert.equal(logins[0].password, kValidPassword);
do_test_finished();
-
} catch (e) {
do_throw(e);
} finally {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
});
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_smtpPasswordFailure3.js
+++ b/mailnews/compose/test/unit/test_smtpPasswordFailure3.js
@@ -5,35 +5,35 @@
* - Have an invalid password in the password database.
* - Re-initiate connection, this time select enter new password, check that
* we get a new password prompt and can enter the password.
*
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/alertTestUtils.js");
load("../../../resources/passwordStorage.js");
var server;
var attempt = 0;
var kIdentityMail = "identity@foo.invalid";
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kUsername = "testsmtp";
// Password needs to match the login information stored in the signons json
// file.
-var kInvalidPassword = "smtptest";
var kValidPassword = "smtptest1";
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptPasswordPS */// for alertTestUtils.js
+function alert(aDialogText, aText) {
// The first few attempts may prompt about the password problem, the last
// attempt shouldn't.
Assert.ok(attempt < 4);
// Log the fact we've got an alert, but we don't need to test anything here.
dump("Alert Title: " + aDialogText + "\nAlert Text: " + aText + "\n");
}
@@ -59,32 +59,32 @@ function promptPasswordPS(aParent, aDial
if (attempt == 2) {
aPassword.value = kValidPassword;
aCheckState.value = true;
return true;
}
return false;
}
-add_task(async function () {
+add_task(async function() {
function createHandler(d) {
var handler = new SMTP_RFC2821_handler(d);
handler.dropOnAuthFailure = true;
// Username needs to match the login information stored in the signons json
// file.
handler.kUsername = kUsername;
handler.kPassword = kValidPassword;
handler.kAuthRequired = true;
handler.kAuthSchemes = [ "PLAIN", "LOGIN" ]; // make match expected transaction below
return handler;
}
server = setupServerDaemon(createHandler);
// Prepare files for passwords (generated by a script in bug 1018624).
- await setupForPassword("signons-mailnews1.8.json")
+ await setupForPassword("signons-mailnews1.8.json");
registerAlertTestUtils();
// Test file
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
@@ -106,19 +106,18 @@ add_task(async function () {
MailServices.smtp.sendMailMessage(testFile, kTo, identity, kSender,
null, URLListener, null, null,
false, {}, {});
server.performTest();
});
var URLListener = {
- OnStartRunningUrl: function(url) { },
- OnStopRunningUrl: function(url, rc)
- {
+ OnStartRunningUrl(url) {},
+ OnStopRunningUrl(url, rc) {
// Check for ok status.
Assert.equal(rc, 0);
// Now check the new password has been saved.
let count = {};
let logins = Services.logins
.findLogins(count, "smtp://localhost", null,
"smtp://localhost");
@@ -128,15 +127,10 @@ var URLListener = {
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
do_test_finished();
-
- }
+ },
};
-
-function run_test() {
- run_next_test();
-}
--- a/mailnews/compose/test/unit/test_smtpProtocols.js
+++ b/mailnews/compose/test/unit/test_smtpProtocols.js
@@ -5,25 +5,24 @@
var defaultProtocolFlags =
Ci.nsIProtocolHandler.URI_NORELATIVE |
Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
Ci.nsIProtocolHandler.URI_NON_PERSISTABLE |
Ci.nsIProtocolHandler.ALLOWS_PROXY |
Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT;
-var protocols =
- [ { protocol: "smtp",
- urlSpec: "smtp://user@localhost/",
- defaultPort: Ci.nsISmtpUrl.DEFAULT_SMTP_PORT
- },
- { protocol: "smtps",
- urlSpec: "smtps://user@localhost/",
- defaultPort: Ci.nsISmtpUrl.DEFAULT_SMTPS_PORT
- } ];
+var protocols = [{
+ protocol: "smtp", urlSpec: "smtp://user@localhost/",
+ defaultPort: Ci.nsISmtpUrl.DEFAULT_SMTP_PORT,
+}, {
+ protocol: "smtps",
+ urlSpec: "smtps://user@localhost/",
+ defaultPort: Ci.nsISmtpUrl.DEFAULT_SMTPS_PORT,
+}];
function run_test() {
for (var part = 0; part < protocols.length; ++part) {
print("protocol: " + protocols[part].protocol);
var pH = Cc["@mozilla.org/network/protocol;1?name=" +
protocols[part].protocol]
.createInstance(Ci.nsIProtocolHandler);
@@ -44,14 +43,13 @@ function run_test() {
Assert.equal(uri.spec, protocols[part].urlSpec);
try {
// This call should throw NS_ERROR_NOT_IMPLEMENTED. If it doesn't,
// then we should implement a new test for it.
pH.newChannel(uri, null);
// If it didn't throw, then shout about it.
do_throw("newChannel not throwing NS_ERROR_NOT_IMPLEMENTED.");
- }
- catch (ex) {
+ } catch (ex) {
Assert.equal(ex.result, Cr.NS_ERROR_NOT_IMPLEMENTED);
}
}
}
--- a/mailnews/compose/test/unit/test_smtpProxy.js
+++ b/mailnews/compose/test/unit/test_smtpProxy.js
@@ -11,19 +11,16 @@ var daemon, localserver, server;
add_task(async function setup() {
server = setupServerDaemon();
daemon = server._daemon;
server.start();
NetworkTestUtils.configureProxy("smtp.tinderbox.invalid", PORT, server.port);
localserver = getBasicSmtpServer(PORT, "smtp.tinderbox.invalid");
});
-let CompFields = CC("@mozilla.org/messengercompose/composefields;1",
- Ci.nsIMsgCompFields);
-
add_task(async function sendMessage() {
equal(daemon.post, undefined);
let identity = getSmtpIdentity("test@tinderbox.invalid", localserver);
var testFile = do_get_file("data/message1.eml");
var urlListener = new PromiseTestUtils.PromiseUrlListener();
MailServices.smtp.sendMailMessage(testFile, "somebody@example.org", identity,
"me@example.org",
null, urlListener, null, null,
--- a/mailnews/compose/test/unit/test_smtpURL.js
+++ b/mailnews/compose/test/unit/test_smtpURL.js
@@ -1,23 +1,23 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for checking SMTP URLs are working as expected.
* XXX this test needs extending as we fix up nsSmtpUrl.
*/
-var smtpURLs =
- [ { url: "smtp://user@localhost/",
- spec: "smtp://user@localhost/",
- username: "user"
- },
- { url: "smtps://user@localhost/",
- spec: "smtps://user@localhost/",
- username: "user"
- } ];
+var smtpURLs = [{
+ url: "smtp://user@localhost/",
+ spec: "smtp://user@localhost/",
+ username: "user",
+}, {
+ url: "smtps://user@localhost/",
+ spec: "smtps://user@localhost/",
+ username: "user",
+}];
function run_test() {
var url;
for (var part = 0; part < smtpURLs.length; ++part) {
print("url: " + smtpURLs[part].url);
url = Services.io.newURI(smtpURLs[part].url);
--- a/mailnews/compose/test/unit/test_splitRecipients.js
+++ b/mailnews/compose/test/unit/test_splitRecipients.js
@@ -1,105 +1,107 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for nsMsgCompFields functions.
* Currently only tests nsIMsgCompFields::SplitRecipients
*/
-var splitRecipientsTests =
- [ { recipients: "me@foo.invalid",
- emailAddressOnly: false,
- count: 1,
- result: [ "me@foo.invalid" ]
- },
- { recipients: "me@foo.invalid, me2@foo.invalid",
- emailAddressOnly: false,
- count: 2,
- result: [ "me@foo.invalid", "me2@foo.invalid" ]
- },
- { recipients: '"foo bar" <me@foo.invalid>',
- emailAddressOnly: false,
- count: 1,
- result: [ 'foo bar <me@foo.invalid>' ]
- },
- { recipients: '"foo bar" <me@foo.invalid>',
- emailAddressOnly: true,
- count: 1,
- result: [ 'me@foo.invalid' ]
- },
- { recipients: '"foo bar" <me@foo.invalid>, "bar foo" <me2@foo.invalid>',
- emailAddressOnly: false,
- count: 2,
- result: [ 'foo bar <me@foo.invalid>', 'bar foo <me2@foo.invalid>' ]
- },
- { recipients: '"foo bar" <me@foo.invalid>, "bar foo" <me2@foo.invalid>',
- emailAddressOnly: true,
- count: 2,
- result: [ "me@foo.invalid", "me2@foo.invalid" ]
- },
- { recipients: "A Group:Ed Jones <c@a.invalid>,joe@where.invalid,John <jdoe@one.invalid>;",
- emailAddressOnly: false,
- count: 3,
- result: [ "Ed Jones <c@a.invalid>", "joe@where.invalid", "John <jdoe@one.invalid>" ]
- },
- { recipients: 'mygroup:;, empty:;, foo@foo.invalid, othergroup:bar@foo.invalid, bar2@foo.invalid;, y@y.invalid, empty:;',
- emailAddressOnly: true,
- count: 4,
- result: [ "foo@foo.invalid", "bar@foo.invalid", "bar2@foo.invalid", "y@y.invalid" ]
- },
- { recipients: 'Undisclosed recipients:;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,',
- emailAddressOnly: true,
- count: 0,
- result: []
- },
- { recipients: 'a@xxx.invalid; b@xxx.invalid',
- emailAddressOnly: true,
- count: 2,
- result: [ "a@xxx.invalid", "b@xxx.invalid" ]
- },
- { recipients: 'a@xxx.invalid; B <b@xxx.invalid>',
- emailAddressOnly: false,
- count: 2,
- result: [ "a@xxx.invalid", 'B <b@xxx.invalid>' ]
- },
- { recipients: '"A " <a@xxx.invalid>; b@xxx.invalid',
- emailAddressOnly: false,
- count: 2,
- result: [ 'A <a@xxx.invalid>', "b@xxx.invalid" ]
- },
- { recipients: 'A <a@xxx.invalid>; B <b@xxx.invalid>',
- emailAddressOnly: false,
- count: 2,
- result: [ "A <a@xxx.invalid>", 'B <b@xxx.invalid>' ]
- },
- { recipients: "A (this: is, a comment;) <a.invalid>; g: (this: is, <a> comment;) C <c.invalid>, d.invalid;",
- emailAddressOnly: false,
- count: 3,
- result: [ 'A (this: is, a comment;) <a.invalid>', '(this: is, <a> comment;) C <c.invalid>', "d.invalid <>" ]
- },
- { recipients: 'Mary Smith <mary@x.invalid>, extra:;, group:jdoe@example.invalid; Who? <one@y.invalid>; <boss@nil.invalid>, "Giant; \\"Big\\" Box" <sysservices@example.invalid>, ',
- emailAddressOnly: false,
- count: 5,
- result: [ "Mary Smith <mary@x.invalid>", "jdoe@example.invalid", "Who? <one@y.invalid>", "boss@nil.invalid", 'Giant; \"Big\" Box <sysservices@example.invalid>' ]
- },
- { recipients: 'Undisclosed recipients: a@foo.invalid ;;extra:;',
- emailAddressOnly: true,
- count: 1,
- result: [ 'a@foo.invalid' ]
- },
- { recipients: 'Undisclosed recipients:;;extra:a@foo.invalid;',
- emailAddressOnly: true,
- count: 1,
- result: [ 'a@foo.invalid' ]
- },
- { recipients: "",
- emailAddressOnly: false,
- count: 0,
- result: []
- } ];
+var splitRecipientsTests = [
+ {
+ recipients: "me@foo.invalid",
+ emailAddressOnly: false,
+ count: 1,
+ result: [ "me@foo.invalid" ],
+ }, {
+ recipients: "me@foo.invalid, me2@foo.invalid",
+ emailAddressOnly: false,
+ count: 2,
+ result: [ "me@foo.invalid", "me2@foo.invalid" ],
+ }, {
+ recipients: '"foo bar" <me@foo.invalid>',
+ emailAddressOnly: false,
+ count: 1,
+ result: [ "foo bar <me@foo.invalid>" ],
+ }, {
+ recipients: '"foo bar" <me@foo.invalid>',
+ emailAddressOnly: true,
+ count: 1,
+ result: [ "me@foo.invalid" ],
+ }, {
+ recipients: '"foo bar" <me@foo.invalid>, "bar foo" <me2@foo.invalid>',
+ emailAddressOnly: false,
+ count: 2,
+ result: [ "foo bar <me@foo.invalid>", "bar foo <me2@foo.invalid>" ],
+ }, {
+ recipients: '"foo bar" <me@foo.invalid>, "bar foo" <me2@foo.invalid>',
+ emailAddressOnly: true,
+ count: 2,
+ result: [ "me@foo.invalid", "me2@foo.invalid" ],
+ }, {
+ recipients: "A Group:Ed Jones <c@a.invalid>,joe@where.invalid,John <jdoe@one.invalid>;",
+ emailAddressOnly: false,
+ count: 3,
+ result: [ "Ed Jones <c@a.invalid>", "joe@where.invalid", "John <jdoe@one.invalid>" ],
+ }, {
+ recipients: "mygroup:;, empty:;, foo@foo.invalid, othergroup:bar@foo.invalid, bar2@foo.invalid;, y@y.invalid, empty:;",
+ emailAddressOnly: true,
+ count: 4,
+ result: [ "foo@foo.invalid", "bar@foo.invalid", "bar2@foo.invalid", "y@y.invalid" ],
+ }, {
+ recipients: "Undisclosed recipients:;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,",
+ emailAddressOnly: true,
+ count: 0,
+ result: [],
+ }, {
+ recipients: "a@xxx.invalid; b@xxx.invalid",
+ emailAddressOnly: true,
+ count: 2,
+ result: [ "a@xxx.invalid", "b@xxx.invalid" ],
+ }, {
+ recipients: "a@xxx.invalid; B <b@xxx.invalid>",
+ emailAddressOnly: false,
+ count: 2,
+ result: [ "a@xxx.invalid", "B <b@xxx.invalid>" ],
+ }, {
+ recipients: '"A " <a@xxx.invalid>; b@xxx.invalid',
+ emailAddressOnly: false,
+ count: 2,
+ result: [ "A <a@xxx.invalid>", "b@xxx.invalid" ],
+ }, {
+ recipients: "A <a@xxx.invalid>; B <b@xxx.invalid>",
+ emailAddressOnly: false,
+ count: 2,
+ result: [ "A <a@xxx.invalid>", "B <b@xxx.invalid>" ],
+ }, {
+ recipients: "A (this: is, a comment;) <a.invalid>; g: (this: is, <a> comment;) C <c.invalid>, d.invalid;",
+ emailAddressOnly: false,
+ count: 3,
+ result: [ "A (this: is, a comment;) <a.invalid>", "(this: is, <a> comment;) C <c.invalid>", "d.invalid <>" ],
+ }, {
+ recipients: 'Mary Smith <mary@x.invalid>, extra:;, group:jdoe@example.invalid; Who? <one@y.invalid>; <boss@nil.invalid>, "Giant; \\"Big\\" Box" <sysservices@example.invalid>, ',
+ emailAddressOnly: false,
+ count: 5,
+ result: [ "Mary Smith <mary@x.invalid>", "jdoe@example.invalid", "Who? <one@y.invalid>", "boss@nil.invalid", 'Giant; \"Big\" Box <sysservices@example.invalid>' ],
+ }, {
+ recipients: "Undisclosed recipients: a@foo.invalid ;;extra:;",
+ emailAddressOnly: true,
+ count: 1,
+ result: [ "a@foo.invalid" ],
+ }, {
+ recipients: "Undisclosed recipients:;;extra:a@foo.invalid;",
+ emailAddressOnly: true,
+ count: 1,
+ result: [ "a@foo.invalid" ],
+ }, {
+ recipients: "",
+ emailAddressOnly: false,
+ count: 0,
+ result: [],
+ },
+];
function run_test() {
var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Ci.nsIMsgCompFields);
// As most of SplitRecipients functionality is in the nsIMsgHeaderParser
// functionality, here (at least initially), we're just interested in checking
// the basic argument/return combinations.
--- a/mailnews/compose/test/unit/test_staleTemporaryFileCleanup.js
+++ b/mailnews/compose/test/unit/test_staleTemporaryFileCleanup.js
@@ -45,15 +45,14 @@ function run_test() {
gExpectedFiles.forEach(function(file) {
if (file.exists())
file.remove(false);
});
});
// Ensure we have at least one mail account
localAccountUtils.loadLocalMailAccount();
- let composeService = MailServices.compose;
+ MailServices.compose; // Initialise the compose service.
do_test_pending();
check_files_not_exist(gExpectedFiles);
do_test_finished();
-
}
--- a/mailnews/compose/test/unit/test_temporaryFilesRemoved.js
+++ b/mailnews/compose/test/unit/test_temporaryFilesRemoved.js
@@ -7,26 +7,26 @@
*/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var gMsgCompose;
var gExpectedFiles;
var progressListener = {
- onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
+ onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
do_timeout(0, check_result);
},
- onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {},
- onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {},
- onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {},
- onSecurityChange: function(aWebProgress, aRequest, state) {},
- onContentBlockingEvent: function(aWebProgress, aRequest, aEvent) {},
+ onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {},
+ onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {},
+ onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {},
+ onSecurityChange(aWebProgress, aRequest, state) {},
+ onContentBlockingEvent(aWebProgress, aRequest, aEvent) {},
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener",
"nsISupportsWeakReference"]),
};
function get_temporary_files_for(name) {
let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
file.append(name);
@@ -85,17 +85,17 @@ function run_test() {
params.composeFields = fields;
params.format = Ci.nsIMsgCompFormat.HTML;
gMsgCompose.initialize(params, null, null);
let identity = getSmtpIdentity(null, getBasicSmtpServer());
- let draftFolder = localAccountUtils.rootFolder.createLocalSubfolder("Drafts");
+ localAccountUtils.rootFolder.createLocalSubfolder("Drafts");
let progress = Cc["@mozilla.org/messenger/progress;1"]
.createInstance(Ci.nsIMsgProgress);
progress.registerListener(progressListener);
do_test_pending();
gMsgCompose.SendMsg(Ci.nsIMsgSend.nsMsgSaveAsDraft, identity, "", null,