Bug 1478572 - Turn on ESLint in mail/components/newmailaccount. r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Sat, 06 Oct 2018 21:46:50 +1300
changeset 33330 da7cae0efc9d380eae26d9ef2f1b571bf8fcf811
parent 33329 eaaaf728d1d6b430224c999efa5b95b14216040e
child 33331 3a92dfd670302bc8f6a666728fe7e61afba7041e
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersaceman
bugs1478572
Bug 1478572 - Turn on ESLint in mail/components/newmailaccount. r=aceman
.eslintignore
mail/components/newmailaccount/content/accountProvisioner.js
mail/components/newmailaccount/content/accountProvisionerTab.js
mail/components/newmailaccount/content/uriListener.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -46,17 +46,16 @@ mailnews/test/*
 # mailnews/extensions exclusions
 mailnews/extensions/*
 !mailnews/extensions/newsblog
 
 # mail exclusions
 mail/app/**
 mail/base/**
 mail/branding/**
-mail/components/newmailaccount/**
 mail/components/search/**
 mail/config/**
 mail/extensions/**
 mail/installer/**
 mail/locales/**
 mail/test/**
 mail/themes/**
 
--- a/mail/components/newmailaccount/content/accountProvisioner.js
+++ b/mail/components/newmailaccount/content/accountProvisioner.js
@@ -1,31 +1,32 @@
 /* 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/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource:///modules/StringBundle.js");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/gloda/log4moz.js");
+var { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
 
 // Get a configured logger for this component.
 // To debug, set mail.provider.logging.dump (or .console)="All"
 var gLog = Log4Moz.getConfiguredLogger("mail.provider");
 var stringBundle = new StringBundle("chrome://messenger/locale/newmailaccount/accountProvisioner.properties");
 
-var isOSX = (Services.appinfo.OS == 'Darwin');
-
 var RETRY_TIMEOUT = 5000; // 5 seconds
 var CONNECTION_TIMEOUT = 15000; // 15 seconds
 
-function isAccel (event) { return isOSX && event.metaKey || event.ctrlKey; }
+function isAccel(event) {
+  return AppConstants.platform == "macosx" ? event.metaKey : event.ctrlKey;
+}
 
 /**
  * Get the localstorage for this page in a way that works in chrome.
  *
  * Cribbed from
  *   mozilla/dom/tests/mochitest/localstorage/test_localStorageFromChrome.xhtml
  *
  * @param {String} page The page to get the localstorage for.
@@ -42,32 +43,31 @@ function getLocalStorage(page) {
 var MAX_SMALL_ADDRESSES = 2;
 
 var storedData = {};
 
 function splitName(str) {
   let i = str.lastIndexOf(" ");
   if (i >= 1)
     return [str.substring(0, i), str.substring(i + 1)];
-  else
-    return [str, ""];
+  return [str, ""];
 }
 
 /**
  * Replace occurrences of placeholder with the given node
  *
  * @param aTextContainer {Node}  DOM node containing the text child
  * @param aTextNode {Node}       Text node containing the text, child of the aTextContainer
  * @param aPlaceholder {String}  String to look for in aTextNode's textContent
  * @param aReplacement {Node}    DOM node to insert instead of the found replacement
  */
 function insertHTMLReplacement(aTextContainer, aTextNode, aPlaceholder, aReplacement) {
   if (aTextNode.textContent.includes(aPlaceholder)) {
     let placeIndex = aTextNode.textContent.indexOf(aPlaceholder);
-    let restNode = aTextNode.splitText(placeIndex+aPlaceholder.length);
+    let restNode = aTextNode.splitText(placeIndex + aPlaceholder.length);
     aTextContainer.insertBefore(aReplacement, restNode);
     let placeholderNode = aTextNode.splitText(placeIndex);
     placeholderNode.remove();
   }
 }
 
 /**
  * Logic and functionality for the Account Provisioner dialog.  Sets and reacts
@@ -289,17 +289,17 @@ var EmailAccountProvisioner = {
     // If we have a name stored in local storage from an earlier session,
     // populate the search field with it.
     let name = EmailAccountProvisioner.storage.getItem("name") ||
                nameElement.value;
     if (!name) {
       try {
         let userInfo = Cc["@mozilla.org/userinfo;1"].getService(Ci.nsIUserInfo);
         name = userInfo.fullname;
-      } catch(e) {
+      } catch (e) {
         // nsIUserInfo may not be implemented on all platforms, and name might
         // not be available even if it is.
       }
     }
     nameElement.value = name;
     EmailAccountProvisioner.saveName();
 
     // Pretend like we've typed something into the search input to set the
@@ -343,17 +343,17 @@ var EmailAccountProvisioner = {
       let resultsGroup = event.target;
       while (resultsGroup) {
         if (resultsGroup.classList.contains("resultsGroup")) {
           break;
         }
         resultsGroup = resultsGroup.parentElement;
       }
       if (!resultsGroup)
-        throw("Unexpected error finding resultsGroup.");
+        throw "Unexpected error finding resultsGroup.";
 
       // Return if we're already expanded
       if (resultsGroup.classList.contains("expanded"))
         return;
 
       for (let child of resultsGroup.parentElement.children) {
         if (child != resultsGroup) {
           child.classList.remove("expanded");
@@ -467,39 +467,39 @@ var EmailAccountProvisioner = {
       return;
     }
 
     EmailAccountProvisioner.searchEnabled(false);
     EmailAccountProvisioner.spinning(true);
     let [firstname, lastname] = splitName(name);
     let selectedProviderList =
       [...document.querySelectorAll(".provider input:checked")];
-    let providerList = selectedProviderList.map(node => node.value).join(',');
+    let providerList = selectedProviderList.map(node => node.value).join(",");
 
     let request = new XMLHttpRequest();
     request.open("GET", EmailAccountProvisioner.suggestFromName +
       "?first_name=" + encodeURIComponent(firstname) +
       "&last_name=" + encodeURIComponent(lastname) +
       "&providers=" + encodeURIComponent(providerList) +
       "&version=2");
-    request.onload = function () {
+    request.onload = function() {
       let data;
       try {
         data = JSON.parse(request.responseText);
-      } catch(e) {};
+      } catch (e) {}
       EmailAccountProvisioner.onSearchResults(data);
     };
     request.onerror = () => {
       gLog.info("Error response of XMLHttpRequest fetching address data.");
       EmailAccountProvisioner.showSearchError();
     };
     request.ontimeout = () => {
       gLog.info("Timeout of XMLHttpRequest fetching address data.");
       EmailAccountProvisioner.showSearchError();
-    }
+    };
     request.onloadend = function() {
       // Also called if we timeout.
       let firstAndLastName = document.getElementById("FirstAndLastName");
       firstAndLastName.textContent = (firstname + " " + lastname).trim();
       EmailAccountProvisioner.searchEnabled(true);
       EmailAccountProvisioner.spinning(false);
     };
     request.timeout = CONNECTION_TIMEOUT;
@@ -509,44 +509,44 @@ var EmailAccountProvisioner = {
   /**
    * Event handler for when the user selects an address by clicking on
    * the price button for that address.  This function spawns the content
    * tab for the address order form, and then closes the Account Provisioner
    * window.
    */
   onAddressSelected: function EAP_onAddressSelected(aTarget) {
     gLog.info("An address was selected by the user.");
-    let provider = EmailAccountProvisioner.providers[aTarget.dataset["provider"]];
+    let provider = EmailAccountProvisioner.providers[aTarget.dataset.provider];
 
     // Replace the variables in the url.
     let url = provider.api;
     let [firstName, lastName] = splitName(document.getElementById("name").value.trim());
     let email = aTarget.getAttribute("address");
     url = url.replace("{firstname}", firstName);
     url = url.replace("{lastname}", lastName);
     url = url.replace("{email}", email);
 
     // And add the extra data.
     let data = storedData[provider.id];
     delete data.provider;
     for (let name in data) {
-      url += (url.indexOf("?") == -1 ? "?" : "&") +
+      url += (!url.includes("?") ? "?" : "&") +
               name + "=" + encodeURIComponent(data[name]);
     }
 
     gLog.info("Opening up a contentTab with the order form.");
     // Then open a content tab.
     let mail3Pane = Services.wm.getMostRecentWindow("mail:3pane");
     let tabmail = mail3Pane.document.getElementById("tabmail");
     tabmail.openTab("accountProvisionerTab", {
       contentPage: url,
       realName: (firstName + " " + lastName).trim(),
-      email: email,
+      email,
       searchEngine: provider.search_engine,
-      onLoad: function (aEvent, aBrowser) {
+      onLoad(aEvent, aBrowser) {
         window.close();
       },
     });
 
     // Wait for the handler to close us.
     EmailAccountProvisioner.spinning(true);
     EmailAccountProvisioner.searchEnabled(false);
     for (let node of document.querySelectorAll("#notifications > :not(.spinner)")) {
@@ -563,32 +563,32 @@ var EmailAccountProvisioner = {
     // we already got it before, bail out.
     if (this._loadingProviders || this._loadedProviders)
       return;
 
     gLog.info("Trying to populate provider list...");
 
     // If there's a timeout ID for waking the account provisioner, clear it.
     if (this._loadProviderRetryId) {
-      window.clearTimeout(this._loadProviderRetryId)
+      window.clearTimeout(this._loadProviderRetryId);
       this._loadProviderRetryId = null;
     }
 
     this.searchEnabled(false);
     this.spinning(true);
 
     let providerListUrl = Services.prefs.getCharPref("mail.provider.providerList");
 
     let request = new XMLHttpRequest();
     request.open("GET", providerListUrl);
     request.onload = function() {
       let data;
       try {
         data = JSON.parse(request.responseText);
-      } catch(e) {};
+      } catch (e) {}
       EmailAccountProvisioner.populateProviderList(data);
     };
     request.onerror = () => {
       // Ugh, we couldn't get the JSON file. Maybe we're not online. Or maybe
       // the server is down, or the file isn't being served. Regardless, if
       // we get here, none of this stuff is going to work.
       EmailAccountProvisioner._loadProviderRetryId =
         window.setTimeout(() => EmailAccountProvisioner.tryToPopulateProviderList(),
@@ -600,17 +600,17 @@ var EmailAccountProvisioner = {
     };
     request.onloadend = function() {
       EmailAccountProvisioner._loadingProviders = false;
       EmailAccountProvisioner.spinning(false);
       gLog.info("Got provider list JSON.");
     };
     request.timeout = CONNECTION_TIMEOUT;
     request.ontimeout = () => {
-      glog.info("Timeout of XMLHttpRequest fetching provider list.");
+      gLog.info("Timeout of XMLHttpRequest fetching provider list.");
       request.onError();
     };
     request.send(null);
 
     EmailAccountProvisioner._loadingProviders = true;
     gLog.info("We've kicked off a request for the provider list JSON file...");
   },
 
@@ -622,17 +622,17 @@ var EmailAccountProvisioner = {
 
     for (let aField of required) {
       let fieldExists = (aField in provider);
       result &= fieldExists;
 
       if (!fieldExists)
         gLog.error("A provider did not have the field " + aField
                    + ", and will be skipped.");
-    };
+    }
 
     return result;
   },
 
   /**
    * Take the fetched providers, create checkboxes, icons and labels,
    * and insert them below the search input.
    */
@@ -656,17 +656,17 @@ var EmailAccountProvisioner = {
         return;
       }
 
       EmailAccountProvisioner.providers[provider.id] = provider;
 
       // Let's go through the array of languages for this provider, and
       // check to see if at least one of them matches the user's language.
       // If so, we'll show / select this provider by default.
-      let supportsSomeUserLang = provider.languages.some(function (x) {
+      let supportsSomeUserLang = provider.languages.some(function(x) {
         return x == "*" || x == EmailAccountProvisioner.userLanguage;
       });
 
       let checkboxId = provider.id + "-check";
 
       let providerCheckbox = document.createElement("input");
       providerCheckbox.setAttribute("type", "checkbox");
       providerCheckbox.setAttribute("value", provider.id);
@@ -696,18 +696,17 @@ var EmailAccountProvisioner = {
 
       providerCheckbox.addEventListener("change",
         EmailAccountProvisioner.populateTermsAndPrivacyLinks);
 
       if (supportsSomeUserLang) {
         providerCheckbox.setAttribute("checked", "true");
         providerEntry.style.display = "inline-block";
         providerList.appendChild(providerEntry);
-      }
-      else {
+      } else {
         providerEntry.classList.add("otherLanguage");
         otherLangProviders.push(providerEntry);
       }
     });
 
     if (otherLangProviders.length) {
       for (let provider of otherLangProviders) {
         providerList.appendChild(provider);
@@ -768,17 +767,17 @@ var EmailAccountProvisioner = {
 
       span = document.createElement("span");
       span.appendChild(document.createTextNode(stringBundle.get("sepComma")));
       providerList.appendChild(span);
 
       a = document.createElement("a");
       a.setAttribute("href", provider.tos_url);
       a.setAttribute("class", "tos external " + provider.id);
-      a.appendChild(document.createTextNode(stringBundle.get('tos')));
+      a.appendChild(document.createTextNode(stringBundle.get("tos")));
       providerList.appendChild(a);
 
       span = document.createElement("span");
       span.appendChild(document.createTextNode(")"));
       providerList.appendChild(span);
 
       if (len != 1) {
         if (i < len - 2) {
@@ -796,32 +795,32 @@ var EmailAccountProvisioner = {
     placeholder.textContent = "";
     placeholder.appendChild(providerList);
   },
 
   /**
    * Something went wrong during search.  Show a generic error.  In the future,
    * we might want to show something a bit more descriptive.
    */
-  showSearchError: function() {
+  showSearchError() {
     for (let node of document.getElementById("notifications").children) {
       node.style.display = "none";
     }
     for (let node of document.querySelectorAll("#notifications .error")) {
-      node.style.display = "block"
+      node.style.display = "block";
       node.getBoundingClientRect();
       node.classList.add("showWithFade");
     }
   },
 
   /**
    * Once we've received search results from the server, create some
    * elements to display those results, and inject them into the DOM.
    */
-  onSearchResults: function(data) {
+  onSearchResults(data) {
     gLog.info("Got back search results");
 
     // Empty any old results.
     let results = document.getElementById("results");
     results.textContent = "";
 
     if (!data || !data.length) {
       // If we've gotten back nonsense, display the generic
@@ -845,17 +844,17 @@ var EmailAccountProvisioner = {
       // got at least one result, and that the provider is actually in
       // the list of providers that we care about.
       let providerInList = (aResult.provider in EmailAccountProvisioner.providers);
 
       if (!providerInList)
         gLog.error("Got a result back for a provider that was not "
                    + "in the original providerList: " + aResult.provider);
 
-      let providerSelected = selectedProviders.indexOf(aResult.provider) != -1;
+      let providerSelected = selectedProviders.includes(aResult.provider);
 
       if (!providerSelected)
         gLog.error("Got a result back for a provider that the user did "
                    + "not select: " + aResult.provider);
 
       return (aResult.succeeded
               && aResult.addresses.length > 0
               && providerInList
@@ -898,21 +897,21 @@ var EmailAccountProvisioner = {
         // Figure out the price to display on the address button, as so:
         // If there is a per-address price of > 0, use that.
         // Otherwise, if there is a per-address price of 0, use "Free",
         // Otherwise, there's no per-address price,
         //   so if the provider's price is > 0, use that.
         //   Or if the provider's price is 0, use "Free".
         let priceStr;
         if (address.price && address.price != "0")
-          priceStr = stringBundle.get("price", [address.price])
+          priceStr = stringBundle.get("price", [address.price]);
         else if (address.price && address.price == "0")
           priceStr = stringBundle.get("free");
         else if (provider.price && provider.price != "0")
-          priceStr = stringBundle.get("price", [provider.price])
+          priceStr = stringBundle.get("price", [provider.price]);
         else
           priceStr = stringBundle.get("free");
 
         let templateElement = document.querySelector("#result_tmpl");
         let result = document.importNode(templateElement.content, true).children[0];
         let finalAddress = address.address ? address.address : address;
         function replacePlaceholders(elem) {
           if (elem.childNodes.length > 0)
@@ -981,17 +980,17 @@ var EmailAccountProvisioner = {
 
   /**
    * If we cannot retrieve the provider list from the server, display a
    * message about connection problems, and disable the search fields.
    */
   beOffline: function EAP_beOffline() {
     let offlineMsg = stringBundle.get("cannotConnect");
     let element = document.getElementById("cannotConnectMessage");
-    if(!element.hasChildNodes()) {
+    if (!element.hasChildNodes()) {
       element.appendChild(document.createTextNode(offlineMsg));
     }
     element.style.display = "block";
     element.style.opacity = 1;
     this.searchEnabled(false);
     gLog.info("Email Account Provisioner is in offline mode.");
   },
 
@@ -1000,18 +999,18 @@ var EmailAccountProvisioner = {
    * error message and re-enable the search fields.
    */
   beOnline: function EAP_beOnline() {
     let element = document.getElementById("cannotConnectMessage");
     element.style.display = "none";
     element.textContent = "";
     this.searchEnabled(true);
     gLog.info("Email Account Provisioner is in online mode.");
-  }
-}
+  },
+};
 
 
 XPCOMUtils.defineLazyGetter(EmailAccountProvisioner, "storage", function() {
   return getLocalStorage("accountProvisioner");
 });
 
 window.addEventListener("online",
                         EmailAccountProvisioner.tryToPopulateProviderList);
--- a/mail/components/newmailaccount/content/accountProvisionerTab.js
+++ b/mail/components/newmailaccount/content/accountProvisionerTab.js
@@ -1,29 +1,34 @@
 /* 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/. */
 
+// mail/base/content/contentAreaClick.js
+/* globals hRefForClickEvent, openLinkExternally */
+// mail/base/content/specialTabs.js
+/* globals specialTabs */
+
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource:///modules/gloda/log4moz.js");
+var { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
 
 /**
  * A content tab for the account provisioner.  We use Javascript-y magic to
  * "subclass" specialTabs.contentTabType, and then override the appropriate
  * members.
  *
  * Also note that accountProvisionerTab is a singleton (hence the maxTabs: 1).
  */
 var accountProvisionerTabType = Object.create(specialTabs.contentTabType, {
   name: {value: "accountProvisionerTab"},
   modes: {value: {
     accountProvisionerTab: {
       type: "accountProvisionerTab",
       maxTabs: 1,
-    }
+    },
   }},
   _log: {value: Log4Moz.getConfiguredLogger("mail.provider")},
 });
 
 /**
  * Here, we're overriding openTab - first we call the openTab of contentTab
  * (for the context of this accountProvisionerTab "aTab") and then passing
  * special arguments "realName", "email" and "searchEngine" from the caller
@@ -36,58 +41,58 @@ accountProvisionerTabType.openTab = func
   // Since there's only one tab of this type ever (see the mode definition),
   // we're OK to stash this stuff here.
   this._realName = aArgs.realName;
   this._email = aArgs.email;
   this._searchEngine = aArgs.searchEngine || "";
 
   this._setMonitoring(aTab.browser, aArgs.realName, aArgs.email,
                       aArgs.searchEngine);
-}
+};
 
 /**
  * We're overriding closeTab - first, we call the closeTab of contentTab,
  * (for the context of this accountProvisionerTab "aTab"), and then we
  * unregister our observer that was registered in _setMonitoring.
  */
 accountProvisionerTabType.closeTab = function(aTab) {
   specialTabs.contentTabType.closeTab.call(this, aTab);
   this._log.info("Performing account provisioner cleanup");
   this._log.info("Removing httpRequestObserver");
   Services.obs.removeObserver(this._observer, "http-on-examine-response");
   Services.obs.removeObserver(this._observer, "http-on-examine-cached-response");
-  Services.obs.removeObserver(this.quitObserver, "mail-unloading-messenger", false);
+  Services.obs.removeObserver(this.quitObserver, "mail-unloading-messenger");
   delete this._observer;
   this._log.info("Account provisioner cleanup is done.");
-}
+};
 
 /**
  * Serialize our tab into something we can restore later.
  */
 accountProvisionerTabType.persistTab = function(aTab) {
   return {
     tabURI: aTab.browser.currentURI.spec,
     realName: this._realName,
     email: this._email,
-    searchEngine: this._searchEngine
+    searchEngine: this._searchEngine,
   };
-}
+};
 
 /**
  * Re-open the accountProvisionerTab with all of the stuff we stashed in
  * persistTab. This will automatically hook up our monitoring again.
  */
 accountProvisionerTabType.restoreTab = function(aTabmail, aPersistedState) {
   aTabmail.openTab("accountProvisionerTab",
                    { contentPage: aPersistedState.tabURI,
                      realName: aPersistedState.realName,
                      email: aPersistedState.email,
                      searchEngine: aPersistedState.searchEngine,
                      background: true } );
-}
+};
 
 /**
  * This function registers an observer to watch for HTTP requests where the
  * contentType contains text/xml.
  */
 accountProvisionerTabType._setMonitoring = function(aBrowser, aRealName,
                                                     aEmail, aSearchEngine) {
   let mail3Pane = Services.wm.getMostRecentWindow("mail:3pane");
@@ -102,17 +107,17 @@ accountProvisionerTabType._setMonitoring
   });
 
   // Register our observer
   Services.obs.addObserver(this._observer, "http-on-examine-response");
   Services.obs.addObserver(this._observer, "http-on-examine-cached-response");
   Services.obs.addObserver(this.quitObserver, "mail-unloading-messenger");
 
   this._log.info("httpRequestObserver wired up.");
-}
+};
 
 /**
  * Click handler for the Account Provisioner tab that allows all links
  * to open within the current content tab, except for those which have
  * their targets set to _blank - these links open in the default browser.
  */
 accountProvisionerTabType.clickHandler = function(aEvent) {
   // Don't handle events that: a) aren't trusted, b) have already been
@@ -126,29 +131,29 @@ accountProvisionerTabType.clickHandler =
   if (aEvent.target.hasAttribute("target")) {
     if (aEvent.target.target == "_blank") {
       aEvent.preventDefault();
       openLinkExternally(href);
     }
   }
 
   return false;
-}
+};
 
 /**
  * This observer listens for the mail-unloading-messenger event fired by each
  * mail window before they unload. If the mail window is the same window that
  * this accountProvisionerTab belongs to, then we stash a pref so that when
  * the session restarts, we go straight to the tab, as opposed to showing the
  * dialog again.
  */
 accountProvisionerTabType.quitObserver = {
-  observe: function(aSubject, aTopic, aData) {
+  observe(aSubject, aTopic, aData) {
     // Make sure we saw the right topic, and that the window that is closing
     // is the 3pane window that the accountProvisionerTab belongs to.
     if (aTopic == "mail-unloading-messenger" && (aSubject === window)) {
       // We quit while the accountProvisionerTab was opened. Set our sneaky
       // pref so that we suppress the dialog on startup.
       Services.prefs.setBoolPref("mail.provider.suppress_dialog_on_startup",
                                  true);
     }
-  }
-}
+  },
+};
--- a/mail/components/newmailaccount/content/uriListener.js
+++ b/mail/components/newmailaccount/content/uriListener.js
@@ -1,12 +1,15 @@
 /* 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/. */
 
+// mailnews/base/prefs/content/accountUtils.js
+/* globals NewMailAccountProvisioner */
+
 /**
  * This object takes care of intercepting page loads and creating the
  * corresponding account if the page load turns out to be a text/xml file from
  * one of our account providers.
  */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -29,31 +32,31 @@ ChromeUtils.import("resource:///modules/
  * @param aParams.searchEngine The search engine associated to that provider.
  */
 function httpRequestObserver(aBrowser, aParams) {
   this.browser = aBrowser;
   this.params = aParams;
 }
 
 httpRequestObserver.prototype = {
-  observe: function(aSubject, aTopic, aData) {
+  observe(aSubject, aTopic, aData) {
     if (aTopic != "http-on-examine-response" &&
         aTopic != "http-on-examine-cached-response")
       return;
 
     if (!(aSubject instanceof Ci.nsIHttpChannel)) {
       Cu.reportError("Failed to get a nsIHttpChannel when "
                      + "observing http-on-examine-response");
       return;
     }
 
     let contentType = "";
     try {
       contentType = aSubject.getResponseHeader("Content-Type");
-    } catch(e) {
+    } catch (e) {
       // If we couldn't get the response header, which can happen,
       // just swallow the exception and return.
       return;
     }
 
     if (!contentType.toLowerCase().startsWith("text/xml"))
       return;
 
@@ -72,39 +75,39 @@ httpRequestObserver.prototype = {
   /**
    * _getWindowForRequest is an internal function that takes an nsIRequest,
    * and returns the associated window for that request.  If it cannot find
    * an associated window, the function returns null. On exception, the
    * exception message is logged to the Error Console and null is returned.
    *
    * @param aRequest the nsIRequest to analyze
    */
-  _getWindowForRequest: function(aRequest) {
+  _getWindowForRequest(aRequest) {
     try {
       if (aRequest && aRequest.notificationCallbacks) {
         return aRequest.notificationCallbacks
                        .getInterface(Ci.nsILoadContext)
                        .associatedWindow;
       }
       if (aRequest && aRequest.loadGroup
           && aRequest.loadGroup.notificationCallbacks) {
         return aRequest.loadGroup
                        .notificationCallbacks
                        .getInterface(Ci.nsILoadContext)
                        .associatedWindow;
       }
-    } catch(e) {
+    } catch (e) {
       Cu.reportError("Could not find an associated window "
                      + "for an HTTP request. Error: " + e);
     }
     return null;
   },
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
-}
+};
 
 /**
  * TracingListener is an nsITracableChannel implementation that copies
  * an incoming stream of data from a request.  The data flows through this
  * nsITracableChannel transparently to the original listener. Once the
  * response data is fully downloaded, an attempt is made to parse it
  * as XML, and derive email account data from it.
  *
@@ -118,24 +121,24 @@ function TracingListener(aBrowser, aPara
   this.chunks = [];
   this.browser = aBrowser;
   this.params = aParams;
   this.oldListener = null;
 }
 
 TracingListener.prototype = {
 
-  onStartRequest: function (/* nsIRequest */ aRequest,
-                            /* nsISupports */ aContext) {
+  onStartRequest(/* nsIRequest */ aRequest,
+                 /* nsISupports */ aContext) {
     this.oldListener.onStartRequest(aRequest, aContext);
   },
 
-  onStopRequest: function (/* nsIRequest */ aRequest,
-                           /* nsISupports */ aContext,
-                           /* int */ aStatusCode) {
+  onStopRequest(/* nsIRequest */ aRequest,
+                /* nsISupports */ aContext,
+                /* int */ aStatusCode) {
 
     // Why don't people use JSMs? Sigh...
     let accountCreationFuncs = {};
     Services.scriptloader.loadSubScript(
       "chrome://messenger/content/accountcreation/util.js",
       accountCreationFuncs);
     Services.scriptloader.loadSubScript(
       "chrome://messenger/content/accountcreation/accountConfig.js",
@@ -160,17 +163,17 @@ TracingListener.prototype = {
       accountCreationFuncs);
     Services.scriptloader.loadSubScript(
       "chrome://messenger/content/accountcreation/createInBackend.js",
       accountCreationFuncs);
     Services.scriptloader.loadSubScript(
       "chrome://messenger/content/accountcreation/MyBadCertHandler.js",
       accountCreationFuncs);
 
-    let tabmail = document.getElementById('tabmail');
+    let tabmail = document.getElementById("tabmail");
     let success = false;
     let account;
 
     try {
       // Attempt to construct the downloaded data into XML
       let data = this.chunks.join("");
 
       // Attempt to derive email account information
@@ -188,36 +191,36 @@ TracingListener.prototype = {
       // tab will be reopened.
       Cu.reportError("Problem interpreting provider XML:" + e);
     }
 
     tabmail.switchToTab(0);
 
     // Find the tab associated with this browser, and close it.
     let myTabInfo = tabmail.tabInfo
-      .filter((function (x) {
+      .filter((function(x) {
             return "browser" in x && x.browser == this.browser;
             }).bind(this))[0];
     tabmail.closeTab(myTabInfo);
 
     // Respawn the account provisioner to announce our success
     NewMailAccountProvisioner(null, {
-      success: success,
+      success,
       search_engine: this.params.searchEngine,
-      account: account,
+      account,
     });
 
     this.oldListener.onStopRequest(aRequest, aContext, aStatusCode);
   },
 
-  onDataAvailable: function (/* nsIRequest */ aRequest,
-                             /* nsISupports */ aContext,
-                             /* nsIInputStream */ aStream,
-                             /* int */ aOffset,
-                             /* int */ aCount) {
+  onDataAvailable(/* nsIRequest */ aRequest,
+                  /* nsISupports */ aContext,
+                  /* nsIInputStream */ aStream,
+                  /* int */ aOffset,
+                  /* int */ aCount) {
     // We want to read the stream of incoming data, but we also want
     // to make sure it gets passed to the original listener. We do this
     // by passing the input stream through an nsIStorageStream, writing
     // the data to that stream, and passing it along to the next listener.
     let binaryInputStream = Cc["@mozilla.org/binaryinputstream;1"]
                            .createInstance(Ci.nsIBinaryInputStream);
     let storageStream = Cc["@mozilla.org/storagestream;1"]
                         .createInstance(Ci.nsIStorageStream);
@@ -237,11 +240,11 @@ TracingListener.prototype = {
 
     outStream.writeBytes(data, aCount);
     this.oldListener.onDataAvailable(aRequest, aContext,
                                      storageStream.newInputStream(0),
                                      aOffset, aCount);
   },
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener,
-                                          Ci.nsIRequestObserver])
+                                          Ci.nsIRequestObserver]),
 
-}
+};