Bug 1595649 - Fix disabling auto-completion on a per-directory basis; r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 12 Nov 2019 14:55:23 +1300
changeset 36659 9ffcd0110d4155b71896110755152b8e0708397e
parent 36658 78130fcb03716b7a22e451e4d2197d20288bfde0
child 36660 18938b699f1861ff962b763d90967bb02353f5a1
push id2534
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:52:51 +0000
treeherdercomm-beta@055c50840778 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1595649
Bug 1595649 - Fix disabling auto-completion on a per-directory basis; r=mkmelin
mailnews/addrbook/jsaddrbook/AddrBookDirectory.jsm
mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
--- a/mailnews/addrbook/jsaddrbook/AddrBookDirectory.jsm
+++ b/mailnews/addrbook/jsaddrbook/AddrBookDirectory.jsm
@@ -765,17 +765,20 @@ var bookPrototype = {
     this._saveCardProperties(newCard);
 
     MailServices.ab.notifyDirectoryItemAdded(this, newCard);
     Services.obs.notifyObservers(newCard, "addrbook-contact-created", this.UID);
 
     return newCard;
   },
   useForAutocomplete(identityKey) {
-    return Services.prefs.getBoolPref("mail.enable_autocomplete");
+    return (
+      Services.prefs.getBoolPref("mail.enable_autocomplete") &&
+      this.getBoolValue("enable_autocomplete", true)
+    );
   },
   addMailList(list) {
     if (!list.isMailList) {
       throw Cr.NS_ERROR_UNEXPECTED;
     }
 
     let newList = new AddrBookMailingList(
       newUID(),
--- a/mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
+++ b/mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
@@ -54,21 +54,25 @@ function check_ab(abConfig) {
   Assert.equal(AB.dirPrefId, abConfig.dirPrefID);
 
   // Test - autocomplete enable/disable
 
   // enable is the default
   Assert.equal(AB.useForAutocomplete(""), true);
 
   Services.prefs.setBoolPref("mail.enable_autocomplete", false);
-
   Assert.equal(AB.useForAutocomplete(""), false);
 
   Services.prefs.setBoolPref("mail.enable_autocomplete", true);
+  Assert.equal(AB.useForAutocomplete(""), true);
 
+  AB.setBoolValue("enable_autocomplete", false);
+  Assert.equal(AB.useForAutocomplete(""), false);
+
+  AB.setBoolValue("enable_autocomplete", true);
   Assert.equal(AB.useForAutocomplete(""), true);
 
   // Test - check getting default preferences
 
   Assert.equal(AB.getIntValue("random", 54321), 54321);
   Assert.equal(AB.getBoolValue("random", false), false);
   Assert.equal(AB.getStringValue("random", "abc"), "abc");
   Assert.equal(AB.getLocalizedStringValue("random", "xyz"), "xyz");