diff --git a/mozilla/mailnews/addrbook/Makefile.in b/mozilla/mailnews/addrbook/Makefile.in index 39452d40dd2..63e3ddb1f10 100644 --- a/mozilla/mailnews/addrbook/Makefile.in +++ b/mozilla/mailnews/addrbook/Makefile.in @@ -43,13 +43,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -EXTRA_COMPONENTS += src/nsAbAutoCompleteMyDomain.js src/nsAbLDAPAttributeMap.js - -ifdef MOZ_LDAP_XPCOM -REQUIRES += mozldap necko -EXTRA_COMPONENTS += src/nsLDAPPrefsService.js -endif - DIRS = public src ifndef MOZ_STATIC_MAIL_BUILD diff --git a/mozilla/mailnews/addrbook/src/Makefile.in b/mozilla/mailnews/addrbook/src/Makefile.in index 785ab242bbe..560cd1fda62 100644 --- a/mozilla/mailnews/addrbook/src/Makefile.in +++ b/mozilla/mailnews/addrbook/src/Makefile.in @@ -104,6 +104,11 @@ CPPSRCS = \ nsAbContentHandler.cpp \ $(NULL) +EXTRA_COMPONENTS += \ + nsAbLDAPAttributeMap.js \ + nsAbAutoCompleteMyDomain.js \ + $(NULL) + EXPORTS = \ nsAbCardProperty.h \ nsAbMDBCard.h \ @@ -146,6 +151,8 @@ CPPSRCS += \ nsLDAPAutoCompleteSession.cpp \ $(NULL) +EXTRA_COMPONENTS += nsLDAPPrefsService.js + # XXX These files are not being built as they don't work. Bug 311632 should # fix them. # nsAbLDAPChangeLogQuery.cpp diff --git a/mozilla/mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js b/mozilla/mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js new file mode 100644 index 00000000000..a96176ad098 --- /dev/null +++ b/mozilla/mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Test suite for nsAbAutoCompleteSearch + */ + +const ACR = Components.interfaces.nsIAutoCompleteResult; + +function acObserver() {} + +acObserver.prototype = { + _search: null, + _result: null, + + onSearchResult: function (aSearch, aResult) { + this._search = aSearch; + this._result = aResult; + } +}; + +function run_test() { + // Test - Create a new search component + + var acs = Components.classes["@mozilla.org/autocomplete/search;1?name=mydomain"] + .getService(Components.interfaces.nsIAutoCompleteSearch); + + var obs = new acObserver(); + + // Set up an identity in the account manager with the default settings + var acctMgr = Cc["@mozilla.org/messenger/account-manager;1"] + .getService(Ci.nsIMsgAccountManager); + + var identity = acctMgr.createIdentity(); + + // Initially disable autocomplete + identity.autocompleteToMyDomain = false; + identity.email = "myemail@invalid.com"; + + // Test - Valid search - this should return no results (autocomplete disabled) + acs.startSearch("test", identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, "test"); + do_check_eq(obs._result.searchResult, ACR.RESULT_FAILURE); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 0); + + // Now enable autocomplete for this identity + identity.autocompleteToMyDomain = true; + + // Test - Search with empty string + + acs.startSearch(null, identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, null); + do_check_eq(obs._result.searchResult, ACR.RESULT_FAILURE); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 0); + + acs.startSearch("", identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, ""); + do_check_eq(obs._result.searchResult, ACR.RESULT_FAILURE); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 0); + + // Test - Check ignoring result with comma + + acs.startSearch("a,b", identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, "a,b"); + do_check_eq(obs._result.searchResult, ACR.RESULT_FAILURE); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 0); + + // Test - Check ignoring result with @ sign + + acs.startSearch("a@b", identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, "a@b"); + do_check_eq(obs._result.searchResult, ACR.RESULT_FAILURE); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 0); + + // Test - Add default domain + + acs.startSearch("test1", identity.key, null, obs); + + do_check_eq(obs._search, acs); + do_check_eq(obs._result.searchString, "test1"); + do_check_eq(obs._result.searchResult, ACR.RESULT_SUCCESS); + do_check_eq(obs._result.errorDescription, null); + do_check_eq(obs._result.matchCount, 1); + + do_check_eq(obs._result.getValueAt(0), "test1@invalid.com"); + do_check_eq(obs._result.getCommentAt(0), null); + do_check_eq(obs._result.getStyleAt(0), "default-match"); + do_check_eq(obs._result.getImageAt(0), null); +};