diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/db/msgdb/test/unit/test_enumerator_cleanup.js | |
parent | Initial commit. (diff) | |
download | thunderbird-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 '')
-rw-r--r-- | comm/mailnews/db/msgdb/test/unit/test_enumerator_cleanup.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/comm/mailnews/db/msgdb/test/unit/test_enumerator_cleanup.js b/comm/mailnews/db/msgdb/test/unit/test_enumerator_cleanup.js new file mode 100644 index 0000000000..dfb5aa5285 --- /dev/null +++ b/comm/mailnews/db/msgdb/test/unit/test_enumerator_cleanup.js @@ -0,0 +1,56 @@ +/* + * Test nsMsgDatabase's cleanup of nsMsgDBEnumerators + */ + +var { MailServices } = ChromeUtils.import( + "resource:///modules/MailServices.jsm" +); + +var anyOldMessage = do_get_file("../../../../data/bugmail1"); + +/** + * Test closing a db with an outstanding enumerator. + */ +function test_enumerator_cleanup() { + let db = localAccountUtils.inboxFolder.msgDatabase; + let enumerator = db.enumerateMessages(); + Cc["@mozilla.org/msgDatabase/msgDBService;1"] + .getService(Ci.nsIMsgDBService) + .forceFolderDBClosed(localAccountUtils.inboxFolder); + localAccountUtils.inboxFolder.msgDatabase = null; + db = null; + gc(); + [...enumerator]; + do_test_finished(); +} + +/* + * This infrastructure down here exists just to get + * test_references_header_parsing its message header. + */ + +function run_test() { + localAccountUtils.loadLocalMailAccount(); + do_test_pending(); + MailServices.copy.copyFileMessage( + anyOldMessage, + localAccountUtils.inboxFolder, + null, + false, + 0, + "", + messageHeaderGetterListener, + null + ); + return true; +} + +var messageHeaderGetterListener = { + OnStartCopy() {}, + OnProgress(aProgress, aProgressMax) {}, + GetMessageId(aMessageId) {}, + SetMessageKey(aKey) {}, + OnStopCopy(aStatus) { + do_timeout(0, test_enumerator_cleanup); + }, +}; |