Bug 1515877 - Turn on ESLint in mailnews/addrbook; r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 25 Jan 2019 17:32:10 +1300
changeset 33442 bd2ed7ad33c9
parent 33441 132113b4ce51
child 33443 881cf0d594f2
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1515877
Bug 1515877 - Turn on ESLint in mailnews/addrbook; r=aceman
.eslintignore
mailnews/addrbook/content/abAddressBookNameDialog.js
mailnews/addrbook/content/abDragDrop.js
mailnews/addrbook/content/abMailListDialog.js
mailnews/addrbook/content/abResultsPane.js
mailnews/addrbook/content/addrbookWidgets.xml
mailnews/addrbook/prefs/content/pref-directory-add.js
mailnews/addrbook/prefs/content/pref-editdirectories.js
mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
mailnews/addrbook/src/nsAbAutoCompleteSearch.js
mailnews/addrbook/src/nsAbLDAPAttributeMap.js
mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
mailnews/addrbook/test/unit/.eslintrc.js
mailnews/addrbook/test/unit/data/bug534822prefs.js
mailnews/addrbook/test/unit/head_addrbook.js
mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
mailnews/addrbook/test/unit/test_bug534822.js
mailnews/addrbook/test/unit/test_bug_448165.js
mailnews/addrbook/test/unit/test_cardForEmail.js
mailnews/addrbook/test/unit/test_collection.js
mailnews/addrbook/test/unit/test_collection_2.js
mailnews/addrbook/test/unit/test_db_enumerator.js
mailnews/addrbook/test/unit/test_ldap1.js
mailnews/addrbook/test/unit/test_ldap2.js
mailnews/addrbook/test/unit/test_ldapOffline.js
mailnews/addrbook/test/unit/test_mailList1.js
mailnews/addrbook/test/unit/test_notifications.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch1.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch2.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch3.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch4.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch5.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch6.js
mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch7.js
mailnews/addrbook/test/unit/test_nsAbManager1.js
mailnews/addrbook/test/unit/test_nsAbManager2.js
mailnews/addrbook/test/unit/test_nsAbManager3.js
mailnews/addrbook/test/unit/test_nsIAbCard.js
mailnews/addrbook/test/unit/test_uid.js
mailnews/addrbook/test/unit/test_uuid.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -23,17 +23,16 @@ build/**
 chat/**
 editor/**
 im/**
 ldap/**
 suite/**
 
 # mailnews exclusions
 mailnews/mailnews.js
-mailnews/addrbook/*
 mailnews/base/*
 mailnews/build/*
 mailnews/compose/*
 mailnews/db/*
 mailnews/imap/*
 mailnews/import/*
 mailnews/intl/*
 mailnews/jsaccount/*
--- a/mailnews/addrbook/content/abAddressBookNameDialog.js
+++ b/mailnews/addrbook/content/abAddressBookNameDialog.js
@@ -1,30 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var {
+  fixIterator,
+} = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gOkButton;
 var gNameInput;
 var gDirectory = null;
 
 var kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
 var kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab";
 var kAllDirectoryRoot = "moz-abdirectory://";
 var kPABDirectory = 2; // defined in nsDirPrefs.h
 
-function abNameOnLoad()
-{
+function abNameOnLoad() {
   // Get the document elements.
-  gOkButton = document.documentElement.getButton('accept');
-  gNameInput = document.getElementById('name');
+  gOkButton = document.documentElement.getButton("accept");
+  gNameInput = document.getElementById("name");
 
   // look in arguments[0] for parameters to see if we have a directory or not
   if ("arguments" in window && window.arguments[0] &&
       "selectedDirectory" in window.arguments[0]) {
     gDirectory = window.arguments[0].selectedDirectory;
     gNameInput.value = gDirectory.dirName;
   }
 
@@ -49,18 +50,17 @@ function abNameOnLoad()
     document.documentElement.buttons = "accept";
     document.documentElement.removeAttribute("ondialogaccept");
   } else {
     gNameInput.focus();
     abNameDoOkEnabling();
   }
 }
 
-function abNameOKButton()
-{
+function abNameOKButton() {
   var newName = gNameInput.value.trim();
 
   // Do not allow an already existing name.
   for (let ab of fixIterator(MailServices.ab.directories,
                              Ci.nsIAbDirectory)) {
     if ((ab.dirName.toLowerCase() == newName.toLowerCase()) &&
         (!gDirectory || (ab.URI != gDirectory.URI))) {
       const kAlertTitle = document.getElementById("bundle_addressBook")
@@ -77,12 +77,11 @@ function abNameOKButton()
   if (gDirectory)
     gDirectory.dirName = newName;
   else
     MailServices.ab.newAddressBook(newName, "", kPABDirectory);
 
   return true;
 }
 
-function abNameDoOkEnabling()
-{
+function abNameDoOkEnabling() {
   gOkButton.disabled = gNameInput.value.trim() == "";
 }
--- a/mailnews/addrbook/content/abDragDrop.js
+++ b/mailnews/addrbook/content/abDragDrop.js
@@ -1,28 +1,31 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+/* import-globals-from ../../../mail/base/content/nsDragAndDrop.js */
+/* import-globals-from ../../../mail/components/addrbook/content/abCommon.js */
+/* import-globals-from ../../../mail/components/compose/content/addressingWidgetOverlay.js */
+/* import-globals-from abResultsPane.js */
+
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
+ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // Returns the load context for the current window
 function getLoadContext() {
   return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 var abFlavorDataProvider = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIFlavorDataProvider]),
 
