summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/extensions/mdn/test/unit/test_askuser.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/mailnews/extensions/mdn/test/unit/test_askuser.js')
-rw-r--r--comm/mailnews/extensions/mdn/test/unit/test_askuser.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/comm/mailnews/extensions/mdn/test/unit/test_askuser.js b/comm/mailnews/extensions/mdn/test/unit/test_askuser.js
new file mode 100644
index 0000000000..b30ab49b0f
--- /dev/null
+++ b/comm/mailnews/extensions/mdn/test/unit/test_askuser.js
@@ -0,0 +1,67 @@
+localAccountUtils.loadLocalMailAccount();
+
+var localAccount = MailServices.accounts.FindAccountForServer(
+ localAccountUtils.incomingServer
+);
+var identity = MailServices.accounts.createIdentity();
+identity.email = "bob@t2.example.net";
+localAccount.addIdentity(identity);
+localAccount.defaultIdentity = identity;
+
+function run_test() {
+ var headers =
+ "from: alice@t1.example.com\r\n" +
+ "to: bob@t2.example.net\r\n" +
+ "return-path: alice@t1.example.com\r\n" +
+ "Disposition-Notification-To: alice@t1.example.com\r\n";
+
+ let mimeHdr = Cc["@mozilla.org/messenger/mimeheaders;1"].createInstance(
+ Ci.nsIMimeHeaders
+ );
+ mimeHdr.initialize(headers);
+ let receivedHeader = mimeHdr.extractHeader("To", false);
+ dump(receivedHeader + "\n");
+
+ localAccountUtils.inboxFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
+ localAccountUtils.inboxFolder.addMessage(
+ "From \r\n" + headers + "\r\nhello\r\n"
+ );
+ // Need to setup some prefs
+ Services.prefs.setBoolPref("mail.mdn.report.enabled", true);
+ Services.prefs.setIntPref("mail.mdn.report.not_in_to_cc", 2);
+ Services.prefs.setIntPref("mail.mdn.report.other", 2);
+ Services.prefs.setIntPref("mail.mdn.report.outside_domain", 2);
+
+ var msgFolder = localAccountUtils.inboxFolder;
+
+ var msgWindow = {};
+
+ var msgHdr = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder);
+
+ // Everything looks good so far, let's generate the MDN response.
+ var mdnGenerator = Cc[
+ "@mozilla.org/messenger-mdn/generator;1"
+ ].createInstance(Ci.nsIMsgMdnGenerator);
+
+ Services.prefs.setIntPref("mail.mdn.report.outside_domain", 1);
+ var askUser = mdnGenerator.process(
+ Ci.nsIMsgMdnGenerator.eDisplayed,
+ msgWindow,
+ msgFolder,
+ msgHdr.messageKey,
+ mimeHdr,
+ false
+ );
+ Assert.ok(!askUser);
+
+ Services.prefs.setIntPref("mail.mdn.report.outside_domain", 2);
+ askUser = mdnGenerator.process(
+ Ci.nsIMsgMdnGenerator.eDisplayed,
+ msgWindow,
+ msgFolder,
+ msgHdr.messageKey,
+ mimeHdr,
+ false
+ );
+ Assert.ok(askUser);
+}