Bug 1577116 - Implement nsIAbCard.translateTo for new AB provider; r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 22 Oct 2019 12:09:37 +1300
changeset 37332 c1ee2010d423a7311be8e43bb0047d187ed93ec7
parent 37331 e0e759a383675bc41ed82906e0645aa68126afed
child 37333 4982de786c5402c20b95015f73e2a467ed0a108c
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewersmkmelin
bugs1577116
Bug 1577116 - Implement nsIAbCard.translateTo for new AB provider; r=mkmelin
mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
mailnews/addrbook/test/unit/xpcshell-mdbaddrbook.ini
mailnews/addrbook/test/unit/xpcshell.ini
--- a/mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
+++ b/mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
@@ -222,17 +222,22 @@ AddrBookCard.prototype = {
       return true;
     }
     if (this._properties.get("SecondEmail") == emailAddress) {
       return true;
     }
     return false;
   },
   translateTo(type) {
-    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+    // Get nsAbCardProperty to do the work, the code is in C++ anyway.
+    let cardCopy = Cc[
+      "@mozilla.org/addressbook/cardproperty;1"
+    ].createInstance(Ci.nsIAbCard);
+    cardCopy.copy(this);
+    return cardCopy.translateTo(type);
   },
   generatePhoneticName(lastNameFirst) {
     if (lastNameFirst) {
       return `${this.lastName}, ${this.firstName}`;
     }
     return `${this.firstName} ${this.lastName}`;
   },
   generateChatName() {
--- a/mailnews/addrbook/test/unit/xpcshell-mdbaddrbook.ini
+++ b/mailnews/addrbook/test/unit/xpcshell-mdbaddrbook.ini
@@ -7,13 +7,12 @@ tags = mdbaddrbook
 
 # These are the tests that do not pass or should not pass when using the
 # JS directory provider.
 
 [test_bug534822.js] # head_jsaddrbook.js breaks test
 [test_ldap1.js]
 [test_ldap2.js]
 [test_ldapOffline.js]
-[test_nsIAbCard.js] # translateTo is not implemented
 [test_uid.js]
 [test_uuid.js]
 
 [include:xpcshell.ini]
--- a/mailnews/addrbook/test/unit/xpcshell.ini
+++ b/mailnews/addrbook/test/unit/xpcshell.ini
@@ -16,8 +16,9 @@
 [test_nsAbAutoCompleteSearch3.js]
 [test_nsAbAutoCompleteSearch4.js]
 [test_nsAbAutoCompleteSearch5.js]
 [test_nsAbAutoCompleteSearch6.js]
 [test_nsAbAutoCompleteSearch7.js]
 [test_nsAbManager1.js]
 [test_nsAbManager2.js]
 [test_nsAbManager3.js]
+[test_nsIAbCard.js]