-  getFlavorData: function(aTransferable, aFlavor, aData, aDataLen)
-  {
-    if (aFlavor == "application/x-moz-file-promise")
-    {
+  getFlavorData(aTransferable, aFlavor, aData, aDataLen) {
+    if (aFlavor == "application/x-moz-file-promise") {
       var primitive = {};
       aTransferable.getTransferData("text/vcard", primitive, {});
       var vCard = primitive.value.QueryInterface(Ci.nsISupportsString).data;
       aTransferable.getTransferData("application/x-moz-file-promise-dest-filename", primitive, {});
       var leafName = primitive.value.QueryInterface(Ci.nsISupportsString).data;
       aTransferable.getTransferData("application/x-moz-file-promise-dir", primitive, {});
       var localFile = primitive.value.QueryInterface(Ci.nsIFile).clone();
       localFile.append(leafName);
@@ -31,22 +34,21 @@ var abFlavorDataProvider = {
       ofStream.init(localFile, -1, -1, 0);
       var converter = Cc["@mozilla.org/intl/converter-output-stream;1"].createInstance(Ci.nsIConverterOutputStream);
       converter.init(ofStream, null);
       converter.writeString(vCard);
       converter.close();
 
       aData.value = localFile;
     }
-  }
+  },
 };
 
 var abResultsPaneObserver = {
-  onDragStart: function (aEvent, aXferData, aDragAction)
-    {
+  onDragStart(aEvent, aXferData, aDragAction) {
       var selectedRows = GetSelectedRows();
 
       if (!selectedRows)
         return;
 
       var selectedAddresses = GetSelectedAddresses();
 
       aXferData.data = new TransferData();
@@ -71,34 +73,30 @@ var abResultsPaneObserver = {
       var card = GetSelectedCard();
       if (card && card.displayName) {
         let vCard = card.translateTo("vcard");
         aXferData.data.addDataForFlavour("text/vcard", decodeURIComponent(vCard));
         aXferData.data.addDataForFlavour("application/x-moz-file-promise-dest-filename", card.displayName + ".vcf");
         aXferData.data.addDataForFlavour("application/x-moz-file-promise-url", "data:text/vcard," + vCard);
         aXferData.data.addDataForFlavour("application/x-moz-file-promise", abFlavorDataProvider);
       }
-    },
+  },
 
-  onDrop: function (aEvent, aXferData, aDragSession)
-    {
-    },
+  onDrop(aEvent, aXferData, aDragSession) {
+  },
 
-  onDragExit: function (aEvent, aDragSession)
-    {
-    },
+  onDragExit(aEvent, aDragSession) {
+  },
 
-  onDragOver: function (aEvent, aFlavour, aDragSession)
-    {
-    },
+  onDragOver(aEvent, aFlavour, aDragSession) {
+  },
 
-  getSupportedFlavours: function ()
-    {
-      return null;
-    }
+  getSupportedFlavours() {
+    return null;
+  },
 };
 
 
 var dragService = Cc["@mozilla.org/widget/dragservice;1"]
                     .getService(Ci.nsIDragService);
 
 var abDirTreeObserver = {
   /**
@@ -121,18 +119,17 @@ var abDirTreeObserver = {
    *   (cards currently have to exist outside list for list to work correctly)
    *   mailing list      -> different address book = MOVE only
    *   (lists currently need to have unique names)
    *   card in mailing list -> parent mailing list = Not allowed
    *   card in mailing list -> other mailing list  = MOVE or COPY
    *   card in mailing list -> other address book  = MOVE or COPY
    *   read only directory item -> anywhere        = COPY only
    */
-  canDrop: function(index, orientation, dataTransfer)
-  {
+  canDrop(index, orientation, dataTransfer) {
     if (orientation != Ci.nsITreeView.DROP_ON)
       return false;
     if (!dataTransfer.types.includes("moz/abcard")) {
       return false;
     }
 
     let targetURI = gDirectoryTreeView.getDirectoryAtIndex(index).URI;
 
@@ -164,65 +161,60 @@ var abDirTreeObserver = {
 
     // XXX Due to bug 373125/bug 349044 we can't specify a default action,
     // so we default to move and this means that the user would have to press
     // ctrl to copy which most users don't realize.
     //
     // If target directory is a mailing list, then only allow copies.
     //    if (targetDirectory.isMailList &&
     //   dragSession.dragAction != Ci.nsIDragService.DRAGDROP_ACTION_COPY)
-    //return false;
+    // return false;
 
     var srcDirectory = GetDirectoryFromURI(srcURI);
 
     // Only allow copy from read-only directories.
     if (srcDirectory.readOnly &&
-        dragSession.dragAction != Ci.
-                                  nsIDragService.DRAGDROP_ACTION_COPY)
+        dragSession.dragAction != Ci.nsIDragService.DRAGDROP_ACTION_COPY) {
       return false;
+    }
 
     // Go through the cards checking to see if one of them is a mailing list
     // (if we are attempting a copy) - we can't copy mailing lists as
     // that would give us duplicate names which isn't allowed at the
     // moment.
     var draggingMailList = false;
 
     // The data contains the a string of "selected rows", eg.: "1,2".
     var rows = dataTransfer.getData("moz/abcard").split(",").map(j => parseInt(j, 10));
 
-    for (var j = 0; j < rows.length; j++)
-    {
-      if (gAbView.getCardFromRow(rows[j]).isMailList)
-      {
+    for (var j = 0; j < rows.length; j++) {
+      if (gAbView.getCardFromRow(rows[j]).isMailList) {
         draggingMailList = true;
         break;
       }
     }
 
     // The rest of the cases - allow cards for copy or move, but only allow
     // move of mailing lists if we're not going into another mailing list.
     if (draggingMailList &&
         (targetDirectory.isMailList ||
-         dragSession.dragAction == Ci.
-                                   nsIDragService.DRAGDROP_ACTION_COPY))
-    {
+         dragSession.dragAction == Ci.nsIDragService.DRAGDROP_ACTION_COPY)) {
       return false;
     }
 
     dragSession.canDrop = true;
     return true;
   },
 
   /**
    * onDrop - we don't need to check again for correctness as the
    * tree view calls canDrop just before calling onDrop.
    *
    */
-  onDrop: function(index, orientation, dataTransfer)
-  {
+  onDrop(index, orientation, dataTransfer) {
     var dragSession = dragService.getCurrentSession();
     if (!dragSession)
       return;
     if (!dataTransfer.types.includes("moz/abcard")) {
       return;
     }
 
     let targetURI = gDirectoryTreeView.getDirectoryAtIndex(index).URI;
@@ -238,18 +230,17 @@ var abDirTreeObserver = {
     // - it's not for if we are moving or not.
     var needToCopyCard = true;
     if (srcURI.length > targetURI.length) {
       result = srcURI.split(targetURI);
       if (result[0] != srcURI) {
         // src directory is a mailing list on target directory, no need to copy card
         needToCopyCard = false;
       }
-    }
-    else {
+    } else {
       result = targetURI.split(srcURI);
       if (result[0] != targetURI) {
         // target directory is a mailing list on src directory, no need to copy card
         needToCopyCard = false;
       }
     }
 
     // if we still think we have to copy the card,
@@ -315,105 +306,88 @@ var abDirTreeObserver = {
 
     if (srcURI == kAllDirectoryRoot + "?") {
       SetAbView(srcURI);
     }
 
     document.getElementById("statusText").label = cardsTransferredText;
   },
 
-  onToggleOpenState: function()
-  {
+  onToggleOpenState() {
   },
 
-  onCycleHeader: function(colID, elt)
-  {
+  onCycleHeader(colID, elt) {
   },
 
-  onCycleCell: function(row, colID)
-  {
+  onCycleCell(row, colID) {
   },
 
-  onSelectionChanged: function()
-  {
+  onSelectionChanged() {
   },
 
-  onPerformAction: function(action)
-  {
+  onPerformAction(action) {
   },
 
-  onPerformActionOnRow: function(action, row)
-  {
+  onPerformActionOnRow(action, row) {
   },
 
-  onPerformActionOnCell: function(action, row, colID)
-  {
-  }
-}
+  onPerformActionOnCell(action, row, colID) {
+  },
+};
 
-function DragAddressOverTargetControl(event)
-{
+function DragAddressOverTargetControl(event) {
   var dragSession = gDragService.getCurrentSession();
 
   if (!dragSession.isDataFlavorSupported("text/x-moz-address"))
      return;
 
   var trans = Cc["@mozilla.org/widget/transferable;1"]
                 .createInstance(Ci.nsITransferable);
   trans.init(getLoadContext());
   trans.addDataFlavor("text/x-moz-address");
 
   var canDrop = true;
 
-  for ( var i = 0; i < dragSession.numDropItems; ++i )
-  {
-    dragSession.getData ( trans, i );
-    var dataObj = new Object();
-    var bestFlavor = new Object();
-    var len = new Object();
-    try
-    {
-      trans.getAnyTransferData ( bestFlavor, dataObj, len );
-    }
-    catch (ex)
-    {
+  for (var i = 0; i < dragSession.numDropItems; ++i) {
+    dragSession.getData(trans, i);
+    var dataObj = {};
+    var bestFlavor = {};
+    var len = {};
+    try {
+      trans.getAnyTransferData(bestFlavor, dataObj, len);
+    } catch (ex) {
       canDrop = false;
       break;
     }
   }
   dragSession.canDrop = canDrop;
 }
 
-function DropAddressOverTargetControl(event)
-{
+function DropAddressOverTargetControl(event) {
   var dragSession = gDragService.getCurrentSession();
 
   var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
   trans.addDataFlavor("text/x-moz-address");
 
-  for ( var i = 0; i < dragSession.numDropItems; ++i )
-  {
-    dragSession.getData ( trans, i );
-    var dataObj = new Object();
-    var bestFlavor = new Object();
-    var len = new Object();
+  for (var i = 0; i < dragSession.numDropItems; ++i) {
+    dragSession.getData(trans, i);
+    var dataObj = {};
+    var bestFlavor = {};
+    var len = {};
 
     // Ensure we catch any empty data that may have slipped through
-    try
-    {
-      trans.getAnyTransferData ( bestFlavor, dataObj, len);
-    }
-    catch (ex)
-    {
+    try {
+      trans.getAnyTransferData(bestFlavor, dataObj, len);
+    } catch (ex) {
       continue;
     }
 
-    if ( dataObj )
+    if (dataObj)
       dataObj = dataObj.value.QueryInterface(Ci.nsISupportsString);
-    if ( !dataObj )
+    if (!dataObj)
       continue;
 
     // pull the address out of the data object
     var address = dataObj.data.substring(0, len.value);
     if (!address)
       continue;
 
     DropRecipient(address);
--- a/mailnews/addrbook/content/abMailListDialog.js
+++ b/mailnews/addrbook/content/abMailListDialog.js
@@ -1,224 +1,198 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../mail/components/addrbook/content/abCommon.js */
+/* import-globals-from ../../../mail/components/compose/content/addressingWidgetOverlay.js */
+
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource:///modules/MailServices.jsm");
+
 top.MAX_RECIPIENTS = 1;
 var inputElementType = "";
 
 var gListCard;
 var gEditList;
 var oldListName = "";
 var gLoadListeners = [];
 var gSaveListeners = [];
 
-try
-{
+try {
   var gDragService = Cc["@mozilla.org/widget/dragservice;1"]
                        .getService(Ci.nsIDragService);
-}
-catch (e)
-{
+} catch (e) {
 }
 
 // Returns the load context for the current window
 function getLoadContext() {
   return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
-function mailingListExists(listname)
-{
-  if (MailServices.ab.mailListNameExists(listname))
-  {
+function mailingListExists(listname) {
+  if (MailServices.ab.mailListNameExists(listname)) {
     Services.prompt.alert(window,
       gAddressBookBundle.getString("mailListNameExistsTitle"),
       gAddressBookBundle.getString("mailListNameExistsMessage"));
     return true;
   }
   return false;
 }
 
-function GetListValue(mailList, doAdd)
-{
+function GetListValue(mailList, doAdd) {
   var listname = document.getElementById("ListName").value.trim();
 
-  if (listname.length == 0)
-  {
+  if (listname.length == 0) {
     var alertText = gAddressBookBundle.getString("emptyListName");
     alert(alertText);
     return false;
   }
-  else
-  {
-    var canonicalNewListName = listname.toLowerCase();
-    var canonicalOldListName = oldListName.toLowerCase();
-    if (doAdd)
-    {
-      if (mailingListExists(canonicalNewListName))
-        return false;
-    }
-    else if (canonicalOldListName != canonicalNewListName)
-    {
-      if (mailingListExists(canonicalNewListName))
-        return false;
-    }
+
+  var canonicalNewListName = listname.toLowerCase();
+  var canonicalOldListName = oldListName.toLowerCase();
+  if (doAdd) {
+    if (mailingListExists(canonicalNewListName))
+      return false;
+  } else if (canonicalOldListName != canonicalNewListName) {
+    if (mailingListExists(canonicalNewListName))
+      return false;
   }
 
   mailList.isMailList = true;
   mailList.dirName = listname;
-  mailList.listNickName = document.getElementById('ListNickName').value;
-  mailList.description = document.getElementById('ListDescription').value;
+  mailList.listNickName = document.getElementById("ListNickName").value;
+  mailList.description = document.getElementById("ListDescription").value;
 
   var oldTotal = mailList.addressLists.length;
   var i = 1;
   var pos = 0;
   var inputField, fieldValue, cardproperty;
-  while ((inputField = awGetInputElement(i)))
-  {
+  while ((inputField = awGetInputElement(i))) {
 
     fieldValue = inputField.value;
 
-    if (doAdd || (!doAdd && pos >= oldTotal))
+    if (doAdd || pos >= oldTotal)
       cardproperty = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance();
     else
       cardproperty = mailList.addressLists.queryElementAt(pos, Ci.nsIAbCard);
 
-    if (fieldValue == "")
-    {
+    if (fieldValue == "") {
       if (!doAdd && cardproperty)
-      try
-      {
+      try {
         mailList.addressLists.removeElementAt(pos);
         --oldTotal;
-      }
-      catch(ex)
-      {
+      } catch (ex) {
         // Ignore attempting to remove an item
         // at a position greater than the number
         // of elements in the addressLists attribute
       }
-    }
-    else if (cardproperty)
-    {
+    } else if (cardproperty) {
       cardproperty = cardproperty.QueryInterface(Ci.nsIAbCard);
-      if (cardproperty)
-      {
+      if (cardproperty) {
         let addrObjects = MailServices.headerParser
                                       .makeFromDisplayAddress(fieldValue, {});
-        for (let j = 0; j < addrObjects.length; j++)
-        {
-          if (j > 0)
-          {
+        for (let j = 0; j < addrObjects.length; j++) {
+          if (j > 0) {
             cardproperty = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance();
             cardproperty = cardproperty.QueryInterface(Ci.nsIAbCard);
           }
           cardproperty.primaryEmail = addrObjects[j].email;
           cardproperty.displayName = addrObjects[j].name || addrObjects[j].email;
 
-          if (doAdd || (doAdd == false && pos >= oldTotal))
+          if (doAdd || pos >= oldTotal)
             mailList.addressLists.appendElement(cardproperty);
         }
         pos++;
       }
     }
     i++;
   }
 
   --i;
 
-  if (doAdd == false && i < oldTotal)
-  {
+  if (!doAdd && i < oldTotal) {
     for (var j = i; j < oldTotal; j++)
       mailList.addressLists.removeElementAt(j);
   }
   return true;
 }
 
-function MailListOKButton()
-{
-  var popup = document.getElementById('abPopup');
-  if (popup)
-  {
-    var uri = popup.getAttribute('value');
+function MailListOKButton() {
+  var popup = document.getElementById("abPopup");
+  if (popup) {
+    var uri = popup.getAttribute("value");
 
     // FIX ME - hack to avoid crashing if no ab selected because of blank option bug from template
     // should be able to just remove this if we are not seeing blank lines in the ab popup
     if (!uri)
       return false;  // don't close window
     // -----
 
-    //Add mailing list to database
+    // Add mailing list to database
     var mailList = Cc["@mozilla.org/addressbook/directoryproperty;1"].createInstance();
     mailList = mailList.QueryInterface(Ci.nsIAbDirectory);
 
-    if (GetListValue(mailList, true))
-    {
+    if (GetListValue(mailList, true)) {
       var parentDirectory = GetDirectoryFromURI(uri);
       mailList = parentDirectory.addMailList(mailList);
       NotifySaveListeners(mailList);
+    } else {
+      return false;
     }
-    else
-      return false;
   }
 
   return true;  // close the window
 }
 
-function OnLoadNewMailList()
-{
+function OnLoadNewMailList() {
   var selectedAB = null;
 
   InitCommonJS();
 
-  if ("arguments" in window && window.arguments[0])
-  {
+  if ("arguments" in window && window.arguments[0]) {
     var abURI = window.arguments[0].selectedAB;
     if (abURI && abURI != kAllDirectoryRoot + "?") {
       var directory = GetDirectoryFromURI(abURI);
       if (directory.isMailList) {
         var parentURI = GetParentDirectoryFromMailingListURI(abURI);
         if (parentURI) {
           selectedAB = parentURI;
         }
-      }
-      else if (directory.readOnly) {
+      } else if (directory.readOnly) {
         selectedAB = kPersonalAddressbookURI;
-      }
-      else {
+      } else {
         selectedAB = abURI;
       }
     }
   }
 
   if (!selectedAB)
     selectedAB = kPersonalAddressbookURI;
 
   // set popup with address book names
-  var abPopup = document.getElementById('abPopup');
+  var abPopup = document.getElementById("abPopup");
   abPopup.value = selectedAB;
 
   AppendNewRowAndSetFocus();
   awFitDummyRows(1);
 
   document.addEventListener("keypress", awDocumentKeyPress, true);
 
   // focus on first name
-  var listName = document.getElementById('ListName');
+  var listName = document.getElementById("ListName");
   if (listName)
-    setTimeout( function(firstTextBox) { firstTextBox.focus(); }, 0, listName );
+    setTimeout(function(firstTextBox) { firstTextBox.focus(); }, 0, listName);
 
   NotifyLoadListeners(directory);
 }
 
-function EditListOKButton()
-{
-  //edit mailing list in database
-  if (GetListValue(gEditList, false))
-  {
+function EditListOKButton() {
+  // edit mailing list in database
+  if (GetListValue(gEditList, false)) {
     if (gListCard) {
       // modify the list card (for the results pane) from the mailing list
       gListCard.displayName = gEditList.dirName;
       gListCard.lastName = gEditList.dirName;
       gListCard.setProperty("NickName", gEditList.listNickName);
       gListCard.setProperty("Notes", gEditList.description);
     }
 
@@ -227,57 +201,53 @@ function EditListOKButton()
 
     window.arguments[0].refresh = true;
     return true;  // close the window
   }
 
   return false;
 }
 
-function OnLoadEditList()
-{
+function OnLoadEditList() {
   InitCommonJS();
 
   gListCard = window.arguments[0].abCard;
   var listUri  = window.arguments[0].listURI;
 
   gEditList = GetDirectoryFromURI(listUri);
 
-  document.getElementById('ListName').value = gEditList.dirName;
-  document.getElementById('ListNickName').value = gEditList.listNickName;
-  document.getElementById('ListDescription').value = gEditList.description;
+  document.getElementById("ListName").value = gEditList.dirName;
+  document.getElementById("ListNickName").value = gEditList.listNickName;
+  document.getElementById("ListDescription").value = gEditList.description;
   oldListName = gEditList.dirName;
 
   document.title = gAddressBookBundle.getFormattedString("mailingListTitleEdit", [oldListName]);
 
-  if (gEditList.addressLists)
-  {
+  if (gEditList.addressLists) {
     let total = gEditList.addressLists.length;
-    if (total)
-    {
+    if (total) {
       let listbox = document.getElementById("addressingWidget");
       let newListBoxNode = listbox.cloneNode(false);
       let templateNode = listbox.querySelector("richlistitem");
 
       top.MAX_RECIPIENTS = 0;
-      for (let i = 0; i < total; i++)
-      {
+      for (let i = 0; i < total; i++) {
         let card = gEditList.addressLists.queryElementAt(i, Ci.nsIAbCard);
         let address = MailServices.headerParser.makeMailboxObject(
           card.displayName, card.primaryEmail).toString();
         SetInputValue(address, newListBoxNode, templateNode);
       }
       listbox.parentNode.replaceChild(newListBoxNode, listbox);
     }
   }
 
   // Is this directory read-only? If so, we now need to set all the fields to
   // read-only.
   if (gEditList.readOnly) {
-    const kMailListFields = [ 'ListName', 'ListNickName', 'ListDescription' ];
+    const kMailListFields = ["ListName", "ListNickName", "ListDescription"];
 
     for (let i = 0; i < kMailListFields.length; ++i)
       document.getElementById(kMailListFields[i]).readOnly = true;
 
     document.documentElement.buttons = "accept";
     document.documentElement.removeAttribute("ondialogaccept");
 
     // Getting a sane read-only implementation for the addressing widget would
@@ -292,308 +262,274 @@ function OnLoadEditList()
   // workaround for bug 118337 - for mailing lists that have more rows than fits inside
   // the display, the value of the textbox inside the new row isn't inherited into the input -
   // the first row then appears to be duplicated at the end although it is actually empty.
   // see awAppendNewRow which copies first row and clears it
   setTimeout(AppendLastRow, 0);
   NotifyLoadListeners(gEditList);
 }
 
-function AppendLastRow()
-{
+function AppendLastRow() {
   AppendNewRowAndSetFocus();
   awFitDummyRows(1);
 
   // focus on first name
-  var listName = document.getElementById('ListName');
+  var listName = document.getElementById("ListName");
   if (listName)
     listName.focus();
 }
 
-function AppendNewRowAndSetFocus()
-{
+function AppendNewRowAndSetFocus() {
   var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
   if (lastInput && lastInput.value)
     awAppendNewRow(true);
   else
     awSetFocus(top.MAX_RECIPIENTS, lastInput);
 }
 
-function SetInputValue(inputValue, parentNode, templateNode)
-{
-    top.MAX_RECIPIENTS++;
+function SetInputValue(inputValue, parentNode, templateNode) {
+  top.MAX_RECIPIENTS++;
 
-    var newNode = templateNode.cloneNode(true);
-    parentNode.appendChild(newNode); // we need to insert the new node before we set the value of the select element!
+  var newNode = templateNode.cloneNode(true);
+  parentNode.appendChild(newNode); // we need to insert the new node before we set the value of the select element!
 
-    var input = newNode.getElementsByTagName(awInputElementName());
-    if (input && input.length == 1)
-    {
-    //We need to set the value using both setAttribute and .value else we will
+  var input = newNode.getElementsByTagName(awInputElementName());
+  if (input && input.length == 1) {
+    // We need to set the value using both setAttribute and .value else we will
     // lose the content when the field is not visible. See bug 37435
-      input[0].setAttribute("value", inputValue);
-      input[0].value = inputValue;
-      input[0].setAttribute("id", "addressCol1#" + top.MAX_RECIPIENTS);
+    input[0].setAttribute("value", inputValue);
+    input[0].value = inputValue;
+    input[0].setAttribute("id", "addressCol1#" + top.MAX_RECIPIENTS);
   }
 }
 
-function awNotAnEmptyArea(event)
-{
-  //This is temporary until i figure out how to ensure to always having an empty space after the last row
+function awNotAnEmptyArea(event) {
+  // This is temporary until i figure out how to ensure to always having an empty space after the last row
 
   var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
   if (lastInput && lastInput.value)
     awAppendNewRow(false);
 
   event.stopPropagation();
 }
 
-function awClickEmptySpace(target, setFocus)
-{
+function awClickEmptySpace(target, setFocus) {
   if (target == null || target.localName != "hbox")
     return;
 
   var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
 
   if (lastInput && lastInput.value)
     awAppendNewRow(setFocus);
   else
     if (setFocus)
       awSetFocus(top.MAX_RECIPIENTS, lastInput);
 }
 
-function awReturnHit(inputElement)
-{
+function awReturnHit(inputElement) {
   var row = awGetRowByInputElement(inputElement);
-  if (inputElement.value)
-  {
-    var nextInput = awGetInputElement(row+1);
+  if (inputElement.value) {
+    var nextInput = awGetInputElement(row + 1);
     if (!nextInput)
       awAppendNewRow(true);
     else
-      awSetFocus(row+1, nextInput);
+      awSetFocus(row + 1, nextInput);
   }
 }
 
-function awDeleteRow(rowToDelete)
-{
+function awDeleteRow(rowToDelete) {
   /* When we delete a row, we must reset the id of others row in order to not break the sequence */
   var maxRecipients = top.MAX_RECIPIENTS;
   awRemoveRow(rowToDelete);
 
   var numberOfCols = awGetNumberOfCols();
-  for (var row = rowToDelete + 1; row <= maxRecipients; row ++)
+  for (var row = rowToDelete + 1; row <= maxRecipients; row++)
     for (var col = 1; col <= numberOfCols; col++)
-      awGetElementByCol(row, col).setAttribute("id", "addressCol" + (col) + "#" + (row-1));
+      awGetElementByCol(row, col).setAttribute("id", "addressCol" + (col) + "#" + (row - 1));
 
   awTestRowSequence();
 }
 
-function awInputChanged(inputElement)
-{
+function awInputChanged(inputElement) {
 //  AutoCompleteAddress(inputElement);
 
-  //Do we need to add a new row?
+  // Do we need to add a new row?
   var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
   if (lastInput && lastInput.value && !top.doNotCreateANewRow)
     awAppendNewRow(false);
   top.doNotCreateANewRow = false;
 }
 
-function awInputElementName()
-{
-    if (inputElementType == "")
-        inputElementType = document.getElementById("addressCol1#1").localName;
-    return inputElementType;
+function awInputElementName() {
+  if (inputElementType == "")
+      inputElementType = document.getElementById("addressCol1#1").localName;
+  return inputElementType;
 }
 
-function awAppendNewRow(setFocus)
-{
+function awAppendNewRow(setFocus) {
   var body = document.getElementById("addressingWidget");
   var listitem1 = awGetListItem(1);
 
-  if (body && listitem1)
-  {
+  if (body && listitem1) {
     var nextDummy = awGetNextDummyRow();
     var newNode = listitem1.cloneNode(true);
     if (nextDummy)
       body.replaceChild(newNode, nextDummy);
     else
       body.appendChild(newNode);
 
     top.MAX_RECIPIENTS++;
 
     var input = newNode.getElementsByTagName(awInputElementName());
-    if (input && input.length == 1)
-    {
+    if (input && input.length == 1) {
       input[0].setAttribute("value", "");
       input[0].setAttribute("id", "addressCol1#" + top.MAX_RECIPIENTS);
 
-      if (input[0].getAttribute('focused') != '')
-        input[0].removeAttribute('focused');
+      if (input[0].getAttribute("focused") != "")
+        input[0].removeAttribute("focused");
     }
     // focus on new input widget
-    if (setFocus && input )
+    if (setFocus && input)
       awSetFocus(top.MAX_RECIPIENTS, input[0]);
   }
 }
 
 
 // functions for accessing the elements in the addressing widget
 
-function awGetInputElement(row)
-{
-    return document.getElementById("addressCol1#" + row);
+function awGetInputElement(row) {
+  return document.getElementById("addressCol1#" + row);
 }
 
 
-function _awSetFocus()
-{
+function _awSetFocus() {
   var listbox = document.getElementById("addressingWidget");
-  try
-  {
+  try {
     var theNewRow = awGetListItem(top.awRow);
 
     listbox.ensureElementIsVisible(theNewRow);
     top.awInputElement.focus();
-  }
-  catch(ex)
-  {
-    top.awFocusRetry ++;
-    if (top.awFocusRetry < 8)
-    {
+  } catch (ex) {
+    top.awFocusRetry++;
+    if (top.awFocusRetry < 8) {
       dump("_awSetFocus failed, try it again...\n");
       setTimeout(_awSetFocus, 0);
+    } else {
+      dump("_awSetFocus failed, forget about it!\n");
     }
-    else
-      dump("_awSetFocus failed, forget about it!\n");
   }
 }
 
-function awTabFromRecipient(element, event)
-{
-  //If we are the last element in the listbox, we don't want to create a new row.
+function awTabFromRecipient(element, event) {
+  // If we are the last element in the listbox, we don't want to create a new row.
   if (element == awGetInputElement(top.MAX_RECIPIENTS))
     top.doNotCreateANewRow = true;
 }
 
-function DragOverAddressListTree(event)
-{
-  var validFlavor = false;
+function DragOverAddressListTree(event) {
   var dragSession = gDragService.getCurrentSession();
 
   // XXX add support for other flavors here
   if (dragSession.isDataFlavorSupported("text/x-moz-address")) {
     dragSession.canDrop = true;
   }
 }
 
-function DropOnAddressListTree(event)
-{
+function DropOnAddressListTree(event) {
   let dragSession = gDragService.getCurrentSession();
   let trans;
 
   try {
    trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
    trans.init(getLoadContext());
    trans.addDataFlavor("text/x-moz-address");
-  }
-  catch (ex) {
+  } catch (ex) {
     return;
   }
 
-  for (let i = 0; i < dragSession.numDropItems; ++i)
-  {
+  for (let i = 0; i < dragSession.numDropItems; ++i) {
     dragSession.getData(trans, i);
-    let dataObj = new Object();
-    let bestFlavor = new Object();
-    let len = new Object();
+    let dataObj = {};
+    let bestFlavor = {};
+    let len = {};
     trans.getAnyTransferData(bestFlavor, dataObj, len);
     if (dataObj)
       dataObj = dataObj.value.QueryInterface(Ci.nsISupportsString);
     if (!dataObj)
       continue;
 
     // pull the URL out of the data object
     let address = dataObj.data.substring(0, len.value);
     if (!address)
       continue;
 
     DropListAddress(event.target, address);
   }
 }
 
-function DropListAddress(target, address)
-{
+function DropListAddress(target, address) {
   // Set focus on a new available, visible row.
   awClickEmptySpace(target, true);
   if (top.MAX_RECIPIENTS == 0)
     top.MAX_RECIPIENTS = 1;
 
   // Break apart the MIME-ready header address into individual addressees to
   // add to the dialog.
   let addresses = {}, names = {}, fullNames = {};
   MailServices.headerParser.parseHeadersWithArray(address, addresses, names,
     fullNames);
-  for (let full of fullNames.value)
-  {
+  for (let full of fullNames.value) {
     let lastInput = awGetInputElement(top.MAX_RECIPIENTS);
     lastInput.value = full;
     awAppendNewRow(true);
   }
 }
 
 /* Allows extensions to register a listener function for
  * when a mailing list is loaded.  The listener function
  * should take two parameters - the first being the
  * mailing list being loaded, the second one being the
  * current window document.
  */
-function RegisterLoadListener(aListener)
-{
+function RegisterLoadListener(aListener) {
   gLoadListeners.push(aListener);
 }
 
 /* Allows extensions to unload a load listener function.
  */
-function UnregisterLoadListener(aListener)
-{
+function UnregisterLoadListener(aListener) {
   var fIndex = gLoadListeners.indexOf(aListener);
   if (fIndex != -1)
     gLoadListeners.splice(fIndex, 1);
 }
 
 /* Allows extensions to register a listener function for
  * when a mailing list is saved.  Like a load listener,
  * the save listener should take two parameters: the first
  * being a copy of the mailing list that is being saved,
  * and the second being the current window document.
  */
-function RegisterSaveListener(aListener)
-{
+function RegisterSaveListener(aListener) {
   gSaveListeners.push(aListener);
 }
 
 /* Allows extensions to unload a save listener function.
  */
-function UnregisterSaveListener(aListener)
-{
+function UnregisterSaveListener(aListener) {
   var fIndex = gSaveListeners.indexOf(aListener);
   if (fIndex != -1)
     gSaveListeners.splice(fIndex, 1);
 }
 
 /* Notifies all load listeners.
  */
-function NotifyLoadListeners(aMailingList)
-{
+function NotifyLoadListeners(aMailingList) {
   for (let i = 0; i < gLoadListeners.length; i++)
     gLoadListeners[i](aMailingList, document);
 }
 
 /* Notifies all save listeners.
  */
-function NotifySaveListeners(aMailingList)
-{
+function NotifySaveListeners(aMailingList) {
   for (let i = 0; i < gSaveListeners.length; i++)
     gSaveListeners[i](aMailingList, document);
 }
 
--- a/mailnews/addrbook/content/abResultsPane.js
+++ b/mailnews/addrbook/content/abResultsPane.js
@@ -1,47 +1,52 @@
 /* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 ; js-indent-level: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../mail/components/addrbook/content/abCommon.js */
+/* globals GetAbViewListener */
+// gCurFrame is SeaMonkey-only */
+/* globals gCurFrame */
+
 /**
  * Use of items in this file require:
  *
  * getSelectedDirectoryURI()
  *   returns the URI of the selected directory
  * AbResultsPaneDoubleClick(card)
  *   Is called when the results pane is double-clicked, with the clicked card.
  * AbEditCard(card)
  *   Is called when a card is to be edited, with the card as the parameter.
  *
  * The following function is only required if ResultsPaneController is used:
  *
  * goSetMenuValue()
  *   Core function in globalOverlay.js
  */
+/* globals getSelectedDirectoryURI, AbResultsPaneDoubleClick, AbEditCard, goSetMenuValue */
 
 // List/card selections in the results pane.
 var kNothingSelected = 0;
 var kListsAndCards = 1;
 var kMultipleListsOnly = 2;
 var kSingleListOnly = 3;
 var kCardsOnly = 4;
 
 // Global Variables
 
 // gAbView holds an object with an nsIAbView interface
 var gAbView = null;
 // Holds a reference to the "abResultsTree" document element. Initially
 // set up by SetAbView.
 var gAbResultsTree = null;
 
-function SetAbView(aURI)
-{
+function SetAbView(aURI) {
   // If we don't have a URI, just clear the view and leave everything else
   // alone.
   if (!aURI) {
     gAbView.clearView();
     return;
   }
 
   // If we do have a URI, we want to allow updating the review even if the
@@ -53,18 +58,17 @@ function SetAbView(aURI)
   if (!gAbResultsTree) {
     gAbResultsTree = document.getElementById("abResultsTree");
     gAbResultsTree.controllers.appendController(ResultsPaneController);
   }
 
   if (gAbView) {
     sortColumn = gAbView.sortColumn;
     sortDirection = gAbView.sortDirection;
-  }
-  else {
+  } else {
     if (gAbResultsTree.hasAttribute("sortCol"))
       sortColumn = gAbResultsTree.getAttribute("sortCol");
     var sortColumnNode = document.getElementById(sortColumn);
     if (sortColumnNode && sortColumnNode.hasAttribute("sortDirection"))
       sortDirection = sortColumnNode.getAttribute("sortDirection");
   }
 
   var directory = GetDirectoryFromURI(aURI);
@@ -98,46 +102,40 @@ function SetAbView(aURI)
       abResultsTree.hidden = false;
     if (cardViewOuterBox)
       cardViewOuterBox.hidden = false;
     if (blankResultsPaneMessageBox)
       blankResultsPaneMessageBox.hidden = true;
   }
 }
 
-function CloseAbView()
-{
+function CloseAbView() {
   if (gAbView)
     gAbView.clearView();
 }
 
-function GetOneOrMoreCardsSelected()
-{
+function GetOneOrMoreCardsSelected() {
   return (gAbView && (gAbView.selection.getRangeCount() > 0));
 }
 
-function GetSelectedAddresses()
-{
+function GetSelectedAddresses() {
   return GetAddressesForCards(GetSelectedAbCards());
 }
 
-function GetNumSelectedCards()
-{
+function GetNumSelectedCards() {
  try {
    return gAbView.selection.count;
- }
- catch (ex) {
+ } catch (ex) {
  }
 
  // if something went wrong, return 0 for the count.
  return 0;
 }
 
-function GetSelectedCardTypes()
-{
+function GetSelectedCardTypes() {
   var cards = GetSelectedAbCards();
   if (!cards) {
     Cu.reportError("ERROR: GetSelectedCardTypes: |cards| is null.");
     return kNothingSelected; // no view
   }
   var count = cards.length;
   if (count == 0)
     return kNothingSelected;  // nothing selected
@@ -147,54 +145,57 @@ function GetSelectedCardTypes()
   for (let i = 0; i < count; i++) {
     // We can assume no values from GetSelectedAbCards will be null.
     if (cards[i].isMailList)
       mailingListCnt++;
     else
       cardCnt++;
   }
 
-  return (mailingListCnt == 0) ? kCardsOnly :
-           (cardCnt > 0) ? kListsAndCards :
-             (mailingListCnt == 1) ? kSingleListOnly :
-               kMultipleListsOnly;
+  if (mailingListCnt == 0) {
+    return kCardsOnly;
+  }
+  if (cardCnt > 0) {
+    return kListsAndCards;
+  }
+  if (mailingListCnt == 1) {
+    return kSingleListOnly;
+  }
+  return kMultipleListsOnly;
 }
 
 // NOTE, will return -1 if more than one card selected, or no cards selected.
-function GetSelectedCardIndex()
-{
+function GetSelectedCardIndex() {
   if (!gAbView)
     return -1;
 
   var treeSelection = gAbView.selection;
   if (treeSelection.getRangeCount() == 1) {
-    var start = new Object;
-    var end = new Object;
+    var start = {};
+    var end = {};
     treeSelection.getRangeAt(0, start, end);
     if (start.value == end.value)
       return start.value;
   }
 
   return -1;
 }
 
 // NOTE, returns the card if exactly one card is selected, null otherwise
-function GetSelectedCard()
-{
+function GetSelectedCard() {
   var index = GetSelectedCardIndex();
   return (index == -1) ? null : gAbView.getCardFromRow(index);
 }
 
 /**
  * Return a (possibly empty) list of cards
  *
  * It pushes only non-null/empty element, if any, into the returned list.
  */
-function GetSelectedAbCards()
-{
+function GetSelectedAbCards() {
   var abView = gAbView;
 
   // if sidebar is open, and addressbook panel is open and focused,
   // then use the ab view from sidebar (gCurFrame is from sidebarOverlay.js)
   if (document.getElementById("sidebar-box")) {
     const abPanelUrl =
       "chrome://messenger/content/addressbook/addressbook-panel.xul";
     if (gCurFrame &&
@@ -203,17 +204,16 @@ function GetSelectedAbCards()
       abView = gCurFrame.contentDocument.defaultView.gAbView;
   }
 
   if (!abView)
     return [];
 
   let cards = [];
   var count = abView.selection.getRangeCount();
-  var current = 0;
   for (let i = 0; i < count; ++i) {
     let start = {};
     let end = {};
 
     abView.selection.getRangeAt(i, start, end);
 
     for (let j = start.value; j <= end.value; ++j) {
       // avoid inserting null element into the list. GetRangeAt() may be buggy.
@@ -225,51 +225,47 @@ function GetSelectedAbCards()
   }
   return cards;
 }
 
 // XXX todo
 // an optimization might be to make this return
 // the selected ranges, which would be faster
 // when the user does large selections, but for now, let's keep it simple.
-function GetSelectedRows()
-{
+function GetSelectedRows() {
   var selectedRows = "";
 
   if (!gAbView)
     return selectedRows;
 
   var rangeCount = gAbView.selection.getRangeCount();
   for (let i = 0; i < rangeCount; ++i) {
-    var start = new Object;
-    var end = new Object;
+    var start = {};
+    var end = {};
     gAbView.selection.getRangeAt(i, start, end);
-    for (let j = start.value;j <= end.value; ++j) {
+    for (let j = start.value; j <= end.value; ++j) {
       if (selectedRows)
         selectedRows += ",";
       selectedRows += j;
     }
   }
 
   return selectedRows;
 }
 
-function AbSwapFirstNameLastName()
-{
+function AbSwapFirstNameLastName() {
   if (gAbView)
     gAbView.swapFirstNameLastName();
 }
 
-function AbEditSelectedCard()
-{
+function AbEditSelectedCard() {
   AbEditCard(GetSelectedCard());
 }
 
-function AbResultsPaneOnClick(event)
-{
+function AbResultsPaneOnClick(event) {
   // we only care about button 0 (left click) events
   if (event.button != 0) return;
 
   // all we need to worry about here is double clicks
   // and column header clicks.
   //
   // we get in here for clicks on the "treecol" (headers)
   // and the "scrollbarbutton" (scrollbar buttons)
@@ -281,108 +277,98 @@ function AbResultsPaneOnClick(event)
     var sortDirection;
     var currentDirection = t.getAttribute("sortDirection");
 
     // Revert the sort order. If none is set, use Ascending.
     sortDirection = currentDirection == kDefaultAscending ?
                                         kDefaultDescending : kDefaultAscending;
 
     SortAndUpdateIndicators(t.id, sortDirection);
-  }
-  else if (t.localName == "treechildren") {
+  } else if (t.localName == "treechildren") {
     // figure out what row the click was in
     var row = gAbResultsTree.getRowAt(event.clientX, event.clientY);
     if (row == -1)
       return;
 
     if (event.detail == 2)
       AbResultsPaneDoubleClick(gAbView.getCardFromRow(row));
   }
 }
 
-function AbSortAscending()
-{
+function AbSortAscending() {
   var sortColumn = gAbResultsTree.getAttribute("sortCol");
   SortAndUpdateIndicators(sortColumn, kDefaultAscending);
 }
 
-function AbSortDescending()
-{
+function AbSortDescending() {
   var sortColumn = gAbResultsTree.getAttribute("sortCol");
   SortAndUpdateIndicators(sortColumn, kDefaultDescending);
 }
 
-function SortResultPane(sortColumn)
-{
+function SortResultPane(sortColumn) {
   var sortDirection = kDefaultAscending;
   if (gAbView)
      sortDirection = gAbView.sortDirection;
 
   SortAndUpdateIndicators(sortColumn, sortDirection);
 }
 
-function SortAndUpdateIndicators(sortColumn, sortDirection)
-{
+function SortAndUpdateIndicators(sortColumn, sortDirection) {
   UpdateSortIndicators(sortColumn, sortDirection);
 
   if (gAbView)
     gAbView.sortBy(sortColumn, sortDirection);
 }
 
-function UpdateSortIndicators(colID, sortDirection)
-{
+function UpdateSortIndicators(colID, sortDirection) {
   var sortedColumn = null;
 
   // set the sort indicator on the column we are sorted by
   if (colID) {
     sortedColumn = document.getElementById(colID);
     if (sortedColumn) {
-      sortedColumn.setAttribute("sortDirection",sortDirection);
+      sortedColumn.setAttribute("sortDirection", sortDirection);
       gAbResultsTree.setAttribute("sortCol", colID);
     }
   }
 
   // remove the sort indicator from all the columns
   // except the one we are sorted by
   var currCol = gAbResultsTree.firstChild.firstChild;
   while (currCol) {
     if (currCol != sortedColumn && currCol.localName == "treecol")
       currCol.removeAttribute("sortDirection");
     currCol = currCol.nextSibling;
   }
 }
 
-function InvalidateResultsPane()
-{
+function InvalidateResultsPane() {
   if (gAbResultsTree)
     gAbResultsTree.invalidate();
 }
 
 // Controller object for Results Pane
-var ResultsPaneController =
-{
-  supportsCommand: function(command)
-  {
+var ResultsPaneController = {
+  supportsCommand(command) {
     switch (command) {
       case "cmd_selectAll":
       case "cmd_delete":
       case "button_delete":
       case "cmd_printcardpreview":
       case "cmd_printcard":
       case "cmd_properties":
       case "cmd_newlist":
       case "cmd_newCard":
         return true;
       default:
         return false;
     }
   },
 
-  isCommandEnabled: function(command)
-  {
+  isCommandEnabled(command) {
     switch (command) {
       case "cmd_selectAll":
         return true;
       case "cmd_delete":
       case "button_delete": {
         let numSelected;
         let enabled = false;
         if (gAbView && gAbView.selection) {
@@ -463,18 +449,17 @@ var ResultsPaneController =
       case "cmd_newlist":
       case "cmd_newCard":
         return true;
       default:
         return false;
     }
   },
 
-  doCommand: function(command)
-  {
+  doCommand(command) {
     switch (command) {
       case "cmd_selectAll":
         if (gAbView)
           gAbView.selectAll();
         break;
       case "cmd_delete":
       case "button_delete":
         AbDelete();
@@ -486,21 +471,19 @@ var ResultsPaneController =
         AbNewList();
         break;
       case "cmd_newCard":
         AbNewCard();
         break;
     }
   },
 
-  onEvent: function(event)
-  {
+  onEvent(event) {
     // on blur events set the menu item texts back to the normal values
     if (event == "blur")
       goSetMenuValue("cmd_delete", "valueDefault");
-  }
+  },
 };
 
-function SelectFirstCard()
-{
+function SelectFirstCard() {
   if (gAbView && gAbView.selection && (gAbView.selection.count > 0))
     gAbView.selection.select(0);
 }
--- a/mailnews/addrbook/content/addrbookWidgets.xml
+++ b/mailnews/addrbook/content/addrbookWidgets.xml
@@ -149,17 +149,17 @@
 
       <method name="onItemRemoved">
         <parameter name="aParentDir"/>
         <parameter name="aItem"/>
         <body><![CDATA[
           if (aItem instanceof Ci.nsIAbDirectory) {
             // Find the item in the list to remove.
             // We can't use indexOf here because we need loose equality.
-            for (var index = this._directories.length; --index >= 0; )
+            for (var index = this._directories.length; --index >= 0;)
               if (this._directories[index] == aItem)
                 break;
             if (index != -1) {
               this._directories.splice(index, 1);
               // Are we removing the selected directory?
               if (this.parentNode.selectedItem ==
                   this.removeChild(this.childNodes[index])) {
                 // If so, try to select the first directory, if available.
@@ -177,17 +177,17 @@
         <parameter name="aItem"/>
         <parameter name="aProperty"/>
         <parameter name="aOldValue"/>
         <parameter name="aNewValue"/>
         <body><![CDATA[
           if (aItem instanceof Ci.nsIAbDirectory) {
             // Find the item in the list to rename.
             // We can't use indexOf here because we need loose equality.
-            for (var oldIndex = this._directories.length; --oldIndex >= 0; )
+            for (var oldIndex = this._directories.length; --oldIndex >= 0;)
               if (this._directories[oldIndex] == aItem)
                 break;
             if (oldIndex != -1)
               this._rebuild();
           }
         ]]></body>
       </method>
 
@@ -229,17 +229,17 @@
 
           this._directories.sort(this._compare);
 
           // Push mailing lists back appending them after their respective
           // containing addressbook.
           for (let d = this._directories.length - 1; d >= 0; d--) {
             let abURI = this._directories[d].URI;
             if (abURI in lists) {
-              lists[abURI].sort(function(a,b) { return a.dirName.localeCompare(b.dirName); });
+              lists[abURI].sort(function(a, b) { return a.dirName.localeCompare(b.dirName); });
               let listIndex = d;
               for (let list of lists[abURI]) {
                 listIndex++;
                 this._directories.splice(listIndex, 0, list);
               }
               delete lists[abURI];
             }
           }
@@ -300,16 +300,18 @@
       <property name="mapURL" readonly="true">
         <getter><![CDATA[
           return this._createMapItURL();
         ]]></getter>
       </property>
 
       <constructor>
         <![CDATA[
+          ChromeUtils.import("resource://gre/modules/Services.jsm");
+
           this._setWidgetDisabled(true);
         ]]>
       </constructor>
 
       <!--
         Initializes the necessary address data from an addressbook card.
         @param aCard        A nsIAbCard to get the address data from.
         @param aAddrPrefix  A prefix of the card properties to use. Use "Home" or "Work".
@@ -321,20 +323,20 @@
           let mapItURLFormat = this._getMapURLPref(0);
           let doNotShowMap = !mapItURLFormat || !aAddrPrefix || !aCard;
           this._setWidgetDisabled(doNotShowMap);
           if (doNotShowMap)
             return;
 
           this.setAttribute("map_address1", aCard.getProperty(aAddrPrefix + "Address"));
           this.setAttribute("map_address2", aCard.getProperty(aAddrPrefix + "Address2"));
-          this.setAttribute("map_city"    , aCard.getProperty(aAddrPrefix + "City"));
-          this.setAttribute("map_state"   , aCard.getProperty(aAddrPrefix + "State"));
-          this.setAttribute("map_zip"     , aCard.getProperty(aAddrPrefix + "ZipCode"));
-          this.setAttribute("map_country" , aCard.getProperty(aAddrPrefix + "Country"));
+          this.setAttribute("map_city", aCard.getProperty(aAddrPrefix + "City"));
+          this.setAttribute("map_state", aCard.getProperty(aAddrPrefix + "State"));
+          this.setAttribute("map_zip", aCard.getProperty(aAddrPrefix + "ZipCode"));
+          this.setAttribute("map_country", aCard.getProperty(aAddrPrefix + "Country"));
         ]]></body>
       </method>
 
       <!--
         Initializes the necessary address data from passed in values.
         -->
       <method name="initMapAddress">
         <parameter name="aAddr1"/>
@@ -347,20 +349,20 @@
           let mapItURLFormat = this._getMapURLPref(0);
           let doNotShowMap = !mapItURLFormat || !(aAddr1 + aAddr2 + aCity + aState + aZip + aCountry);
           this._setWidgetDisabled(doNotShowMap);
           if (doNotShowMap)
             return;
 
           this.setAttribute("map_address1", aAddr1);
           this.setAttribute("map_address2", aAddr2);
-          this.setAttribute("map_city"    , aCity);
-          this.setAttribute("map_state"   , aState);
-          this.setAttribute("map_zip"     , aZip);
-          this.setAttribute("map_country" , aCountry);
+          this.setAttribute("map_city", aCity);
+          this.setAttribute("map_state", aState);
+          this.setAttribute("map_zip", aZip);
+          this.setAttribute("map_country", aCountry);
         ]]></body>
       </method>
 
       <!--
         Sets the disabled/enabled state of the parent widget (e.g. a button).
         -->
       <method name="_setWidgetDisabled">
         <parameter name="aDisabled"/>
@@ -380,17 +382,18 @@
           let url = null;
           if (!aIndex) {
             url = Services.prefs.getComplexValue("mail.addr_book.mapit_url.format",
                                                  Ci.nsIPrefLocalizedString).data;
           } else {
             try {
               url = Services.prefs.getComplexValue("mail.addr_book.mapit_url." + aIndex + ".format",
                                                    Ci.nsIPrefLocalizedString).data;
-            } catch (e) { }
+            } catch (e) {
+            }
           }
 
           return url;
         ]]></body>
       </method>
 
       <!--
         Builds menuitem elements representing map services defined in prefs
--- a/mailnews/addrbook/prefs/content/pref-directory-add.js
+++ b/mailnews/addrbook/prefs/content/pref-directory-add.js
@@ -1,18 +1,23 @@
 /* -*- Mode: Java; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/hostnameUtils.jsm");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var {
+  isLegalHostNameOrIP,
+  cleanUpHostName,
+} = ChromeUtils.import("resource:///modules/hostnameUtils.jsm", null);
+var {
+  fixIterator,
+} = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
 var gCurrentDirectory = null;
 var gReplicationBundle = null;
 var gReplicationService =
   Cc["@mozilla.org/addressbook/ldap-replication-service;1"].
              getService(Ci.nsIAbLDAPReplicationService);
 var gReplicationCancelled = false;
 var gProgressText;
@@ -20,26 +25,24 @@ var gProgressMeter;
 var gDownloadInProgress = false;
 
 var kDefaultMaxHits = 100;
 var kDefaultLDAPPort = 389;
 var kDefaultSecureLDAPPort = 636;
 var kLDAPDirectory = 0;  // defined in nsDirPrefs.h
 
 var ldapOfflineObserver = {
-  observe: function(subject, topic, state)
-  {
+  observe(subject, topic, state) {
     // sanity checks
     if (topic != "network:offline-status-changed") return;
     setDownloadOfflineOnlineState(state == "offline");
-  }
-}
+  },
+};
 
-function Startup()
-{
+function Startup() {
   gReplicationBundle = document.getElementById("bundle_replication");
 
   document.getElementById("download").label =
     gReplicationBundle.getString("downloadButton");
   document.getElementById("download").accessKey =
     gReplicationBundle.getString("downloadButton.accesskey");
 
   if ("arguments" in window && window.arguments[0]) {
@@ -67,31 +70,29 @@ function Startup()
     }
   } else {
     document.title = gReplicationBundle.getString("directoryTitleNew");
     fillDefaultSettings();
     // Don't add observer here as it doesn't make any sense.
   }
 }
 
-function onUnload()
-{
+function onUnload() {
   if ("arguments" in window &&
       window.arguments[0] &&
       !Services.prefs.prefIsLocked(gCurrentDirectory.dirPrefId +
                                    ".disable_button_download")) {
     // Remove the observer that we put in on dialog startup
     Services.obs.removeObserver(ldapOfflineObserver,
                                 "network:offline-status-changed");
   }
 }
 
 var progressListener = {
-  onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
-  {
+  onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
     if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
       // start the spinning
       gProgressMeter.removeAttribute("value");
       gProgressText.value = gReplicationBundle.getString(aStatus ?
                                                          "replicationStarted" :
                                                          "changesStarted");
       gDownloadInProgress = true;
       document.getElementById("download").label =
@@ -99,105 +100,98 @@ var progressListener = {
       document.getElementById("download").accessKey =
         gReplicationBundle.getString("cancelDownloadButton.accesskey");
     }
 
     if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
       EndDownload(aStatus);
     }
   },
-  onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
-  {
+  onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {
     gProgressText.value = gReplicationBundle.getFormattedString("currentCount",
                                                                 [aCurSelfProgress]);
   },
-  onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags)
-  {
+  onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
   },
-  onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
-  {
+  onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
   },
-  onSecurityChange: function(aWebProgress, aRequest, state)
-  {
+  onSecurityChange(aWebProgress, aRequest, state) {
   },
-  onContentBlockingEvent: function(aWebProgress, aRequest, aEvent)
-  {
+  onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
   },
   QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener",
                                           "nsISupportsWeakReference"]),
 };
 
-function DownloadNow()
-{
+function DownloadNow() {
   if (!gDownloadInProgress) {
     gProgressText = document.getElementById("replicationProgressText");
     gProgressMeter = document.getElementById("replicationProgressMeter");
 
     gProgressText.hidden = false;
     gProgressMeter.hidden = false;
     gReplicationCancelled = false;
 
     try {
       if (gCurrentDirectory instanceof Ci.nsIAbLDAPDirectory)
         gReplicationService.startReplication(gCurrentDirectory,
                                              progressListener);
       else
         EndDownload(false);
-    }
-    catch (ex) {
+    } catch (ex) {
       EndDownload(false);
     }
   } else {
     gReplicationCancelled = true;
     try {
       gReplicationService.cancelReplication(gCurrentDirectory.dirPrefId);
-    }
-    catch (ex) {
+    } catch (ex) {
       // XXX todo
       // perhaps replication hasn't started yet?  This can happen if you hit cancel after attempting to replication when offline
       dump("unexpected failure while cancelling.  ex=" + ex + "\n");
     }
   }
 }
 
-function EndDownload(aStatus)
-{
+function EndDownload(aStatus) {
   document.getElementById("download").label =
     gReplicationBundle.getString("downloadButton");
   document.getElementById("download").accessKey =
     gReplicationBundle.getString("downloadButton.accesskey");
 
   // stop the spinning
   gProgressMeter.value = 100;
   gProgressMeter.hidden = true;
 
   gDownloadInProgress = false;
-  gProgressText.value =
-    gReplicationBundle.getString(aStatus ? "replicationSucceeded" :
-                                 gReplicationCancelled ? "replicationCancelled" :
-                                  "replicationFailed");
+  if (aStatus) {
+    gProgressText.value = gReplicationBundle.getString("replicationSucceeded");
+  } else if (gReplicationCancelled) {
+    gProgressText.value = gReplicationBundle.getString("replicationCancelled");
+  } else {
+    gProgressText.value = gReplicationBundle.getString("replicationFailed");
+  }
 }
 
 // fill the settings panel with the data from the preferences.
 //
-function fillSettings()
-{
+function fillSettings() {
   document.getElementById("description").value = gCurrentDirectory.dirName;
 
   if (gCurrentDirectory instanceof Ci.nsIAbLDAPDirectory) {
     var ldapUrl = gCurrentDirectory.lDAPURL;
 
     document.getElementById("results").value = gCurrentDirectory.maxHits;
     document.getElementById("login").value = gCurrentDirectory.authDn;
     document.getElementById("hostname").value = ldapUrl.host;
     document.getElementById("basedn").value = ldapUrl.dn;
     document.getElementById("search").value = ldapUrl.filter;
 
     var sub = document.getElementById("sub");
-    switch(ldapUrl.scope) {
+    switch (ldapUrl.scope) {
     case Ci.nsILDAPURL.SCOPE_ONELEVEL:
       sub.radioGroup.selectedItem = document.getElementById("one");
       break;
     default:
       sub.radioGroup.selectedItem = sub;
       break;
     }
 
@@ -206,90 +200,80 @@ function fillSettings()
     case "GSSAPI":
       sasl.selectedItem = document.getElementById("GSSAPI");
       break;
     default:
       sasl.selectedItem = document.getElementById("Simple");
       break;
     }
 
-    var secure = ldapUrl.options & ldapUrl.OPT_SECURE
+    var secure = ldapUrl.options & ldapUrl.OPT_SECURE;
     if (secure)
       document.getElementById("secure").setAttribute("checked", "true");
 
     if (ldapUrl.port == -1)
       document.getElementById("port").value =
         (secure ? kDefaultSecureLDAPPort : kDefaultLDAPPort);
     else
       document.getElementById("port").value = ldapUrl.port;
   }
 
   // check if any of the preferences for this server are locked.
-  //If they are locked disable them
+  // If they are locked disable them
   DisableUriFields(gCurrentDirectory.dirPrefId + ".uri");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".description", "description");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".disable_button_download", "download");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".maxHits", "results");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".auth.dn", "login");
 }
 
-function DisableElementIfPrefIsLocked(aPrefName, aElementId)
-{
+function DisableElementIfPrefIsLocked(aPrefName, aElementId) {
   if (Services.prefs.prefIsLocked(aPrefName))
-    document.getElementById(aElementId).setAttribute('disabled', true);
+    document.getElementById(aElementId).setAttribute("disabled", true);
 }
 
 // disables all the text fields corresponding to the .uri pref.
-function DisableUriFields(aPrefName)
-{
+function DisableUriFields(aPrefName) {
   if (Services.prefs.prefIsLocked(aPrefName)) {
     let lockedElements = document.querySelectorAll('[disableiflocked="true"]');
     for (let i = 0; i < lockedElements.length; i++)
-      lockedElements[i].setAttribute('disabled', 'true');
+      lockedElements[i].setAttribute("disabled", "true");
   }
 }
 
-function onSecure()
-{
+function onSecure() {
   document.getElementById("port").value =
     document.getElementById("secure").checked ? kDefaultSecureLDAPPort :
                                                 kDefaultLDAPPort;
 }
 
-function fillDefaultSettings()
-{
+function fillDefaultSettings() {
   document.getElementById("port").value = kDefaultLDAPPort;
   document.getElementById("results").value = kDefaultMaxHits;
   var sub = document.getElementById("sub");
   sub.radioGroup.selectedItem = sub;
 
   // Disable the download button and add some text indicating why.
   document.getElementById("download").disabled = true;
   document.getElementById("downloadWarningMsg").hidden = false;
   document.getElementById("downloadWarningMsg").textContent = document.
                                       getElementById("bundle_addressBook").
                                       getString("abReplicationSaveSettings");
 }
 
-function hasCharacters(number)
-{
+function hasCharacters(number) {
   var re = /[0-9]/g;
   var num = number.match(re);
-  if(num && (num.length == number.length))
+  if (num && (num.length == number.length))
     return false;
-  else
-    return true;
+  return true;
 }
 
-function onAccept()
-{
+function onAccept() {
   try {
-    let pref_string_content = "";
-    let pref_string_title = "";
-
     let description = document.getElementById("description").value.trim();
     let hostname = cleanUpHostName(document.getElementById("hostname").value);
     let port = document.getElementById("port").value;
     let secure = document.getElementById("secure");
     let results = document.getElementById("results").value;
     let errorValue = null;
     let errorArg = null;
     let saslMechanism = "";
@@ -301,39 +285,40 @@ function onAccept()
         if ((ab.dirName.toLowerCase() == newName.toLowerCase()) &&
             (!gCurrentDirectory || (ab.URI != gCurrentDirectory.URI))) {
           return ab.dirName;
         }
       }
       return null;
     };
 
-    if (!description)
+    if (!description) {
       errorValue = "invalidName";
-    else if ((errorArg = findDupeName(description))) {
+    } else if ((errorArg = findDupeName(description))) {
       errorValue = "duplicateNameText";
+    } else if (!isLegalHostNameOrIP(hostname)) {
+      errorValue = "invalidHostname";
+    } else if (port && hasCharacters(port)) {
+      // XXX write isValidDn and call it on the dn string here?
+      errorValue = "invalidPortNumber";
+    } else if (results && hasCharacters(results)) {
+      errorValue = "invalidResults";
     }
-    else if (!isLegalHostNameOrIP(hostname))
-      errorValue = "invalidHostname";
-    // XXX write isValidDn and call it on the dn string here?
-    else if (port && hasCharacters(port))
-      errorValue = "invalidPortNumber";
-    else if (results && hasCharacters(results))
-      errorValue = "invalidResults";
 
     if (!errorValue) {
       // XXX Due to the LDAP c-sdk pass a dummy url to the IO service, then
       // update the parts (bug 473351).
       let ldapUrl = Services.io.newURI(
         (secure.checked ? "ldaps://" : "ldap://") + "localhost/dc=???")
         .QueryInterface(Ci.nsILDAPURL);
 
-      let newPort = port ? port :
-                          (secure.checked ? kDefaultSecureLDAPPort :
-                                            kDefaultLDAPPort);
+      let newPort = port;
+      if (!port) {
+        port = secure.checked ? kDefaultSecureLDAPPort : kDefaultLDAPPort;
+      }
       ldapUrl = ldapUrl.mutate()
                        .setHost(hostname)
                        .setPort(newPort)
                        .finalize()
                        .QueryInterface(Ci.nsILDAPURL);
 
       ldapUrl.dn = document.getElementById("basedn").value;
       ldapUrl.scope = document.getElementById("one").selected ?
@@ -345,18 +330,17 @@ function onAccept()
         saslMechanism = "GSSAPI";
       }
 
       // check if we are modifying an existing directory or adding a new directory
       if (gCurrentDirectory) {
         gCurrentDirectory.dirName = description;
         gCurrentDirectory.lDAPURL = ldapUrl.QueryInterface(Ci.nsILDAPURL);
         window.opener.gNewServerString = gCurrentDirectory.dirPrefId;
-      }
-      else { // adding a new directory
+      } else { // adding a new directory
         window.opener.gNewServerString =
           MailServices.ab.newAddressBook(description, ldapUrl.spec, kLDAPDirectory);
       }
 
       // XXX This is really annoying - both new/modify Address Book don't
       // give us back the new directory we just created - so go find it from
       // rdf so we can set a few final things up on it.
       var targetURI = "moz-abldapdirectory://" + window.opener.gNewServerString;
@@ -372,47 +356,37 @@ function onAccept()
       // set window.opener.gUpdate to true so that LDAP Directory Servers
       // dialog gets updated
       window.opener.gUpdate = true;
     } else {
       let addressBookBundle = document.getElementById("bundle_addressBook");
 
       let errorText;
       if (errorArg)
-        errorText = addressBookBundle.getFormattedString(errorValue, [errorArg])
+        errorText = addressBookBundle.getFormattedString(errorValue, [errorArg]);
       else
         errorText = addressBookBundle.getString(errorValue);
 
       Services.prompt.alert(window, document.title, errorText);
       return false;
     }
   } catch (outer) {
     Cu.reportError("Internal error in pref-directory-add.js:onAccept() " + outer);
   }
   return true;
 }
 
-function onCancel()
-{
+function onCancel() {
   window.opener.gUpdate = false;
 }
 
-
-// called by Help button in platform overlay
-function doHelpButton()
-{
-  openHelp("mail-ldap-properties");
-}
-
 // Sets the download button state for offline or online.
 // This function should only be called for ldap edit dialogs.
-function setDownloadOfflineOnlineState(isOffline)
-{
-  if (isOffline)
-  {
+function setDownloadOfflineOnlineState(isOffline) {
+  if (isOffline) {
     // Disable the download button and add some text indicating why.
     document.getElementById("downloadWarningMsg").textContent = document.
       getElementById("bundle_addressBook").
       getString("abReplicationOfflineWarning");
   }
   document.getElementById("downloadWarningMsg").hidden = !isOffline;
   document.getElementById("download").disabled = isOffline;
 }
--- a/mailnews/addrbook/prefs/content/pref-editdirectories.js
+++ b/mailnews/addrbook/prefs/content/pref-editdirectories.js
@@ -1,144 +1,132 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../../mail/components/addrbook/content/abCommon.js */
+
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // Listener to refresh the list items if something changes. In all these
 // cases we just rebuild the list as it is easier than searching/adding in the
 // correct places an would be an infrequent operation.
 var gAddressBookAbListener = {
-  onItemAdded: function(parentDir, item) {
-    if (item instanceof Ci.nsIAbDirectory) {
-      fillDirectoryList();
-    }
-  },
-  onItemRemoved: function(parentDir, item) {
+  onItemAdded(parentDir, item) {
     if (item instanceof Ci.nsIAbDirectory) {
       fillDirectoryList();
     }
   },
-  onItemPropertyChanged: function(item, property, oldValue, newValue) {
+  onItemRemoved(parentDir, item) {
     if (item instanceof Ci.nsIAbDirectory) {
       fillDirectoryList();
     }
-  }
+  },
+  onItemPropertyChanged(item, property, oldValue, newValue) {
+    if (item instanceof Ci.nsIAbDirectory) {
+      fillDirectoryList();
+    }
+  },
 };
 
-function onInitEditDirectories()
-{
+function onInitEditDirectories() {
   // For AbDeleteDirectory in abCommon.js
   gAddressBookBundle = document.getElementById("bundle_addressBook");
 
   // If the pref is locked disable the "Add" button
   if (Services.prefs.prefIsLocked("ldap_2.disable_button_add"))
-    document.getElementById("addButton").setAttribute('disabled', true);
+    document.getElementById("addButton").setAttribute("disabled", true);
 
   // Fill out the directory list
   fillDirectoryList();
 
   const nsIAbListener = Ci.nsIAbListener;
   // Add a listener so we can update correctly if the list should change
   MailServices.ab.addAddressBookListener(gAddressBookAbListener,
                                          nsIAbListener.itemAdded |
                                          nsIAbListener.directoryRemoved |
                                          nsIAbListener.itemChanged);
 }
 
-function onUninitEditDirectories()
-{
+function onUninitEditDirectories() {
   MailServices.ab.removeAddressBookListener(gAddressBookAbListener);
 }
 
-function fillDirectoryList()
-{
+function fillDirectoryList() {
   var abList = document.getElementById("directoriesList");
 
   // Empty out anything in the list
   while (abList.hasChildNodes())
     abList.lastChild.remove();
 
   // Init the address book list
   let directories = MailServices.ab.directories;
   let holdingArray = [];
   while (directories && directories.hasMoreElements()) {
     let ab = directories.getNext();
     if (ab instanceof Ci.nsIAbDirectory && ab.isRemote)
       holdingArray.push(ab);
   }
 
-  holdingArray.sort(function (a, b) { return a.dirName.localeCompare(b.dirName); });
+  holdingArray.sort(function(a, b) { return a.dirName.localeCompare(b.dirName); });
 
-  holdingArray.forEach(function (ab) {
+  holdingArray.forEach(function(ab) {
     let item = document.createElement("richlistitem");
     let label = document.createElement("label");
     label.setAttribute("value", ab.dirName);
     item.appendChild(label);
     item.setAttribute("value", ab.URI);
 
     abList.appendChild(item);
   });
 }
 
-function selectDirectory()
-{
+function selectDirectory() {
   var abList = document.getElementById("directoriesList");
   var editButton = document.getElementById("editButton");
   var removeButton = document.getElementById("removeButton");
 
   if (abList && abList.selectedItem) {
     editButton.removeAttribute("disabled");
 
     // If the disable delete button pref for the selected directory is set,
     // disable the delete button for that directory.
-    let disable = false;
     let ab = MailServices.ab.getDirectory(abList.value);
-    try {
-      disable = Services.prefs.getBoolPref(ab.dirPrefId + ".disable_delete");
-    }
-    catch(ex){
-      // If this preference is not set, it's ok.
-    }
+    let disable = Services.prefs.getBoolPref(ab.dirPrefId + ".disable_delete", false);
     if (disable)
       removeButton.setAttribute("disabled", true);
     else
       removeButton.removeAttribute("disabled");
-  }
-  else {
+  } else {
     editButton.setAttribute("disabled", true);
     removeButton.setAttribute("disabled", true);
   }
 }
 
-function dblClickDirectory(event)
-{
+function dblClickDirectory(event) {
   // We only care about left click events.
   if (event.button != 0)
     return;
 
   editDirectory();
 }
 
-function editDirectory()
-{
+function editDirectory() {
   var abList = document.getElementById("directoriesList");
 
   if (abList && abList.selectedItem) {
     let abURI = abList.value;
     let ab = MailServices.ab.getDirectory(abURI);
 
     window.openDialog(ab.propertiesChromeURI, "editDirectory",
                       "chrome,modal=yes,resizable=no",
                       { selectedDirectory: ab });
   }
 }
 
-function removeDirectory()
-{
+function removeDirectory() {
   var abList = document.getElementById("directoriesList");
 
   if (abList && abList.selectedItem)
     AbDeleteDirectory(abList.value);
 }
--- a/mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
+++ b/mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
@@ -12,17 +12,17 @@ nsAbAutoCompleteMyDomain.prototype = {
   QueryInterface: ChromeUtils.generateQI([
       Ci.nsIAutoCompleteSearch]),
 
   cachedIdKey: "",
   cachedIdentity: null,
 
   applicableHeaders: new Set(["addr_to", "addr_cc", "addr_bcc", "addr_reply"]),
 
-  startSearch: function(aString, aSearchParam, aResult, aListener) {
+  startSearch(aString, aSearchParam, aResult, aListener) {
     let params = aSearchParam ? JSON.parse(aSearchParam) : {};
     let applicable = ("type" in params) && this.applicableHeaders.has(params.type);
     const ACR = Ci.nsIAutoCompleteResult;
     var address = null;
     if (applicable && aString && !aString.includes(",")) {
       if (("idKey" in params) && (params.idKey != this.cachedIdKey)) {
         this.cachedIdentity = MailServices.accounts.getIdentity(params.idKey);
         this.cachedIdKey = params.idKey;
@@ -33,26 +33,26 @@ nsAbAutoCompleteMyDomain.prototype = {
     }
 
     var result = {
       searchString: aString,
       searchResult: address ? ACR.RESULT_SUCCESS : ACR.RESULT_FAILURE,
       defaultIndex: -1,
       errorDescription: null,
       matchCount: address ? 1 : 0,
-      getValueAt: function() { return address; },
-      getLabelAt: function() { return this.getValueAt(); },
-      getCommentAt: function() { return null; },
-      getStyleAt: function() { return "default-match"; },
-      getImageAt: function() { return null; },
-      getFinalCompleteValueAt: function(aIndex) {
+      getValueAt() { return address; },
+      getLabelAt() { return this.getValueAt(); },
+      getCommentAt() { return null; },
+      getStyleAt() { return "default-match"; },
+      getImageAt() { return null; },
+      getFinalCompleteValueAt(aIndex) {
         return this.getValueAt(aIndex);
       },
-      removeValueAt: function() {}
+      removeValueAt() {},
     };
     aListener.onSearchResult(this, result);
   },
 
-  stopSearch: function() {}
+  stopSearch() {},
 };
 
 var components = [nsAbAutoCompleteMyDomain];
 var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/mailnews/addrbook/src/nsAbAutoCompleteSearch.js
+++ b/mailnews/addrbook/src/nsAbAutoCompleteSearch.js
@@ -1,15 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/ABQueryUtils.jsm");
+var {
+  getSearchTokens,
+  getModelQuery,
+  modelQueryHasUserValue,
+  generateQueryURI,
+} = ChromeUtils.import("resource:///modules/ABQueryUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var ACR = Ci.nsIAutoCompleteResult;
 var nsIAbAutoCompleteResult = Ci.nsIAbAutoCompleteResult;
 
 function nsAbAutoCompleteResult(aSearchString) {
   // Can't create this in the prototype as we'd get the same array for
   // all instances
@@ -33,57 +38,57 @@ nsAbAutoCompleteResult.prototype = {
   searchResult: ACR.RESULT_NOMATCH,
   defaultIndex: -1,
   errorDescription: null,
 
   get matchCount() {
     return this._searchResults.length;
   },
 
-  getValueAt: function getValueAt(aIndex) {
+  getValueAt(aIndex) {
     return this._searchResults[aIndex].value;
   },
 
-  getLabelAt: function getLabelAt(aIndex) {
+  getLabelAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
-  getCommentAt: function getCommentAt(aIndex) {
+  getCommentAt(aIndex) {
     return this._searchResults[aIndex].comment;
   },
 
-  getStyleAt: function getStyleAt(aIndex) {
+  getStyleAt(aIndex) {
     return "local-abook";
   },
 
-  getImageAt: function getImageAt(aIndex) {
+  getImageAt(aIndex) {
     return "";
   },
 
-  getFinalCompleteValueAt: function(aIndex) {
+  getFinalCompleteValueAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
-  removeValueAt: function removeValueAt(aRowIndex, aRemoveFromDB) {
+  removeValueAt(aRowIndex, aRemoveFromDB) {
   },
 
   // nsIAbAutoCompleteResult
 
-  getCardAt: function getCardAt(aIndex) {
+  getCardAt(aIndex) {
     return this._searchResults[aIndex].card;
   },
 
-  getEmailToUse: function getEmailToUse(aIndex) {
+  getEmailToUse(aIndex) {
     return this._searchResults[aIndex].emailToUse;
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult])
-}
+  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult]),
+};
 
 function nsAbAutoCompleteSearch() {}
 
 nsAbAutoCompleteSearch.prototype = {
   // For component registration
   classID: Components.ID("2f946df9-114c-41fe-8899-81f10daf4f0c"),
 
   // This is set from a preference,
@@ -99,17 +104,17 @@ nsAbAutoCompleteSearch.prototype = {
   /**
    * Returns the popularity index for a given card. This takes account of a
    * translation bug whereby Thunderbird 2 stores its values in mork as
    * hexadecimal, and Thunderbird 3 stores as decimal.
    *
    * @param aDirectory  The directory that the card is in.
    * @param aCard       The card to return the popularity index for.
    */
-  _getPopularityIndex: function _getPopularityIndex(aDirectory, aCard) {
+  _getPopularityIndex(aDirectory, aCard) {
     let popularityValue = aCard.getProperty("PopularityIndex", "0");
     let popularityIndex = parseInt(popularityValue);
 
     // If we haven't parsed it the first time round, parse it as hexadecimal
     // and repair so that we don't have to keep repairing.
     if (isNaN(popularityIndex)) {
       popularityIndex = parseInt(popularityValue, 16);
 
@@ -117,18 +122,17 @@ nsAbAutoCompleteSearch.prototype = {
       if (isNaN(popularityIndex))
         popularityIndex = 0;
 
       // Now store this change so that we're not changing it each time around.
       if (!aDirectory.readOnly) {
         aCard.setProperty("PopularityIndex", popularityIndex);
         try {
           aDirectory.modifyCard(aCard);
-        }
-        catch (ex) {
+        } catch (ex) {
           Cu.reportError(ex);
         }
       }
     }
     return popularityIndex;
   },
 
   /**
@@ -136,17 +140,17 @@ nsAbAutoCompleteSearch.prototype = {
    * results that match the beginning of a "word" in the result to score better
    * than a result that matches only in the middle of the word.
    *
    * @param aCard - the card whose score is being decided
    * @param aAddress - full lower-cased address, including display name and address
    * @param aSearchString - search string provided by user
    * @return a score; a higher score is better than a lower one
    */
-  _getScore: function(aCard, aAddress, aSearchString) {
+  _getScore(aCard, aAddress, aSearchString) {
     const BEST = 100;
 
     // We will firstly check if the search term provided by the user
     // is the nick name for the card or at least in the beginning of it.
     let nick = aCard.getProperty("NickName", "").toLocaleLowerCase();
     aSearchString = aSearchString.toLocaleLowerCase();
     if (nick == aSearchString)
       return BEST + 1;
@@ -179,36 +183,36 @@ nsAbAutoCompleteSearch.prototype = {
    * Searches cards in the given directory. If a card is matched (and isn't
    * a mailing list) then the function will add a result for each email address
    * that exists.
    *
    * @param searchQuery  The boolean search query to use.
    * @param directory    An nsIAbDirectory to search.
    * @param result       The result element to append results to.
    */
-  _searchCards: function(searchQuery, directory, result) {
+  _searchCards(searchQuery, directory, result) {
     let childCards;
     try {
       childCards = this._abManager.getDirectory(directory.URI + searchQuery).childCards;
     } catch (e) {
       Cu.reportError("Error running addressbook query '" + searchQuery + "': " + e);
       return;
     }
 
     // Cache this values to save going through xpconnect each time
     var commentColumn = this._commentColumn == 1 ? directory.dirName : "";
 
     // Now iterate through all the cards.
     while (childCards.hasMoreElements()) {
       var card = childCards.getNext();
 
       if (card instanceof Ci.nsIAbCard) {
-        if (card.isMailList)
+        if (card.isMailList) {
           this._addToResult(commentColumn, directory, card, "", true, result);
-        else {
+        } else {
           let email = card.primaryEmail;
           if (email)
             this._addToResult(commentColumn, directory, card, email, true, result);
 
           email = card.getProperty("SecondEmail", "");
           if (email)
             this._addToResult(commentColumn, directory, card, email, false, result);
         }
@@ -222,17 +226,17 @@ nsAbAutoCompleteSearch.prototype = {
    * should still be included in the narrowed-down result.
    *
    * @param aCard        The card to check.
    * @param aEmailToUse  The email address to check against.
    * @param aSearchWords Array of words in the multi word search string.
    * @return             True if the card matches the search parameters, false
    *                     otherwise.
    */
-  _checkEntry: function _checkEntry(aCard, aEmailToUse, aSearchWords) {
+  _checkEntry(aCard, aEmailToUse, aSearchWords) {
     // Joining values of many fields in a single string so that a single
     // search query can be fired on all of them at once. Separating them
     // using spaces so that field1=> "abc" and field2=> "def" on joining
     // shouldn't return true on search for "bcd".
     // Note: This should be constructed from model query pref using
     // getModelQuery("mail.addr_book.autocompletequery.format")
     // but for now we hard-code the default value equivalent of the pref here
     // or else bail out before and reconstruct the full c++ query if the pref
@@ -257,17 +261,17 @@ nsAbAutoCompleteSearch.prototype = {
    * higher than the previous card.
    *
    * @param directory       The directory that the card is in.
    * @param card            The card that could be a duplicate.
    * @param lcEmailAddress  The emailAddress (name/address combination) to check
    *                        for duplicates against. Lowercased.
    * @param currentResults  The current results list.
    */
-  _checkDuplicate: function (directory, card, lcEmailAddress, currentResults) {
+  _checkDuplicate(directory, card, lcEmailAddress, currentResults) {
     let existingResult = currentResults._collectedValues.get(lcEmailAddress);
     if (!existingResult)
       return false;
 
     let popIndex = this._getPopularityIndex(directory, card);
     // It's a duplicate, is the new one more popular?
     if (popIndex > existingResult.popularity) {
       // Yes it is, so delete this element, return false and allow
@@ -289,18 +293,17 @@ nsAbAutoCompleteSearch.prototype = {
    * @param directory      The directory that the card is in.
    * @param card           The card being added to the results.
    * @param emailToUse     The email address from the card that should be used
    *                       for this result.
    * @param isPrimaryEmail Is the emailToUse the primary email? Set to true if
    *                       it is the case. For mailing lists set it to true.
    * @param result         The result to add the new entry to.
    */
-  _addToResult: function(commentColumn, directory, card,
-                         emailToUse, isPrimaryEmail, result) {
+  _addToResult(commentColumn, directory, card, emailToUse, isPrimaryEmail, result) {
     let mbox = this._parser.makeMailboxObject(card.displayName,
       card.isMailList ? card.getProperty("Notes", "") || card.displayName :
                         emailToUse);
     if (!mbox.email)
       return;
 
     let emailAddress = mbox.toString();
     let lcEmailAddress = emailAddress.toLocaleLowerCase();
@@ -308,36 +311,35 @@ nsAbAutoCompleteSearch.prototype = {
     // If it is a duplicate, then just return and don't add it. The
     // _checkDuplicate function deals with it all for us.
     if (this._checkDuplicate(directory, card, lcEmailAddress, result))
       return;
 
     result._collectedValues.set(lcEmailAddress, {
       value: emailAddress,
       comment: commentColumn,
-      card: card,
-      isPrimaryEmail: isPrimaryEmail,
-      emailToUse: emailToUse,
+      card,
+      isPrimaryEmail,
+      emailToUse,
       popularity: this._getPopularityIndex(directory, card),
-      score: this._getScore(card, lcEmailAddress, result.searchString)
+      score: this._getScore(card, lcEmailAddress, result.searchString),
     });
   },
 
   // nsIAutoCompleteSearch
 
   /**
    * Starts a search based on the given parameters.
    *
    * @see nsIAutoCompleteSearch for parameter details.
    *
    * It is expected that aSearchParam contains the identity (if any) to use
    * for determining if an address book should be autocompleted against.
    */
-  startSearch: function startSearch(aSearchString, aSearchParam,
-                                    aPreviousResult, aListener) {
+  startSearch(aSearchString, aSearchParam, aPreviousResult, aListener) {
     let params = aSearchParam ? JSON.parse(aSearchParam) : {};
     var result = new nsAbAutoCompleteResult(aSearchString);
     if (("type" in params) && !this.applicableHeaders.has(params.type)) {
       result.searchResult = ACR.RESULT_IGNORED;
       aListener.onSearchResult(this, result);
       return;
     }
 
@@ -355,19 +357,17 @@ nsAbAutoCompleteSearch.prototype = {
     }
 
     // Array of all the terms from the fullString search query
     // (separated on the basis of spaces or exact terms on the
     // basis of quotes).
     let searchWords = getSearchTokens(fullString);
 
     // Find out about the comment column
-    try {
-      this._commentColumn = Services.prefs.getIntPref("mail.autoComplete.commentColumn");
-    } catch(e) { }
+    this._commentColumn = Services.prefs.getIntPref("mail.autoComplete.commentColumn", 0);
 
     if (aPreviousResult instanceof nsIAbAutoCompleteResult &&
         aSearchString.startsWith(aPreviousResult.searchString) &&
         aPreviousResult.searchResult == ACR.RESULT_SUCCESS &&
         !result._modelQueryHasUserValue &&
         result.modelQuery == aPreviousResult.modelQuery) {
       // We have successful previous matches, and model query has not changed since
       // previous search, therefore just iterate through the list of previous result
@@ -383,29 +383,27 @@ nsAbAutoCompleteSearch.prototype = {
       for (let i = 0; i < aPreviousResult.matchCount; ++i) {
         let card = aPreviousResult.getCardAt(i);
         let email = aPreviousResult.getEmailToUse(i);
         if (this._checkEntry(card, email, searchWords)) {
           // Add matches into the results array. We re-sort as needed later.
           result._searchResults.push({
             value: aPreviousResult.getValueAt(i),
             comment: aPreviousResult.getCommentAt(i),
-            card: card,
+            card,
             isPrimaryEmail: (card.primaryEmail == email),
             emailToUse: email,
             popularity: parseInt(card.getProperty("PopularityIndex", "0")),
             score: this._getScore(card,
               aPreviousResult.getValueAt(i).toLocaleLowerCase(),
-              fullString)
+              fullString),
           });
         }
       }
-    }
-    else
-    {
+    } else {
       // Construct the search query from pref; using a query means we can
       // optimise on running the search through c++ which is better for string
       // comparisons (_checkEntry is relatively slow).
       // When user's fullstring search expression is a multiword query, search
       // for each word separately so that each result contains all the words
       // from the fullstring in the fields of the addressbook card
       // (see bug 558931 for explanations).
       // Use helper method to split up search query to multi-word search
@@ -446,20 +444,20 @@ nsAbAutoCompleteSearch.prototype = {
     if (result.matchCount) {
       result.searchResult = ACR.RESULT_SUCCESS;
       result.defaultIndex = 0;
     }
 
     aListener.onSearchResult(this, result);
   },
 
-  stopSearch: function stopSearch() {
+  stopSearch() {
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIAutoCompleteSearch])
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIAutoCompleteSearch]),
 };
 
 // Module
 
 var components = [nsAbAutoCompleteSearch];
 var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/mailnews/addrbook/src/nsAbLDAPAttributeMap.js
+++ b/mailnews/addrbook/src/nsAbLDAPAttributeMap.js
@@ -13,50 +13,49 @@ var NS_ABLDAPATTRIBUTEMAPSERVICE_CID = C
 function nsAbLDAPAttributeMap() {
   this.mPropertyMap = {};
   this.mAttrMap = {};
 }
 
 nsAbLDAPAttributeMap.prototype = {
   classID: NS_ABLDAPATTRIBUTEMAP_CID,
 
-  getAttributeList: function getAttributeList(aProperty) {
+  getAttributeList(aProperty) {
 
     if (!(aProperty in this.mPropertyMap)) {
       return null;
     }
 
     // return the joined list
     return this.mPropertyMap[aProperty].join(",");
   },
 
-  getAttributes: function getAttributes(aProperty, aCount, aAttrs) {
+  getAttributes(aProperty, aCount, aAttrs) {
 
     // fail if no entry for this
     if (!(aProperty in this.mPropertyMap)) {
       throw Cr.NS_ERROR_FAILURE;
     }
 
     aAttrs = this.mPropertyMap[aProperty];
     aCount = aAttrs.length;
     return aAttrs;
   },
 
-  getFirstAttribute: function getFirstAttribute(aProperty) {
+  getFirstAttribute(aProperty) {
 
     // fail if no entry for this
     if (!(aProperty in this.mPropertyMap)) {
       return null;
     }
 
     return this.mPropertyMap[aProperty][0];
   },
 
-  setAttributeList: function setAttributeList(aProperty, aAttributeList,
-                                              aAllowInconsistencies) {
+  setAttributeList(aProperty, aAttributeList, aAllowInconsistencies) {
 
     var attrs = aAttributeList.split(",");
 
     // check to make sure this call won't allow multiple mappings to be
     // created, if requested
     if (!aAllowInconsistencies) {
       for (var attr of attrs) {
         if (attr in this.mAttrMap && this.mAttrMap[attr] != aProperty) {
@@ -76,69 +75,68 @@ nsAbLDAPAttributeMap.prototype = {
     for (attr of attrs) {
       this.mAttrMap[attr] = aProperty;
     }
 
     // add them to the property map
     this.mPropertyMap[aProperty] = attrs;
   },
 
-  getProperty: function getProperty(aAttribute) {
+  getProperty(aAttribute) {
 
     if (!(aAttribute in this.mAttrMap)) {
       return null;
     }
 
     return this.mAttrMap[aAttribute];
   },
 
-  getAllCardAttributes: function getAllCardAttributes() {
+  getAllCardAttributes() {
     var attrs = [];
     for (var prop in this.mPropertyMap) {
       let attrArray = this.mPropertyMap[prop];
       attrs = attrs.concat(attrArray);
     }
 
     if (!attrs.length) {
       throw Cr.NS_ERROR_FAILURE;
     }
 
     return attrs.join(",");
   },
 
-  getAllCardProperties: function getAllCardProperties(aCount) {
+  getAllCardProperties(aCount) {
 
     var props = [];
     for (var prop in this.mPropertyMap) {
       props.push(prop);
     }
 
     aCount.value = props.length;
     return props;
   },
 
-  setFromPrefs: function setFromPrefs(aPrefBranchName) {
+  setFromPrefs(aPrefBranchName) {
     // get the right pref branch
     let branch = Services.prefs.getBranch(aPrefBranchName + ".");
 
     // get the list of children
     var childCount = {};
     var children = branch.getChildList("", childCount);
 
     // do the actual sets
     for (var child of children) {
       this.setAttributeList(child, branch.getCharPref(child), true);
     }
 
     // ensure that everything is kosher
     this.checkState();
   },
 
-  setCardPropertiesFromLDAPMessage: function
-    setCardPropertiesFromLDAPMessage(aMessage, aCard) {
+  setCardPropertiesFromLDAPMessage(aMessage, aCard) {
 
     var cardValueWasSet = false;
 
     var msgAttrCount = {};
     var msgAttrs = aMessage.getAttributes(msgAttrCount);
 
     // downcase the array for comparison
     function toLower(a) { return a.toLowerCase(); }
@@ -148,17 +146,17 @@ nsAbLDAPAttributeMap.prototype = {
     for (var prop in this.mPropertyMap) {
 
       // go through the list of possible attrs in precedence order
       for (var attr of this.mPropertyMap[prop]) {
 
         attr = attr.toLowerCase();
 
         // find the first attr that exists in this message
-        if (msgAttrs.indexOf(attr) != -1) {
+        if (msgAttrs.includes(attr)) {
 
           try {
             var values = aMessage.getValues(attr, {});
             // strip out the optional label from the labeledURI
             if (attr == "labeleduri" && values[0]) {
               var index = values[0].indexOf(" ");
               if (index != -1)
                 values[0] = values[0].substring(0, index);
@@ -172,59 +170,55 @@ nsAbLDAPAttributeMap.prototype = {
           }
         }
       }
     }
 
     if (!cardValueWasSet) {
       throw Cr.NS_ERROR_FAILURE;
     }
-
-    return;
   },
 
-  checkState: function checkState() {
+  checkState() {
 
     var attrsSeen = [];
 
     for (var prop in this.mPropertyMap) {
       let attrArray = this.mPropertyMap[prop];
       for (var attr of attrArray) {
 
         // multiple attributes that mapped to the empty string are permitted
         if (!attr.length) {
           continue;
         }
 
         // if we've seen this before, there's a problem
-        if (attrsSeen.indexOf(attr) != -1) {
+        if (attrsSeen.includes(attr)) {
           throw Cr.NS_ERROR_FAILURE;
         }
 
         // remember that we've seen it now
         attrsSeen.push(attr);
       }
     }
-
-    return;
   },
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIAbLDAPAttributeMap])
-}
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIAbLDAPAttributeMap]),
+};
 
 function nsAbLDAPAttributeMapService() {
 }
 
 nsAbLDAPAttributeMapService.prototype = {
 
   classID: NS_ABLDAPATTRIBUTEMAPSERVICE_CID,
 
   mAttrMaps: {},
 
-  getMapForPrefBranch: function getMapForPrefBranch(aPrefBranchName) {
+  getMapForPrefBranch(aPrefBranchName) {
 
     // if we've already got this map, return it
     if (aPrefBranchName in this.mAttrMaps) {
       return this.mAttrMaps[aPrefBranchName];
     }
 
     // otherwise, try and create it
     var attrMap = new nsAbLDAPAttributeMap();
@@ -233,13 +227,13 @@ nsAbLDAPAttributeMapService.prototype = 
 
     // cache
     this.mAttrMaps[aPrefBranchName] = attrMap;
 
     // and return
     return attrMap;
   },
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIAbLDAPAttributeMapService])
-}
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIAbLDAPAttributeMapService]),
+};
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsAbLDAPAttributeMap, nsAbLDAPAttributeMapService]);
 
--- a/mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
+++ b/mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
@@ -33,54 +33,54 @@ nsAbLDAPAutoCompleteResult.prototype = {
   searchResult: ACR.RESULT_NOMATCH,
   defaultIndex: -1,
   errorDescription: null,
 
   get matchCount() {
     return this._searchResults.length;
   },
 
-  getLabelAt: function getLabelAt(aIndex) {
+  getLabelAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
-  getValueAt: function getValueAt(aIndex) {
+  getValueAt(aIndex) {
     return this._searchResults[aIndex].value;
   },
 
-  getCommentAt: function getCommentAt(aIndex) {
+  getCommentAt(aIndex) {
     return this._commentColumn;
   },
 
-  getStyleAt: function getStyleAt(aIndex) {
+  getStyleAt(aIndex) {
     return this.searchResult == ACR.RESULT_FAILURE ? "remote-err" :
                                                      "remote-abook";
   },
 
-  getImageAt: function getImageAt(aIndex) {
+  getImageAt(aIndex) {
     return "";
   },
 
-  getFinalCompleteValueAt: function(aIndex) {
+  getFinalCompleteValueAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
-  removeValueAt: function removeValueAt(aRowIndex, aRemoveFromDB) {
+  removeValueAt(aRowIndex, aRemoveFromDB) {
   },
 
   // nsIAbAutoCompleteResult
 
-  getCardAt: function getCardAt(aIndex) {
+  getCardAt(aIndex) {
     return this._searchResults[aIndex].card;
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult])
-}
+  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult]),
+};
 
 function nsAbLDAPAutoCompleteSearch() {
   Services.obs.addObserver(this, "quit-application");
   this._timer = Cc["@mozilla.org/timer;1"]
                   .createInstance(Ci.nsITimer);
 }
 
 nsAbLDAPAutoCompleteSearch.prototype = {
@@ -104,25 +104,25 @@ nsAbLDAPAutoCompleteSearch.prototype = {
   _listener: null,
 
   _parser: MailServices.headerParser,
 
   applicableHeaders: new Set(["addr_to", "addr_cc", "addr_bcc", "addr_reply"]),
 
   // Private methods
 
-  _checkDuplicate: function _checkDuplicate(card, emailAddress) {
+  _checkDuplicate(card, emailAddress) {
     var lcEmailAddress = emailAddress.toLocaleLowerCase();
 
     return this._result._searchResults.some(function(result) {
       return result.value.toLocaleLowerCase() == lcEmailAddress;
     });
   },
 
-  _addToResult: function(card) {
+  _addToResult(card) {
     let mbox = this._parser.makeMailboxObject(card.displayName,
       card.isMailList ? card.getProperty("Notes", "") || card.displayName :
                         card.primaryEmail);
     if (!mbox.email)
       return;
 
     let emailAddress = mbox.toString();
 
@@ -136,23 +136,23 @@ nsAbLDAPAutoCompleteSearch.prototype = {
 
     // Next sort on full address
     while (insertPosition < this._result._searchResults.length &&
            emailAddress > this._result._searchResults[insertPosition].value)
       ++insertPosition;
 
     this._result._searchResults.splice(insertPosition, 0, {
       value: emailAddress,
-      card: card,
+      card,
     });
   },
 
   // nsIObserver
 
-  observe: function observer(subject, topic, data) {
+  observe(subject, topic, data) {
     if (topic == "quit-application") {
       Services.obs.removeObserver(this, "quit-application");
     } else if (topic != "timer-callback") {
       return;
     }
 
     // Force the individual query items to null, so that the memory
     // gets collected straight away.
@@ -160,18 +160,17 @@ nsAbLDAPAutoCompleteSearch.prototype = {
     this._book = null;
     this._context = -1;
     this._query = null;
     this._attributes = null;
   },
 
   // nsIAutoCompleteSearch
 
-  startSearch: function startSearch(aSearchString, aParam,
-                                    aPreviousResult, aListener) {
+  startSearch(aSearchString, aParam, aPreviousResult, aListener) {
     let params = JSON.parse(aParam) || {};
     let applicable = !("type" in params) || this.applicableHeaders.has(params.type);
 
     this._result = new nsAbLDAPAutoCompleteResult(aSearchString);
     aSearchString = aSearchString.toLocaleLowerCase();
 
     // If the search string isn't value, or contains a comma, or the user
     // hasn't enabled autocomplete, then just return no matches / or the
@@ -187,30 +186,28 @@ nsAbLDAPAutoCompleteSearch.prototype = {
     // The rules here: If the current identity has a directoryServer set, then
     // use that, otherwise, try the global preference instead.
     var acDirURI = null;
     var identity;
 
     if ("idKey" in params) {
       try {
         identity = MailServices.accounts.getIdentity(params.idKey);
-      }
-      catch(ex) {
+      } catch (ex) {
         Cu.reportError("Couldn't get specified identity, " +
                        "falling back to global settings");
       }
     }
 
     // Does the current identity override the global preference?
-    if (identity && identity.overrideGlobalPref)
+    if (identity && identity.overrideGlobalPref) {
       acDirURI = identity.directoryServer;
-    else {
+    } else if (Services.prefs.getBoolPref("ldap_2.autoComplete.useDirectory")) {
       // Try the global one
-      if (Services.prefs.getBoolPref("ldap_2.autoComplete.useDirectory"))
-        acDirURI = Services.prefs.getCharPref("ldap_2.autoComplete.directoryServer");
+      acDirURI = Services.prefs.getCharPref("ldap_2.autoComplete.directoryServer");
     }
 
     if (!acDirURI || Services.io.offline) {
       // No directory to search or we are offline, send a no match and return.
       aListener.onSearchResult(this, this._result);
       return;
     }
 
@@ -259,48 +256,47 @@ nsAbLDAPAutoCompleteSearch.prototype = {
     args.querySubDirectories = true;
     args.filter = filter;
 
     // Start the actual search
     this._context =
       this._query.doQuery(this._book, args, this, this._book.maxHits, 0);
   },
 
-  stopSearch: function stopSearch() {
+  stopSearch() {
     if (this._listener) {
       this._query.stopQuery(this._context);
       this._listener = null;
     }
   },
 
   // nsIAbDirSearchListener
 
-  onSearchFinished: function onSearchFinished(aResult, aErrorMsg) {
+  onSearchFinished(aResult, aErrorMsg) {
     if (!this._listener)
       return;
 
     if (aResult == nsIAbDirectoryQueryResultListener.queryResultComplete) {
       if (this._result.matchCount) {
         this._result.searchResult = ACR.RESULT_SUCCESS;
         this._result.defaultIndex = 0;
-      }
-      else
+      } else {
         this._result.searchResult = ACR.RESULT_NOMATCH;
-    }
-    else if (aResult == nsIAbDirectoryQueryResultListener.queryResultError) {
+      }
+    } else if (aResult == nsIAbDirectoryQueryResultListener.queryResultError) {
       this._result.searchResult = ACR.RESULT_FAILURE;
       this._result.defaultIndex = 0;
     }
     //    const long queryResultStopped  = 2;
     //    const long queryResultError    = 3;
     this._listener.onSearchResult(this, this._result);
     this._listener = null;
   },
 
-  onSearchFoundCard: function onSearchFoundCard(aCard) {
+  onSearchFoundCard(aCard) {
     if (!this._listener)
       return;
 
     this._addToResult(aCard);
 
     /* XXX autocomplete doesn't expect you to rearrange while searching
     if (this._result.matchCount)
       this._result.searchResult = ACR.RESULT_SUCCESS_ONGOING;
@@ -310,14 +306,14 @@ nsAbLDAPAutoCompleteSearch.prototype = {
     this._listener.onSearchResult(this, this._result);
     */
   },
 
   // nsISupports
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
                                           Ci.nsIAutoCompleteSearch,
-                                          Ci.nsIAbDirSearchListener])
+                                          Ci.nsIAbDirSearchListener]),
 };
 
 // Module
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsAbLDAPAutoCompleteSearch]);
new file mode 100644
--- /dev/null
+++ b/mailnews/addrbook/test/unit/.eslintrc.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = {
+  "extends": "plugin:mozilla/xpcshell-test",
+
+  "rules": {
+    "func-names": "off",
+    "mozilla/import-headjs-globals": "error",
+    "no-unused-vars": ["error", {
+      "args": "none",
+      "vars": "all",
+    }],
+  },
+};
--- a/mailnews/addrbook/test/unit/data/bug534822prefs.js
+++ b/mailnews/addrbook/test/unit/data/bug534822prefs.js
@@ -1,3 +1,4 @@
+/* globals pref */
 pref("ldap_2.servers.extension.description", "extension");
 pref("ldap_2.servers.extension.filename", "ldap1.mab");
 pref("ldap_2.servers.extension.uri", "ldap://test.invalid:389/o=invalid??sub");
--- a/mailnews/addrbook/test/unit/head_addrbook.js
+++ b/mailnews/addrbook/test/unit/head_addrbook.js
@@ -3,13 +3,14 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var CC = Components.Constructor;
 
 // Ensure the profile directory is set up
 do_get_profile();
 
 // Import the required setup scripts.
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/abSetup.js");
 
 registerCleanupFunction(function() {
   load("../../../resources/mailShutdown.js");
 });
--- a/mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
+++ b/mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
@@ -102,9 +102,9 @@ function check_ab(abConfig) {
 }
 
 function run_test() {
   // Check the default personal address book
   check_ab(kPABData);
 
   // Check the default collected address book
   check_ab(kCABData);
-};
+}
--- a/mailnews/addrbook/test/unit/test_bug534822.js
+++ b/mailnews/addrbook/test/unit/test_bug534822.js
@@ -14,29 +14,27 @@ function run_test() {
   specialPrefs = profileDir;
   specialPrefs.append("bug534822prefs.js");
 
   Services.prefs.readUserPrefsFromFile(specialPrefs);
 
   // Now load the ABs and check we've got all of them.
   let dirs = MailServices.ab.directories;
 
-  let dir;
-
   let results = [
     { name: "extension", result: false },
     { name: kPABData.dirName, result: false },
-    { name: kCABData.dirName, result: false }
+    { name: kCABData.dirName, result: false },
   ];
 
   while (dirs.hasMoreElements()) {
     let dir = dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
 
     for (let i = 0; i < results.length; ++i) {
       if (results[i].name == dir.dirName) {
         Assert.ok(!results[i].result);
         results[i].result = true;
       }
     }
   }
 
-  results.forEach(function (result) { Assert.ok(result.result); });
-};
+  results.forEach(function(result) { Assert.ok(result.result); });
+}
--- a/mailnews/addrbook/test/unit/test_bug_448165.js
+++ b/mailnews/addrbook/test/unit/test_bug_448165.js
@@ -4,14 +4,13 @@
  */
 function run_test() {
   // get the Personal Address Book
   let pab = MailServices.ab.getDirectory(kPABData.URI);
   Assert.ok(pab instanceof Ci.nsIAbDirectory);
   try {
     pab.deleteCards(null); // this should throw an error
     do_throw("Error, deleteCards should throw an error when null is passed to it");
-  }
-  catch (e) {
+  } catch (e) {
     // make sure the correct error message was thrown
     Assert.equal(e.result, Cr.NS_ERROR_INVALID_POINTER);
   }
 }
--- a/mailnews/addrbook/test/unit/test_cardForEmail.js
+++ b/mailnews/addrbook/test/unit/test_cardForEmail.js
@@ -75,20 +75,20 @@ function run_test() {
   card = AB.getCardFromProperty("JobTitle", "jobtitle1", false);
   check_correct_card(card);
 
   var cards = AB.getCardsFromProperty("LastName", "DOE", true);
   Assert.ok(!cards.hasMoreElements());
 
   cards = AB.getCardsFromProperty("LastName", "Doe", true);
   var i = 0;
-  var data = [ 'John', 'Jane' ];
+  var data = [ "John", "Jane" ];
 
   while (cards.hasMoreElements()) {
     i++;
     card = cards.getNext().QueryInterface(Ci.nsIAbCard);
-    Assert.equal(card.lastName, 'Doe');
+    Assert.equal(card.lastName, "Doe");
     var index = data.indexOf(card.firstName);
     Assert.notEqual(index, -1);
     delete data[index];
   }
   Assert.equal(i, 2);
-};
+}
--- a/mailnews/addrbook/test/unit/test_collection.js
+++ b/mailnews/addrbook/test/unit/test_collection.js
@@ -182,54 +182,52 @@ var modifyEmailChecks =
       screenName: "" },
    ];
 
 var collectChecker = {
   addressCollect: null,
   AB: null,
   part: 0,
 
-  checkAddress : function (aDetails) {
+  checkAddress(aDetails) {
     try {
       this.addressCollect.collectAddress(aDetails.emailHeader, true,
                                          aDetails.mailFormat);
 
       this.checkCardResult(aDetails, false);
-    }
-    catch (e) {
+    } catch (e) {
       throw "FAILED in checkAddress emailHeader: " + aDetails.emailHeader +
       " part: " + this.part + " : " + e;
     }
     ++this.part;
   },
 
-  checkAll : function (aDetailsArray) {
+  checkAll(aDetailsArray) {
     try {
       // Formulate the string to add.
       var emailHeader = "";
       var i;
 
       for (i = 0; i < aDetailsArray.length - 1; ++i)
         emailHeader += aDetailsArray[i].emailHeader + ", ";
 
       emailHeader += aDetailsArray[aDetailsArray.length - 1].emailHeader;
 
       // Now add it. In this case we just set the Mail format Type to unknown.
       this.addressCollect.collectAddress(emailHeader, true,
                                          nsIAbPMF.unknown);
 
       for (i = 0; i < aDetailsArray.length; ++i)
         this.checkCardResult(aDetailsArray[i], true);
-    }
-    catch (e) {
+    } catch (e) {
       throw "FAILED in checkAll item: " + i + " : " + e;
     }
   },
 
-  checkCardResult : function (aDetails, overrideMailFormat) {
+  checkCardResult(aDetails, overrideMailFormat) {
     try {
       var card = this.AB.cardForEmailAddress(aDetails.primaryEmail);
 
       Assert.ok(card != null);
 
       if ("secondEmail" in aDetails)
         Assert.equal(card.getProperty("SecondEmail", "BAD"), aDetails.secondEmail);
 
@@ -239,25 +237,23 @@ var collectChecker = {
         Assert.equal(card.getProperty("PreferMailFormat", "BAD"), aDetails.mailFormatOut);
       else
         Assert.equal(card.getProperty("PreferMailFormat", "BAD"), aDetails.mailFormat);
 
       Assert.equal(card.displayName, aDetails.displayName);
       Assert.equal(card.firstName, aDetails.firstName);
       Assert.equal(card.lastName, aDetails.lastName);
       Assert.equal(card.getProperty("_AimScreenName", ""), aDetails.screenName);
-    }
-    catch (e) {
+    } catch (e) {
       throw "FAILED in checkCardResult emailHeader: " + aDetails.emailHeader + " : " + e;
     }
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   // Test - Get the address collecter
 
   // XXX Getting all directories ensures we create all ABs because the
   // address collecter can't currently create ABs itself (bug 314448).
   MailServices.ab.directories;
 
   // Get the actual AB for the collector so we can check cards have been
   // added.
@@ -359,24 +355,24 @@ function run_test()
                                                      true,
                                                      nsIAbPMF.unknown,
                                                      true);
 
   childCards = collectChecker.AB.childCards;
   var foundCards = [];
 
   while (childCards.hasMoreElements()) {
-    var card = childCards.getNext();
+    card = childCards.getNext();
     if (card instanceof Ci.nsIAbCard &&
         card.primaryEmail == kSingleAddress)
       foundCards.push(card);
   }
 
   Assert.equal(foundCards.length, 2);
 
   if (foundCards[0].displayName != kSingleDisplayName &&
       foundCards[1].displayName != kSingleDisplayName)
     do_throw("Error, collectSingleCard didn't create a new card");
 
   if (foundCards[0].displayName != "" &&
       foundCards[1].displayName != "")
     do_throw("Error, collectSingleCard created ok, but other card does not exist");
-};
+}
--- a/mailnews/addrbook/test/unit/test_collection_2.js
+++ b/mailnews/addrbook/test/unit/test_collection_2.js
@@ -3,18 +3,17 @@
  * Test suite for the Address Collector Service part 2.
  *
  * This test checks that we don't collect addresses when they already exist
  * in other address books.
  */
 
 var nsIAbPMF = Ci.nsIAbPreferMailFormat;
 
-function run_test()
-{
+function run_test() {
   // Test - Get the address collecter
 
   // Get the actual collecter
   var addressCollect =
     Cc["@mozilla.org/addressbook/services/addressCollector;1"]
       .getService(Ci.nsIAbAddressCollector);
 
   // Set the new pref afterwards to ensure we change correctly
@@ -43,9 +42,9 @@ function run_test()
 
   Assert.equal(card.displayName, "Other Book");
   Assert.equal(card.primaryEmail, "other@book.invalid");
 
   // Check the CAB has no cards.
   let CAB = MailServices.ab.getDirectory(kCABData.URI);
 
   Assert.ok(!CAB.childCards.hasMoreElements());
-};
+}
--- a/mailnews/addrbook/test/unit/test_db_enumerator.js
+++ b/mailnews/addrbook/test/unit/test_db_enumerator.js
@@ -2,18 +2,17 @@
  * This test verifies that we don't crash if we have an enumerator on an
  * addr database and delete the underlying directory, which forces the ab
  * closed.
  */
 var ab_prefix       = "test-537815-";
 var card_properties = { FirstName: "01-first-3", LastName: "02-last", PrimaryEmail: "08-email-1@zindus.invalid" };
 var max_addressbooks = 10;
 
-function bug_537815_fixture_setup()
-{
+function bug_537815_fixture_setup() {
   let i, key;
 
   for (i = 1; i <= max_addressbooks; i++) {
     let ab_name = ab_prefix + i;
     MailServices.ab.newAddressBook(ab_name, "", 2);
     dump("created: " + ab_name + "\n");
 
     for (var j = 1; j < 2; j++) {
@@ -36,63 +35,58 @@ function bug_537815_fixture_setup()
           }
           dump("populated: " + elem.dirName + "\n");
         }
       }
     }
   }
 }
 
-function bug_537815_test()
-{
+function bug_537815_test() {
   let enm_dirs = MailServices.ab.directories;
-  let i, key;
 
   while (enm_dirs.hasMoreElements()) {
     let elem = enm_dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
     let uri  = elem.URI;
     let dir  = MailServices.ab.getDirectory(uri);
 
     if (elem.dirName.startsWith(ab_prefix)) {
       let enm_cards = dir.childCards;
 
       while (enm_cards.hasMoreElements()) {
         let item = enm_cards.getNext();
         let abCard = item.QueryInterface(Ci.nsIAbCard);
 
-        for (i in card_properties) {
-          let value = abCard.getProperty(key, null);
+        for (let key in card_properties) {
+          abCard.getProperty(key, null);
         }
       }
       dump("visited all cards in: " + elem.dirName + "\n");
     }
   }
 }
 
-function test_bug_537815()
-{
+function test_bug_537815() {
   bug_537815_fixture_setup();
   bug_537815_test();
   bug_537815_fixture_tear_down();
 }
 
-function bug_537815_fixture_tear_down()
-{
+function bug_537815_fixture_tear_down() {
   let enm_dirs = MailServices.ab.directories;
   let a_uri = {};
 
   while (enm_dirs.hasMoreElements()) {
     let elem = enm_dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
 
     if (elem.dirName.startsWith(ab_prefix)) {
       a_uri[elem.URI] = true;
       dump("to be deleted: " + elem.dirName + "\n");
     }
   }
 
   for (let uri in a_uri)
     MailServices.ab.deleteAddressBook(uri);
 }
 
-function run_test()
-{
+function run_test() {
   test_bug_537815();
 }
--- a/mailnews/addrbook/test/unit/test_ldap1.js
+++ b/mailnews/addrbook/test/unit/test_ldap1.js
@@ -30,18 +30,17 @@ function run_test() {
 
   Assert.equal(abDir.authDn, "test\u00D0");
 
   // Test - searchDuringLocalAutocomplete
 
   // Set up an account and identity in the account manager
   let identity = MailServices.accounts.createIdentity();
 
-  const localAcTests =
-    [
+  const localAcTests = [
      // Online checks
      { useDir: false, dirSer: "",
        idOver: false, idSer: "", idKey: "",
        offline: false, result: false },
      { useDir: true, dirSer: abDir.dirPrefId,
        idOver: false, idSer: "", idKey: "",
        offline: false, result: false },
      // Offline checks with and without global prefs set, no identity key
@@ -78,24 +77,24 @@ function run_test() {
        idOver: false, idSer: abDir.dirPrefId, idKey: identity.key,
        offline: true, result: false },
      // Offline checks, global prefs and identity ones
      { useDir: true, dirSer: kPABData.dirPrefID,
        idOver: true, idSer: abDir.dirPrefId, idKey: identity.key,
        offline: true, result: true },
      { useDir: true, dirSer: abDir.dirPrefId,
        idOver: true, idSer: kPABData.dirPrefID, idKey: identity.key,
-       offline: true, result: false }
-     ];
+       offline: true, result: false },
+  ];
 
   function checkAc(element, index, array) {
     dump("Testing index " + index + "\n");
     Services.prefs.setBoolPref("ldap_2.autoComplete.useDirectory", element.useDir);
     Services.prefs.setCharPref("ldap_2.autoComplete.directoryServer", element.dirSer);
     identity.overrideGlobalPref = element.idOver;
     identity.directoryServer = element.idSer;
     Services.io.offline = element.offline;
 
     Assert.equal(abDir.useForAutocomplete(element.idKey), element.result);
   }
 
   localAcTests.forEach(checkAc);
-};
+}
--- a/mailnews/addrbook/test/unit/test_ldap2.js
+++ b/mailnews/addrbook/test/unit/test_ldap2.js
@@ -30,9 +30,9 @@ function run_test() {
   Assert.equal(abDir.lDAPURL.spec, kLDAPTestSpec);
   Assert.ok(abDir.readOnly);
 
   // XXX I'd really like a better check than this, to check that searching
   // works correctly. However we haven't got the support for that at the moment
   // and this at least ensures that we get a consistent ascii based preference
   // for the directory.
   Assert.equal(abDir.dirPrefId, "ldap_2.servers._nonascii");
-};
+}
--- a/mailnews/addrbook/test/unit/test_ldapOffline.js
+++ b/mailnews/addrbook/test/unit/test_ldapOffline.js
@@ -36,18 +36,17 @@ function run_test() {
   // Now try and get the card that has been replicated for offline use.
   let childCards = abDir.childCards;
   let count = 0;
 
   // Make sure we clear any memory that is now loose, so that the crash would
   // be triggered.
   gc();
 
-  while (childCards.hasMoreElements())
-  {
+  while (childCards.hasMoreElements()) {
     // Make sure everything is an nsIAbCard.
     childCards.getNext().QueryInterface(Ci.nsIAbCard);
 
     ++count;
   }
 
   Assert.equal(count, 4);
 }
--- a/mailnews/addrbook/test/unit/test_mailList1.js
+++ b/mailnews/addrbook/test/unit/test_mailList1.js
@@ -12,26 +12,26 @@ function checkLists(childNodes, number) 
 
   for (var i = 0; i < number; ++i)
     mailListArray[i] = null;
 
   // See comment above for matching requirements
   while (childNodes.hasMoreElements()) {
     var list = childNodes.getNext();
     if (list instanceof Ci.nsIAbDirectory &&
-        list.isMailList && list.dirName.startsWith('TestList')) {
+        list.isMailList && list.dirName.startsWith("TestList")) {
       var index = list.dirName.substr(8, list.dirName.length - 8);
       Assert.equal(mailListArray[index - 1], null);
       Assert.equal(list.URI, kPABData.URI + "/MailList" + index);
 
       mailListArray[index - 1] = list;
     }
   }
 
-  mailListArray.forEach(function (value) { Assert.notEqual(value, null); });
+  mailListArray.forEach(function(value) { Assert.notEqual(value, null); });
 }
 
 function run_test() {
   // Create a new card
   // Test setup - copy the data file into place
   var testAB = do_get_file("../../../data/abLists1.mab");
 
   // Copy the file to the profile directory for a PAB
--- a/mailnews/addrbook/test/unit/test_notifications.js
+++ b/mailnews/addrbook/test/unit/test_notifications.js
@@ -6,33 +6,31 @@
  * XXX Still to do:
  * - Editing a mailing list properties (name/nickname/notes)
  * - Adding, editing and deleting items in mailing lists
  */
 
 var abListener = {
   result: [],
   maxResults: 1,
-  onItemAdded: function (parentItem, item) {
+  onItemAdded(parentItem, item) {
     Assert.ok(this.result.length < this.maxResults);
     this.result.push(["onItemAdded", parentItem, item]);
   },
-  onItemRemoved: function (parentItem, item) {
+  onItemRemoved(parentItem, item) {
     Assert.ok(this.result.length < this.maxResults);
     this.result.push(["onItemRemoved", parentItem, item]);
   },
-  onItemPropertyChanged: function (item, property, oldValue, newValue) {
+  onItemPropertyChanged(item, property, oldValue, newValue) {
     Assert.ok(this.result.length < this.maxResults);
     this.result.push(["onItemPropertyChanged", item, property, oldValue, newValue]);
-  }
+  },
 };
 
 function run_test() {
-  var i;
-
   // XXX Getting all directories ensures we create all ABs because the
   // address collecter can't currently create ABs itself (bug 314448).
   MailServices.ab.directories;
 
   // Add a listener
   MailServices.ab.addAddressBookListener(abListener, Ci.nsIAbListener.all);
 
   // Get the directory
@@ -135,18 +133,18 @@ function run_test() {
 
   // Now verify the card and the directory
   card = abListener.result[0][2].QueryInterface(Ci.nsIAbCard);
   Assert.ok(card.isMailList);
   Assert.equal(card.displayName, "TestList");
   Assert.equal(card.getProperty("Notes", "BAD"), "testdescription");
   Assert.equal(card.getProperty("NickName", "BAD"), "test");
 
-  var book = abListener.result[1][2].QueryInterface(Ci.nsIAbDirectory);
+  book = abListener.result[1][2].QueryInterface(Ci.nsIAbDirectory);
   Assert.ok(book.isMailList);
   Assert.equal(book.dirName, "TestList");
   Assert.equal(book.listNickName, "test");
   Assert.equal(book.description, "testdescription");
 
   // Remove listener
 
   MailServices.ab.removeAddressBookListener(abListener);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteMyDomain.js
@@ -6,20 +6,20 @@
 var ACR = Ci.nsIAutoCompleteResult;
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 function run_test() {
   // Test - Create a new search component
 
   var acs = Cc["@mozilla.org/autocomplete/search;1?name=mydomain"]
     .getService(Ci.nsIAutoCompleteSearch);
 
@@ -114,9 +114,9 @@ function run_test() {
   Assert.equal(obs._result.errorDescription, null);
   Assert.equal(obs._result.matchCount, 1);
 
   Assert.equal(obs._result.getValueAt(0), "test1@foo.invalid");
   Assert.equal(obs._result.getLabelAt(0), "test1@foo.invalid");
   Assert.equal(obs._result.getCommentAt(0), null);
   Assert.equal(obs._result.getStyleAt(0), "default-match");
   Assert.equal(obs._result.getImageAt(0), null);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch1.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch1.js
@@ -18,17 +18,17 @@ var results = [ { email: "d <ema@foo.inv
                   { email: "disp <e@foo.invalid>", dirName: kPABData.dirName }, // 3
                   { email: "displ <em@foo.invalid>", dirName: kPABData.dirName }, // 4
                   { email: "DisplayName1 <PrimaryEmail1@test.invalid>", // 5
                     dirName: kCABData.dirName },
                   { email: "t <list>", dirName: kPABData.dirName }, // 6
                   { email: "te <lis>", dirName: kPABData.dirName }, // 7
                   { email: "tes <li>", dirName: kPABData.dirName }, // 8
                    // this contact has a nickname of "abcdef"
-                  { email: "test <l>", dirName: kPABData.dirName } // 9
+                  { email: "test <l>", dirName: kPABData.dirName }, // 9
                 ];
 var firstNames = [ { search: "f",      expected: [0, 1, 2, 3, 4, 5, 9] },
                      { search: "fi",     expected: [0, 1, 3, 4, 5] },
                      { search: "fir",    expected: [0, 1, 4, 5] },
                      { search: "firs",   expected: [0, 1, 5] },
                      { search: "first",  expected: [1, 5] },
                      { search: "firstn", expected: [5] } ];
 
@@ -62,133 +62,131 @@ var emails = [ { search: "e",     expect
 // "l" case tested above
 var lists = [ { search: "li", expected: [6, 7, 8, 0, 1, 2, 3, 4, 5] },
                 { search: "lis", expected: [6, 7] },
                 { search: "list", expected: [6] },
                 { search: "t", expected: [6, 7, 8, 9, 0, 1, 4, 5] },
                 { search: "te", expected: [7, 8, 9, 5] },
                 { search: "tes", expected: [8, 9, 5] },
                 { search: "test", expected: [9, 5] },
-                { search: "abcdef", expected: [9] } // Bug 441586
+                { search: "abcdef", expected: [9] }, // Bug 441586
               ];
 
 var bothNames = [ { search: "f l",            expected: [0, 1, 2, 3, 4, 5, 9] },
                     { search: "l f",            expected: [0, 1, 2, 3, 4, 5, 9] },
                     { search: "firstn lastna",  expected: [5] },
                     { search: "lastna firstna", expected: [5] } ];
 
 var inputs = [ firstNames, lastNames, displayNames, nickNames, emails,
                  lists, bothNames ];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 var PAB_CARD_DATA = [
   {
     "FirstName": "firs",
     "LastName": "lastn",
     "DisplayName": "d",
     "NickName": "ni",
     "PrimaryEmail": "ema@foo.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
+    "PopularityIndex": 0,
   },
   {
     "FirstName": "first",
     "LastName": "l",
     "DisplayName": "di",
     "NickName": "nic",
     "PrimaryEmail": "emai@foo.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
+    "PopularityIndex": 0,
   },
   {
     "FirstName": "f",
     "LastName": "la",
     "DisplayName": "dis",
     "NickName": "nick",
     "PrimaryEmail": "email@foo.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
+    "PopularityIndex": 0,
   },
   {
     "FirstName": "fi",
     "LastName": "las",
     "DisplayName": "disp",
     "NickName": "nickn",
     "PrimaryEmail": "e@foo.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
+    "PopularityIndex": 0,
   },
   {
     "FirstName": "fir",
     "LastName": "last",
     "DisplayName": "displ",
     "NickName": "n",
     "PrimaryEmail": "em@foo.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
-  }
+    "PopularityIndex": 0,
+  },
 ];
 
 var PAB_LIST_DATA =  [
   {
-    "dirName" : "t",
+    "dirName": "t",
     "listNickName": null,
-    "description": "list"
+    "description": "list",
   },
   {
-    "dirName" : "te",
+    "dirName": "te",
     "listNickName": null,
-    "description": "lis"
+    "description": "lis",
   },
   {
-    "dirName" : "tes",
+    "dirName": "tes",
     "listNickName": null,
-    "description": "li"
+    "description": "li",
   },
   {
-    "dirName" : "test",
+    "dirName": "test",
     "listNickName": "abcdef",
-    "description": "l"
-  }
+    "description": "l",
+  },
 ];
 
 var CAB_CARD_DATA = [
   {
     "FirstName": "FirstName1",
     "LastName": "LastName1",
     "DisplayName": "DisplayName1",
     "NickName": "NickName1",
     "PrimaryEmail": "PrimaryEmail1@test.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
+    "PopularityIndex": 0,
   },
   {
     "FirstName": "Empty",
     "LastName": "Email",
     "DisplayName": "Empty Email",
     "PreferDisplayName": true,
-    "PopularityIndex": 0
-  }
+    "PopularityIndex": 0,
+  },
 ];
 
 var CAB_LIST_DATA = [];
 
-var ABMDB_PREFIX = "moz-abmdbdirectory://";
-
 function setupAddressBookData(aDirURI, aCardData, aMailListData) {
   let ab = MailServices.ab.getDirectory(aDirURI);
 
   // Getting all directories ensures we create all ABs because mailing
   // lists need help initialising themselves
   MailServices.ab.directories;
 
   let childCards0 = ab.childCards;
@@ -213,17 +211,17 @@ function setupAddressBookData(aDirURI, a
     for (var prop in ld) {
       list[prop] = ld[prop];
     }
     ab.addMailList(list);
   });
 
   let childCards = ab.childCards;
   while (childCards.hasMoreElements()) {
-    let c = childCards.getNext().QueryInterface(Ci.nsIAbCard);
+    childCards.getNext().QueryInterface(Ci.nsIAbCard);
   }
 }
 
 function run_test() {
   // Set up addresses for in the personal address book.
   setupAddressBookData(kPABData.URI, PAB_CARD_DATA, PAB_LIST_DATA);
   // ... and collected addresses address book.
   setupAddressBookData(kCABData.URI, CAB_CARD_DATA, CAB_LIST_DATA);
@@ -349,33 +347,33 @@ function run_test() {
   Assert.equal(obs._result.getImageAt(0), "");
 
   // Now check multiple matches
   function checkInputItem(element, index, array) {
     let prevRes = obs._result;
     print("Search #" + index + ": search=" + element.search);
     acs.startSearch(element.search, param, prevRes, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
 
-    for (var i = 0; i < element.expected.length; i++) {
+    for (let i = 0; i < element.expected.length; i++) {
       print("... expected " + i + " (result " + element.expected[i] + "): " +
             results[element.expected[i]].email);
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, element.expected.length);
     Assert.equal(obs._result.defaultIndex, 0);
 
-    for (var i = 0; i < element.expected.length; ++i) {
+    for (let i = 0; i < element.expected.length; ++i) {
       Assert.equal(obs._result.getValueAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getLabelAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getCommentAt(i), results[element.expected[i]].dirName);
       Assert.equal(obs._result.getStyleAt(i), "local-abook");
       Assert.equal(obs._result.getImageAt(i), "");
     }
   }
   function checkInputSet(element, index, array) {
@@ -420,9 +418,9 @@ function run_test() {
   const popularitySearch = [ { search: "d",      expected: [1, 4, 2, 3, 0, 5, 9] },
                              { search: "di",     expected: [1, 4, 2, 3, 5] },
                              { search: "dis",    expected: [4, 2, 3, 5] },
                              { search: "disp",   expected: [4, 3, 5] },
                              { search: "displ",  expected: [4, 5] },
                              { search: "displa", expected: [5] } ];
 
   popularitySearch.forEach(checkInputItem);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch2.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch2.js
@@ -3,17 +3,19 @@
  * Second Test suite for nsAbAutoCompleteSearch - test follow-on lookup after
  * a previous search.
  *
  * We run this test without address books, constructing manually ourselves,
  * so that we can ensure that we're not getting the data out of the address
  * books.
  */
 
-ChromeUtils.import("resource:///modules/ABQueryUtils.jsm");
+var {
+  getModelQuery,
+} = ChromeUtils.import("resource:///modules/ABQueryUtils.jsm", null);
 
 // taken from nsAbAutoCompleteSearch.js
 var ACR = Ci.nsIAutoCompleteResult;
 var nsIAbAutoCompleteResult = Ci.nsIAbAutoCompleteResult;
 
 function nsAbAutoCompleteResult(aSearchString) {
   // Can't create this in the prototype as we'd get the same array for
   // all instances
@@ -52,17 +54,17 @@ nsAbAutoCompleteResult.prototype = {
   getStyleAt: function getStyleAt(aIndex) {
     return "local-abook";
   },
 
   getImageAt: function getImageAt(aIndex) {
     return "";
   },
 
-  getFinalCompleteValueAt: function(aIndex) {
+  getFinalCompleteValueAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
   removeValueAt: function removeValueAt(aRowIndex, aRemoveFromDB) {
   },
 
   // nsIAbAutoCompleteResult
 
@@ -72,85 +74,54 @@ nsAbAutoCompleteResult.prototype = {
 
   getEmailToUse: function getEmailToUse(aIndex) {
     // For this test we can just use the primary email here.
     return this._searchResults[aIndex].card.primaryEmail;
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult])
-}
+  QueryInterface: ChromeUtils.generateQI([ACR, nsIAbAutoCompleteResult]),
+};
 
 function createCard(chars, popularity) {
   var card = Cc["@mozilla.org/addressbook/cardproperty;1"]
                .createInstance(Ci.nsIAbCard);
 
   card.firstName = "firstName".slice(0, chars);
   card.lastName = "lastName".slice(0, chars);
   card.displayName = "displayName".slice(0, chars);
   card.primaryEmail = "email".slice(0, chars) + "@foo.invalid";
   card.setProperty("NickName", "nickName".slice(0, chars));
 
   return card;
 }
 
-var lastSearchCards = [ createCard(1, 0), createCard(2, 0), createCard(3, 0) ];
-
 var results = [ { email: "d <e@foo.invalid>", dirName: kPABData.dirName },
                   { email: "di <em@foo.invalid>", dirName: kPABData.dirName },
                   { email: "dis <ema@foo.invalid>", dirName: kPABData.dirName } ];
 
 var firstNames = [ { search: "fi",     expected: [1, 2] },
                      { search: "fir",    expected: [2] } ];
 
 var lastNames = [ { search: "la",     expected: [1, 2] },
                     { search: "las",    expected: [2] } ];
 
-var displayNames = [ { search: "d",      expected: [5, 0, 1, 2, 3, 4] },
-                       { search: "di",     expected: [5, 1, 2, 3, 4] },
-                       { search: "dis",    expected: [5, 2, 3, 4] },
-                       { search: "disp",   expected: [5, 3, 4]},
-                       { search: "displ",  expected: [5, 4]},
-                       { search: "displa", expected: [5]} ];
-
-var nickNames = [ { search: "n",      expected: [5, 0, 1, 2, 3, 4] },
-                    { search: "ni",     expected: [5, 0, 1, 2, 3] },
-                    { search: "nic",    expected: [5, 1, 2, 3] },
-                    { search: "nick",   expected: [5, 2, 3] },
-                    { search: "nickn",  expected: [5, 3] },
-                    { search: "nickna", expected: [5] } ];
-
-var emails = [ { search: "e",     expected: [0, 1, 2, 3, 4] },
-                 { search: "em",    expected: [0, 1, 2, 4] },
-                 { search: "ema",   expected: [0, 1, 2] },
-                 { search: "emai",  expected: [1, 2] },
-                 { search: "email", expected: [2] } ];
-
-// "l" case tested above
-var lists = [ { search: "li", expected: [6, 7, 8] },
-                { search: "lis", expected: [6, 7] },
-                { search: "list", expected: [6] },
-                { search: "t", expected: [6, 7, 8, 9] },
-                { search: "te", expected: [7, 8, 9] },
-                { search: "tes", expected: [8, 9] },
-                { search: "test", expected: [9] } ];
-
-var inputs = [ firstNames, lastNames];//, displayNames, nickNames, emails, lists ];
+var inputs = [firstNames, lastNames];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 function run_test() {
   // Test - Create a new search component
 
   var acs = Cc["@mozilla.org/autocomplete/search;1?name=addrbook"]
     .getService(Ci.nsIAutoCompleteSearch);
 
@@ -161,43 +132,43 @@ function run_test() {
 
   // Make up the last autocomplete result
   var lastResult = new nsAbAutoCompleteResult();
 
   lastResult.searchString = "";
   lastResult.searchResult = ACR.RESULT_SUCCESS;
   lastResult.defaultIndex = 0;
   lastResult.errorDescription = null;
-  for (var i = 0; i < results.length; ++i) {
+  for (let i = 0; i < results.length; ++i) {
     lastResult._searchResults.push({
       value: results[i].email,
       comment: results[i].dirName,
-      card: createCard(i + 1, 0)
+      card: createCard(i + 1, 0),
     });
   }
 
 
   // Test - Matches
 
   // Now check multiple matches
   function checkInputItem(element, index, array) {
     acs.startSearch(element.search, JSON.stringify({ type: "addr_to", idKey: "" }), lastResult, obs);
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, element.expected.length);
 
-    for (var i = 0; i < element.expected.length; ++i) {
+    for (let i = 0; i < element.expected.length; ++i) {
       Assert.equal(obs._result.getValueAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getLabelAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getCommentAt(i), results[element.expected[i]].dirName);
       Assert.equal(obs._result.getStyleAt(i), "local-abook");
       Assert.equal(obs._result.getImageAt(i), "");
     }
   }
   function checkInputSet(element, index, array) {
     element.forEach(checkInputItem);
   }
 
   inputs.forEach(checkInputSet);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch3.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch3.js
@@ -21,40 +21,39 @@ var cards = [
   { email: "foo2@foo.invalid", displayName: "di",
     popularityIndex: 3, firstName: "first2", value: "di <foo2@foo.invalid>" },
   // this just tests we can search for the special chars '(' and ')', bug 749097
   { email: "bracket@not.invalid", secondEmail: "h@not.invalid", firstName: "Mr.",
     displayName: "Mr. (Bracket)", value: "Mr. (Bracket) <bracket@not.invalid>",
     popularityIndex: 2 },
   { email: "mr@(bracket).not.invalid", secondEmail: "bracket@not.invalid",  firstName: "Mr.",
     displayName: "Mr. Bracket", value: "Mr. Bracket <mr@(bracket).not.invalid>",
-    popularityIndex: 1 }
+    popularityIndex: 1 },
 ];
 
 var duplicates = [
   { search: "test", expected: [1, 2] },
   { search: "first", expected: [6, 5, 3] },
-  { search: "(bracket)", expected: [7, 8] }
+  { search: "(bracket)", expected: [7, 8] },
 ];
 
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   // We set up the cards for this test manually as it is easier to set the
   // popularity index and we don't need many.
 
   // Ensure all the directories are initialised.
   MailServices.ab.directories;
 
   let ab = MailServices.ab.getDirectory(kPABData.URI);
 
@@ -78,32 +77,32 @@ function run_test()
     .getService(Ci.nsIAutoCompleteSearch);
 
   var obs = new acObserver();
 
   function checkInputItem(element, index, array) {
     print("Search #" + index + ": search=" + element.search);
     acs.startSearch(element.search, JSON.stringify({ type: "addr_to"  }), null, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
 
-    for (var i = 0; i < element.expected.length; i++) {
+    for (let i = 0; i < element.expected.length; i++) {
       print("... expected " + i + " (card " + element.expected[i] + "): " +
             cards[element.expected[i]].value);
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, element.expected.length);
 
-    for (var i = 0; i < element.expected.length; ++i) {
+    for (let i = 0; i < element.expected.length; ++i) {
       Assert.equal(obs._result.getValueAt(i), cards[element.expected[i]].value);
       Assert.equal(obs._result.getLabelAt(i), cards[element.expected[i]].value);
       Assert.equal(obs._result.getCommentAt(i), "");
       Assert.equal(obs._result.getStyleAt(i), "local-abook");
       Assert.equal(obs._result.getImageAt(i), "");
       obs._result.QueryInterface(Ci.nsIAbAutoCompleteResult);
       Assert.equal(obs._result.getCardAt(i).firstName,
                    cards[element.expected[i]].firstName);
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch4.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch4.js
@@ -29,17 +29,17 @@ var cards = [
     displayName: "2testsort" },
   { email: "d@test.invalid", secondEmail: "e@test.invalid",
     displayName: "2testsort" },
   { email: "g@test.invalid", secondEmail: "f@test.invalid",
     displayName: "3testsort", popularityIndex: 3 },
   { email: "j@test.invalid", secondEmail: "h@test.invalid",
     displayName: "3testsort", popularityIndex: 5 },
   // Add a contact that matches, but has no email. Should not show up.
-  { displayName: "primaryX" }
+  { displayName: "primaryX" },
 ];
 
 // These are for the initial search
 var searches = [ "primary", "second", "firstName", "thename", "sortbasic",
                    "testsort", "2testsort", "3testsort" ];
 
 var expectedResults = [ [ "primary@test.invalid",
                             "second@test.invalid"], // searching for primary/second returns
@@ -86,24 +86,23 @@ var reductionExpectedResults = [ [ "bar1
                                    [ "boo2@test.invalid" ] ];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   // We set up the cards for this test manually as it is easier to set the
   // popularity index and we don't need many.
 
   // Ensure all the directories are initialised.
   MailServices.ab.directories;
 
   let ab = MailServices.ab.getDirectory(kPABData.URI);
 
@@ -130,27 +129,27 @@ function run_test()
   var obs = new acObserver();
 
   print("Checking Initial Searches");
 
   function checkSearch(element, index, array) {
     print("Search #" + index + ": search=" + element);
     acs.startSearch(element, JSON.stringify({ type: "addr_to", idKey: "" }), null, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, expectedResults[index].length);
 
-    for (var i = 0; i < expectedResults[index].length; ++i) {
+    for (let i = 0; i < expectedResults[index].length; ++i) {
       Assert.equal(obs._result.getValueAt(i), expectedResults[index][i]);
       Assert.equal(obs._result.getLabelAt(i), expectedResults[index][i]);
       Assert.equal(obs._result.getCommentAt(i), "");
       Assert.equal(obs._result.getStyleAt(i), "local-abook");
       Assert.equal(obs._result.getImageAt(i), "");
       obs._result.QueryInterface(Ci.nsIAbAutoCompleteResult);
     }
   }
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch5.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch5.js
@@ -32,20 +32,20 @@ var lastNames = [ { search: "l",      ex
 var inputs = [ firstNames, lastNames];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 function run_test() {
   // Copy the data files into place
   let testAB = do_get_file("../../../data/tb2hexpopularity.mab");
 
   testAB.copyTo(do_get_profile(), kPABData.fileName);
 
@@ -61,21 +61,21 @@ function run_test() {
 
   // Test - Matches
 
   // Now check multiple matches
   function checkInputItem(element, index, array) {
     print("Search #" + index + ": search=" + element.search);
     acs.startSearch(element.search, JSON.stringify({ type: "addr_to" }), null, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
 
-    for (var i = 0; i < element.expected.length; i++) {
+    for (let i = 0; i < element.expected.length; i++) {
       print("... expected " + i + " (card " + element.expected[i] + "): " +
             results[element.expected[i]].email);
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
@@ -97,9 +97,9 @@ function run_test() {
       }
     }
   }
   function checkInputSet(element, index, array) {
     element.forEach(checkInputItem);
   }
 
   inputs.forEach(checkInputSet);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch6.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch6.js
@@ -3,135 +3,134 @@
  * Tests for for nsAbAutoCompleteSearch scoring.
  */
 
 var ACR = Ci.nsIAutoCompleteResult;
 
 var cards = [
   { // 0
     email: "jd.who@example.com", displayName: "John Doe (:xx)",
-    popularityIndex: 0, firstName: "John", value: "John Doe (:xx) <jd.who@example.com>"
+    popularityIndex: 0, firstName: "John", value: "John Doe (:xx) <jd.who@example.com>",
   },
 
   { // 1
     email: "janey_who@example.com", displayName: "Jane Doe",
-    popularityIndex: 0, value: "Jane Doe <janey_who@example.com>"
+    popularityIndex: 0, value: "Jane Doe <janey_who@example.com>",
   },
 
   { // 2
     email: "pf@example.com", displayName: "Paul \"Shitbreak\" Finch",
-    popularityIndex: 0, value: "Paul \"Shitbreak\" Finch <pf@example.com>"
+    popularityIndex: 0, value: "Paul \"Shitbreak\" Finch <pf@example.com>",
   },
 
   { // 3
     email: "js@example.com", displayName: "Janine (Stifflers Mom)",
-    popularityIndex: 0, value: "Janine (Stifflers Mom) <js@example.com>"
+    popularityIndex: 0, value: "Janine (Stifflers Mom) <js@example.com>",
   },
 
   { // 4
     email: "ex0@example.com", displayName: "Ajden",
-    popularityIndex: 0, value: "Ajden <ex0@example.com>"
+    popularityIndex: 0, value: "Ajden <ex0@example.com>",
   },
 
   { // 5
     email: "5@example.com", displayName: "Foxx",
-    popularityIndex: 0, value: "Foxx <5@example.com>"
+    popularityIndex: 0, value: "Foxx <5@example.com>",
   },
 
   { // 6
     email: "6@example.com", displayName: "thewho",
-    popularityIndex: 0, value: "thewho <6@example.com>"
+    popularityIndex: 0, value: "thewho <6@example.com>",
   },
 
   { // 7
     email: "7@example.com", displayName: "fakeshit",
-    popularityIndex: 0, value: "fakeshit <7@example.com>"
+    popularityIndex: 0, value: "fakeshit <7@example.com>",
   },
 
   { // 8
     email: "8@example.com", displayName: "mastiff",
-    popularityIndex: 0, value: "mastiff <8@example.com>"
+    popularityIndex: 0, value: "mastiff <8@example.com>",
   },
 
   { // 9
     email: "9@example.com", displayName: "anyjohn",
-    popularityIndex: 0, value: "anyjohn <9@example.com>"
+    popularityIndex: 0, value: "anyjohn <9@example.com>",
   },
 
   { // 10
     email: "10@example.com", displayName: "däsh l18n",
-    popularityIndex: 0, value: "däsh l18n <10@example.com>"
+    popularityIndex: 0, value: "däsh l18n <10@example.com>",
   },
 
   { // 11
     email: "11@example.com", displayName: "paul mary",
     popularityIndex: 0, firstName: "paul", lastName: "mary meyer",
-    value: "paul mary <11@example.com>"
+    value: "paul mary <11@example.com>",
   },
 
   { // 12
     email: "12@example.com", displayName: "paul meyer",
     popularityIndex: 0, firstName: "paul", lastName: "mary meyer",
-    value: "paul meyer <12@example.com>"
+    value: "paul meyer <12@example.com>",
   },
 
   { // 13
     email: "13@example.com", displayName: "mr iron man (exp dev)",
     popularityIndex: 0, firstName: "iron", lastName: "man",
-    value: "mr iron man (exp dev) <13@example.com>"
+    value: "mr iron man (exp dev) <13@example.com>",
   },
 
   { // 14
     email: "14@example.com", displayName: "michael",
     popularityIndex: 0, nickName: "short",
-    value: "michael <14@example.com>"
+    value: "michael <14@example.com>",
   },
 
   { // 15
     email: "15@example.com", displayName: "good boy",
     popularityIndex: 0, nickName: "sh",
-    value: "good boy <15@example.com>"
+    value: "good boy <15@example.com>",
   },
 
   { // 16
     email: "16@example.com", displayName: "sherlock holmes",
-    popularityIndex: 0, value: "sherlock holmes <16@example.com>"
-  }
+    popularityIndex: 0, value: "sherlock holmes <16@example.com>",
+  },
 ];
 
 var inputs = [
   { search: "john", expected: [0, 9] },
   { search: "doe", expected: [1, 0] },
   { search: "jd", expected: [0, 4] },
   { search: "who", expected: [1, 0, 6] },
   { search: "xx", expected: [0, 5] },
   { search: "jan", expected: [1, 3] },
   // expecting nickname to score highest.
   { search: "sh", expected: [15, 14, 2, 16, 10, 7] },
-  { search: "st", expected: [3,8] },
+  { search: "st", expected: [3, 8] },
   { search: "paul mary", expected: [11, 12] },
   { search: "\"paul mary\"", expected: [11] },
   { search: "\"iron man\" mr \"exp dev\"", expected: [13] },
-  { search: "short", expected: [14] }
+  { search: "short", expected: [14] },
 ];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   // We set up the cards for this test manually as it is easier to set the
   // popularity index and we don't need many.
 
   // Ensure all the directories are initialised.
   MailServices.ab.directories;
 
   let ab = MailServices.ab.getDirectory(kPABData.URI);
 
@@ -158,31 +157,31 @@ function run_test()
     .getService(Ci.nsIAutoCompleteSearch);
 
   var obs = new acObserver();
 
   function checkInputItem(element, index, array) {
     print("Search #" + index + ": search=" + element.search);
     acs.startSearch(element.search, JSON.stringify({ type: "addr_to"  }), null, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
 
-    for (var i = 0; i < element.expected.length; i++) {
+    for (let i = 0; i < element.expected.length; i++) {
       print("... expected " + i + " (card " + element.expected[i] + "): " +
             cards[element.expected[i]].value);
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, element.expected.length);
 
-    for (var i = 0; i < element.expected.length; ++i) {
+    for (let i = 0; i < element.expected.length; ++i) {
       Assert.equal(obs._result.getValueAt(i), cards[element.expected[i]].value);
       Assert.equal(obs._result.getLabelAt(i), cards[element.expected[i]].value);
     }
   }
 
   inputs.forEach(checkInputItem);
 }
--- a/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch7.js
+++ b/mailnews/addrbook/test/unit/test_nsAbAutoCompleteSearch7.js
@@ -11,71 +11,69 @@ var ACR = Ci.nsIAutoCompleteResult;
 
 // Note the expected arrays are in expected sort order as well.
 
 var results =  [
   { email: "Tomas Doe <tomez.doe@foo.invalid>" }, // 0
   { email: "Tomas Doe <tomez.doe@foo2.invalid>" }, // 1
   { email: "Tomas Doe <tomez.doe@b.example.com>" }, // 2
   { email: "Tomas Doe <tomez.doe@a.example.com>" }, // 3
-  { email: "Tomek Smith <tomek@example.com>" } // 4
-]
+  { email: "Tomek Smith <tomek@example.com>" }, // 4
+];
 
 var inputs = [
   [
     { search: "t",            expected: [2, 3, 0, 1, 4] },
     { search: "tom",          expected: [0, 1, 2, 3, 4] },
-    { search: "tomek",        expected: [4] }
-  ]
+    { search: "tomek",        expected: [4] },
+  ],
 ];
 
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 var PAB_CARD_DATA = [
   {
     "FirstName": "Tomas",
     "LastName": "Doe",
     "DisplayName": "Tomas Doe",
     "NickName": "tom",
     "PrimaryEmail": "tomez.doe@foo.invalid",
     "SecondEmail": "tomez.doe@foo2.invalid",
     "PreferDisplayName": true,
-    "PopularityIndex": 10
+    "PopularityIndex": 10,
   },
   {
     "FirstName": "Tomas",
     "LastName": "Doe",
     "DisplayName": "Tomas Doe",
     "PrimaryEmail": "tomez.doe@b.example.com",
     "SecondEmail": "tomez.doe@a.example.com",
     "PreferDisplayName": true,
-    "PopularityIndex": 200
+    "PopularityIndex": 200,
   },
   {
     "FirstName": "Tomek",
     "LastName": "Smith",
     "DisplayName": "Tomek Smith",
     "PrimaryEmail": "tomek@example.com",
     "PreferDisplayName": true,
-    "PopularityIndex": 3
-  }
+    "PopularityIndex": 3,
+  },
 ];
 
-var ABMDB_PREFIX = "moz-abmdbdirectory://";
-
 function setupAddressBookData(aDirURI, aCardData, aMailListData) {
   let ab = MailServices.ab.getDirectory(aDirURI);
 
   // Getting all directories ensures we create all ABs because mailing
   // lists need help initialising themselves
   MailServices.ab.directories;
 
   let childCards0 = ab.childCards;
@@ -100,62 +98,60 @@ function setupAddressBookData(aDirURI, a
     for (var prop in ld) {
       list[prop] = ld[prop];
     }
     ab.addMailList(list);
   });
 
   let childCards = ab.childCards;
   while (childCards.hasMoreElements()) {
-    let c = childCards.getNext().QueryInterface(Ci.nsIAbCard);
+    childCards.getNext().QueryInterface(Ci.nsIAbCard);
   }
 }
 
 function run_test() {
   // Set up addresses for in the personal address book.
   setupAddressBookData(kPABData.URI, PAB_CARD_DATA, []);
 
   // Test - Create a new search component
 
   var acs = Cc["@mozilla.org/autocomplete/search;1?name=addrbook"]
     .getService(Ci.nsIAutoCompleteSearch);
 
   var obs = new acObserver();
-  let obsNews = new acObserver();
-  let obsFollowup = new acObserver();
 
   let param = JSON.stringify({ type: "addr_to" });
 
   // Now check multiple matches
   function checkInputItem(element, index, array) {
     let prevRes = obs._result;
     print("Search #" + index + ": search=" + element.search);
     acs.startSearch(element.search, param, prevRes, obs);
 
-    for (var i = 0; i < obs._result.matchCount; i++) {
+    for (let i = 0; i < obs._result.matchCount; i++) {
       print("... got " + i + ": " + obs._result.getValueAt(i));
     }
-    for (var i = 0; i < element.expected.length; i++) {
+    for (let i = 0; i < element.expected.length; i++) {
       print("... expected " + i + " (result " + element.expected[i] + "): " +
             results[element.expected[i]].email);
     }
 
     Assert.equal(obs._search, acs);
     Assert.equal(obs._result.searchString, element.search);
     Assert.equal(obs._result.searchResult, ACR.RESULT_SUCCESS);
     Assert.equal(obs._result.errorDescription, null);
     Assert.equal(obs._result.matchCount, element.expected.length);
     Assert.equal(obs._result.defaultIndex, 0);
 
-    for (var i = 0; i < element.expected.length; ++i) {
+    for (let i = 0; i < element.expected.length; ++i) {
       Assert.equal(obs._result.getValueAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getLabelAt(i), results[element.expected[i]].email);
       Assert.equal(obs._result.getCommentAt(i), "");
       Assert.equal(obs._result.getStyleAt(i), "local-abook");
       Assert.equal(obs._result.getImageAt(i), "");
     }
   }
   function checkInputSet(element, index, array) {
     element.forEach(checkInputItem);
   }
 
   inputs.forEach(checkInputSet);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbManager1.js
+++ b/mailnews/addrbook/test/unit/test_nsAbManager1.js
@@ -10,33 +10,33 @@ var gAblAll;
 var gAblSingle = new Array(numListenerOptions);
 
 function abL() {}
 
 abL.prototype = {
  mReceived: 0,
  mAutoRemoveItem: false,
 
-  onItemAdded: function (parentItem, item) {
+  onItemAdded(parentItem, item) {
     this.mReceived |= nsIAbListener.itemAdded;
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
   },
-  onItemRemoved: function (parentItem, item) {
+  onItemRemoved(parentItem, item) {
     this.mReceived |=
       (item == MailServices.ab ? nsIAbListener.directoryRemoved :
                                  nsIAbListener.directoryItemRemoved);
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
   },
-  onItemPropertyChanged: function (item, property, oldValue, newValue) {
+  onItemPropertyChanged(item, property, oldValue, newValue) {
     this.mReceived |= nsIAbListener.itemChanged;
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
-  }
+  },
 };
 
 function NotifyAbManager() {
   MailServices.ab.notifyItemPropertyChanged(null, null, null, null);
   MailServices.ab.notifyDirectoryItemAdded(null, null);
   MailServices.ab.notifyDirectoryItemDeleted(null, null);
   // MailServices.ab just happens to be nsISupports derived and makes it easy for
   // us to distinguish between xxxItemDeleted and xxxDeleted.
@@ -85,19 +85,19 @@ function run_test() {
     Assert.equal(gAblSingle[i].mReceived, 1 << i);
     gAblSingle[i].mReceived = 0;
   }
 
   // Test - Ensure the single listeners have been removed.
 
   NotifyAbManager();
 
-  Assert.equal(gAblAll.mReceived, (1 <<  numListenerOptions) - 1);
+  Assert.equal(gAblAll.mReceived, (1 << numListenerOptions) - 1);
   gAblAll.mReceived = 0;
 
   for (i = 0; i < numListenerOptions; ++i) {
     Assert.equal(gAblSingle[i].mReceived, 0);
   }
 
   // Test - Remove main listener
 
   MailServices.ab.removeAddressBookListener(gAblAll);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbManager2.js
+++ b/mailnews/addrbook/test/unit/test_nsAbManager2.js
@@ -13,34 +13,34 @@ var gAblSingle = new Array(numListenerOp
 
 function abL() {}
 
 abL.prototype = {
  mReceived: 0,
  mDirectory: null,
  mAutoRemoveItem: false,
 
-  onItemAdded: function (parentItem, item) {
+  onItemAdded(parentItem, item) {
     this.mReceived |= nsIAbListener.itemAdded;
     this.mDirectory = item;
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
   },
-  onItemRemoved: function (parentItem, item) {
+  onItemRemoved(parentItem, item) {
     this.mReceived |= nsIAbListener.directoryRemoved;
     this.mDirectory = item;
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
   },
-  onItemPropertyChanged: function (item, property, oldValue, newValue) {
+  onItemPropertyChanged(item, property, oldValue, newValue) {
     this.mReceived |= nsIAbListener.itemChanged;
     this.mDirectory = item;
     if (this.mAutoRemoveItem)
       MailServices.ab.removeAddressBookListener(this);
-  }
+  },
 };
 
 function checkDirs(aDirs, aDirArray) {
   // Don't modify the passed in array.
   var dirArray = aDirArray.concat();
 
   while (aDirs.hasMoreElements()) {
     var dir = aDirs.getNext().QueryInterface(nsIAbDirectory);
@@ -68,19 +68,19 @@ function addDirectory(dirName) {
 
   gAblAll.mReceived = 0;
   gAblAll.mDirectory = null;
 
   for (var i = 0; i < numListenerOptions; ++i) {
     if (1 << i == nsIAbListener.itemAdded) {
       Assert.equal(gAblSingle[i].mReceived, nsIAbListener.itemAdded);
       gAblSingle[i].mReceived = 0;
+    } else {
+      Assert.equal(gAblSingle[i].mReceived, 0);
     }
-    else
-      Assert.equal(gAblSingle[i].mReceived, 0);
   }
 
   return newDirectory;
 }
 
 function removeDirectory(directory) {
   // Remove the directory
   MailServices.ab.deleteAddressBook(directory.URI);
@@ -91,19 +91,19 @@ function removeDirectory(directory) {
 
   gAblAll.mReceived = 0;
   gAblAll.mDirectory = null;
 
   for (var i = 0; i < numListenerOptions; ++i) {
     if (1 << i == nsIAbListener.directoryRemoved) {
       Assert.equal(gAblSingle[i].mReceived, nsIAbListener.directoryRemoved);
       gAblSingle[i].mReceived = 0;
+    } else {
+      Assert.equal(gAblSingle[i].mReceived, 0);
     }
-    else
-      Assert.equal(gAblSingle[i].mReceived, 0);
   }
 }
 
 function run_test() {
   var i;
 
   // Set up listeners
   gAblAll = new abL;
@@ -160,11 +160,11 @@ function run_test() {
 
   // Test - Check new directory list
   checkDirs(MailServices.ab.directories, expectedABs);
 
   // Test - Clear the listeners down
 
   MailServices.ab.removeAddressBookListener(gAblAll);
 
-  for (i = 0; i< numListenerOptions; ++i)
+  for (i = 0; i < numListenerOptions; ++i)
     MailServices.ab.removeAddressBookListener(gAblSingle[i]);
-};
+}
--- a/mailnews/addrbook/test/unit/test_nsAbManager3.js
+++ b/mailnews/addrbook/test/unit/test_nsAbManager3.js
@@ -10,36 +10,36 @@ var gAbListener;
 
 function abListener() {
 }
 
 abListener.prototype = {
   mReceived: 0,
   mDirectory: null,
 
-  onItemAdded: function(aParentItem, aItem) {
+  onItemAdded(aParentItem, aItem) {
     this.mReceived |= Ci.nsIAbListener.itemAdded;
     this.mDirectory = aItem;
   },
 
-  onItemRemoved: function(aParentItem, aItem) {
+  onItemRemoved(aParentItem, aItem) {
     this.mReceived |= Ci.nsIAbListener.directoryRemoved;
     this.mDirectory = aItem;
   },
 
-  onItemPropertyChanged: function(aItem, aProperty, aOldValue, aNewValue) {
+  onItemPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {
     this.mReceived |= Ci.nsIAbListener.itemChanged;
     this.mDirectory = aItem;
   },
 
-  reset: function() {
+  reset() {
     this.mReceived = 0;
     this.mDirectory = null;
-  }
-}
+  },
+};
 
 function addDirectory(dirName) {
   MailServices.ab.newAddressBook(dirName, "", kPABData.dirType);
 
   Assert.equal(gAbListener.mReceived, Ci.nsIAbListener.itemAdded);
 
   let newDirectory = gAbListener.mDirectory.QueryInterface(Ci.nsIAbDirectory);
   Assert.equal(newDirectory.dirName, dirName);
--- a/mailnews/addrbook/test/unit/test_nsIAbCard.js
+++ b/mailnews/addrbook/test/unit/test_nsIAbCard.js
@@ -18,18 +18,17 @@ function run_test() {
 
   // Test - Get the directory
   let AB = MailServices.ab.getDirectory(kPABData.URI);
 
   var childCards = AB.childCards;
   var fullCard = null;
   var tempCard;
 
-  while (childCards.hasMoreElements())
-  {
+  while (childCards.hasMoreElements()) {
     tempCard = childCards.getNext();
 
     // We want the one with the right email...
     if (tempCard instanceof Ci.nsIAbCard &&
         tempCard.primaryEmail == "PrimaryEmail1@test.invalid")
       fullCard = tempCard;
   }
 
--- a/mailnews/addrbook/test/unit/test_uid.js
+++ b/mailnews/addrbook/test/unit/test_uid.js
@@ -92,17 +92,17 @@ add_task(async function newListUID() {
   ok(!!bookCards.find(c => c.UID == list.UID, "New reference to list has the same UID"));
 
   await checkFileForUID(list.UID, book.fileName);
 });
 
 // 3 seems to be the lowest number that works here. I don't know why.
 var count = 3;
 function newAddressBookFile() {
-  let foo = MailServices.ab.newAddressBook(`book${count}`, `moz-abmdbdirectory://abook-${count}.mab`, 2);
+  MailServices.ab.newAddressBook(`book${count}`, `moz-abmdbdirectory://abook-${count}.mab`, 2);
 
   let testAB = do_get_file("data/existing.mab");
   testAB.copyTo(profD, `abook-${count}.mab`);
 
   Services.prefs.setCharPref(`ldap_2.servers.book${count}.filename`, `abook-${count}.mab`);
 
   let book = MailServices.ab.getDirectory(`moz-abmdbdirectory://abook-${count}.mab`);
   equal(2, [...book.childCards].length);
--- a/mailnews/addrbook/test/unit/test_uuid.js
+++ b/mailnews/addrbook/test/unit/test_uuid.js
@@ -4,33 +4,33 @@
 
 /**
  * Checks that the directory follows the contract for UUIDs.
  *
  * If the directory is modifiable, it will be modified, although the net effect
  * will not change the state if the code works properly.
  */
 function check_directory(directory) {
-  var prefId = directory.dirPrefId + '&' + directory.dirName;
+  var prefId = directory.dirPrefId + "&" + directory.dirName;
 
   var testModification = !directory.readOnly;
   dump("Testing " + prefId);
   if (testModification)
     dump(" (with modifications)");
   dump("...\n");
 
   // Question 1: Is the UUID the preference ID?
   Assert.equal(prefId, directory.uuid);
 
   // Now we need to run through the cards, checking that each card meets the
   // requirements.
   var seenIds = [], cards = [];
   var enumerator = directory.childCards;
   while (enumerator.hasMoreElements()) {
-    var card = enumerator.getNext().QueryInterface(Ci.nsIAbCard);
+    let card = enumerator.getNext().QueryInterface(Ci.nsIAbCard);
     cards.push(card);
 
     // Question 2.1: Is the directory ID correct?
     Assert.equal(prefId, card.directoryId);
 
     // Question 2.2: Is the local ID unique and valid?
     Assert.notEqual(card.localId, "");
     Assert.equal(seenIds.indexOf(card.localId), -1);
@@ -42,17 +42,17 @@ function check_directory(directory) {
 
   // Question 3: Do cards returned via searches return UUIDs correctly?
   var uri = directory.URI;
   uri += "?(or(DisplayName,=,a)(DisplayName,!=,a))";
   let search = MailServices.ab.getDirectory(uri);
 
   enumerator = search.childCards;
   while (enumerator.hasMoreElements()) {
-    var card = enumerator.getNext().QueryInterface(Ci.nsIAbCard);
+    let card = enumerator.getNext().QueryInterface(Ci.nsIAbCard);
 
     // Question 3.1: Is the directory ID correct?
     Assert.equal(prefId, card.directoryId);
 
     // Question 3.2: Is the local ID valid?
     Assert.notEqual(card.localId, "");
 
     // Question 3.3: Is the format equal to generateUUID?
@@ -78,17 +78,17 @@ function check_directory(directory) {
 
   // Remove the new card to be stable!
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   array.appendElement(newCard);
   directory.deleteCards(array);
 
   // We need to iterate over the array of cards to avoid any problems if someone
   // makes the childCards enumerator reflect changes to directory...
-  for (var card of cards) {
+  for (let card of cards) {
     // Question 5.1: Does deleting a card properly set the uids?
     var localId = card.localId;
     array.clear();
     array.appendElement(card);
     directory.deleteCards(array);
     Assert.equal(card.directoryId, "");
     Assert.equal(card.localId, localId);