summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js')
-rw-r--r--comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js b/comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
new file mode 100644
index 0000000000..2524c489df
--- /dev/null
+++ b/comm/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
@@ -0,0 +1,62 @@
+/**
+ * The intent of this file is to test temp file handling when
+ * downloading multiple pop3 messages with quarantining turned on.
+ *
+ * Original author: David Bienvenu <dbienvenu@mozilla.com>
+ */
+
+/* import-globals-from ../../../test/resources/POP3pump.js */
+load("../../../resources/POP3pump.js");
+
+var testSubjects = [
+ "[Bug 397009] A filter will let me tag, but not untag",
+ "Hello, did you receive my bugmail?",
+];
+var gExpectedFiles;
+
+function run_test() {
+ Services.prefs.setBoolPref("mailnews.downloadToTempFile", true);
+ gExpectedFiles = createExpectedTemporaryFiles(2);
+ // add 2 messages
+ gPOP3Pump.files = ["../../../data/bugmail1", "../../../data/draft1"];
+ gPOP3Pump.onDone = continueTest;
+ do_test_pending();
+ gPOP3Pump.run();
+}
+
+function continueTest() {
+ dump("temp file path = " + gExpectedFiles[0].path + "\n");
+ dump("temp file path = " + gExpectedFiles[1].path + "\n");
+ for (let expectedFile of gExpectedFiles) {
+ Assert.ok(!expectedFile.exists());
+ }
+
+ // get message headers for the inbox folder
+ var msgCount = 0;
+ for (let hdr of localAccountUtils.inboxFolder.msgDatabase.enumerateMessages()) {
+ Assert.equal(hdr.subject, testSubjects[msgCount++]);
+ }
+ Assert.equal(msgCount, 2);
+ gPOP3Pump = null;
+ do_test_finished();
+}
+
+function createExpectedTemporaryFiles(numFiles) {
+ function createTemporaryFile() {
+ let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
+ file.append("newmsg");
+ file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
+ return file;
+ }
+
+ let expectedFiles = [];
+ for (let i = 0; i < numFiles; i++) {
+ expectedFiles.push(createTemporaryFile());
+ }
+
+ for (let expectedFile of expectedFiles) {
+ expectedFile.remove(false);
+ }
+
+ return expectedFiles;
+}