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/addrbook/test/unit/test_ldapOffline.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.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/addrbook/test/unit/test_ldapOffline.js')
-rw-r--r-- | comm/mailnews/addrbook/test/unit/test_ldapOffline.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/comm/mailnews/addrbook/test/unit/test_ldapOffline.js b/comm/mailnews/addrbook/test/unit/test_ldapOffline.js new file mode 100644 index 0000000000..ed81344d03 --- /dev/null +++ b/comm/mailnews/addrbook/test/unit/test_ldapOffline.js @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Test suite to check that we correctly get child cards for LDAP directories + * when offline and that we don't crash. + */ + +var kLDAPUriPrefix = "moz-abldapdirectory://"; +var kLDAPTestSpec = "ldap://invalidhost//dc=intranet??sub?(objectclass=*)"; + +// Main function for the this test so we can check both personal and +// collected books work correctly in an easy manner. +function run_test() { + // If nsIAbLDAPDirectory doesn't exist in our build options, someone has + // specified --disable-ldap + if (!("nsIAbLDAPDirectory" in Ci)) { + return; + } + + // Test set-up + let abUri = MailServices.ab.newAddressBook( + "test", + kLDAPTestSpec, + Ci.nsIAbManager.LDAP_DIRECTORY_TYPE + ); + + let abDir = MailServices.ab + .getDirectory(kLDAPUriPrefix + abUri) + .QueryInterface(Ci.nsIAbLDAPDirectory); + + const kLDAPFileName = "ldap-1.sqlite"; + + // Test setup - copy the data file into place + loadABFile("data/cardForEmail", kLDAPFileName); + + // And tell the ldap directory we want this file. + abDir.replicationFileName = kLDAPFileName; + + // Now go offline + Services.io.offline = true; + + // Make sure we clear any memory that is now loose, so that the crash would + // be triggered. + gc(); + + // Now try and get the card that has been replicated for offline use. + Assert.equal(abDir.childCards.length, 5); +} |