Bug 1278137 - Use ES6 method syntax in LoginManagerContent.jsm. r=MattN draft
authorSaad Quadri <saad@saadquadri.com>
Mon, 06 Jun 2016 17:28:38 -0700
changeset 375964 001fd9d81f09dba9a412e9fd1382e9459ce0d4e3
parent 375955 53a41d7fbab03dd0de9cab127dd3302cea22360f
child 376303 268578076a9aba58dbb842499fa2bf76e1b65990
child 376306 7ce53292dfc4bbb926c9bb108beab9f6ed6b576b
push id20440
push userbmo:saad@saadquadri.com
push dateTue, 07 Jun 2016 00:27:47 +0000
reviewersMattN
bugs1278137
milestone50.0a1
Bug 1278137 - Use ES6 method syntax in LoginManagerContent.jsm. r=MattN MozReview-Commit-ID: JO4iy7F8Hur
toolkit/components/passwordmgr/LoginManagerContent.jsm
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -42,34 +42,34 @@ XPCOMUtils.defineLazyGetter(this, "log",
 var gEnabled, gAutofillForms, gStoreWhenAutocompleteOff;
 
 var observer = {
   QueryInterface : XPCOMUtils.generateQI([Ci.nsIObserver,
                                           Ci.nsIFormSubmitObserver,
                                           Ci.nsISupportsWeakReference]),
 
   // nsIFormSubmitObserver
-  notify : function (formElement, aWindow, actionURI) {
+  notify(formElement, aWindow, actionURI) {
     log("observer notified for form submission.");
 
     // We're invoked before the content's |onsubmit| handlers, so we
     // can grab form data before it might be modified (see bug 257781).
 
     try {
       let formLike = FormLikeFactory.createFromForm(formElement);
       LoginManagerContent._onFormSubmit(formLike);
     } catch (e) {
       log("Caught error in onFormSubmit(", e.lineNumber, "):", e.message);
       Cu.reportError(e);
     }
 
     return true; // Always return true, or form submit will be canceled.
   },
 
-  onPrefChange : function() {
+  onPrefChange() {
     gEnabled = Services.prefs.getBoolPref("signon.rememberSignons");
     gAutofillForms = Services.prefs.getBoolPref("signon.autofillForms");
     gStoreWhenAutocompleteOff = Services.prefs.getBoolPref("signon.storeWhenAutocompleteOff");
   },
 };
 
 Services.obs.addObserver(observer, "earlyformsubmit", false);
 var prefBranch = Services.prefs.getBranch("signon.");
@@ -93,17 +93,17 @@ var LoginManagerContent = {
   get _formFillService() {
     if (!this.__formFillService)
       this.__formFillService =
                       Cc["@mozilla.org/satchel/form-fill-controller;1"].
                       getService(Ci.nsIFormFillController);
     return this.__formFillService;
   },
 
-  _getRandomId: function() {
+  _getRandomId() {
     return Cc["@mozilla.org/uuid-generator;1"]
              .getService(Ci.nsIUUIDGenerator).generateUUID().toString();
   },
 
   _messages: [ "RemoteLogins:loginsFound",
                "RemoteLogins:loginsAutoCompleted" ],
 
   /**
@@ -131,17 +131,17 @@ var LoginManagerContent = {
   _deferredPasswordAddedTasksByRootElement: new WeakMap(),
 
   // Map from form login requests to information about that request.
   _requests: new Map(),
 
   // Number of outstanding requests to each manager.
   _managers: new Map(),
 
-  _takeRequest: function(msg) {
+  _takeRequest(msg) {
     let data = msg.data;
     let request = this._requests.get(data.requestId);
 
     this._requests.delete(data.requestId);
 
     let count = this._managers.get(msg.target);
     if (--count === 0) {
       this._managers.delete(msg.target);
@@ -150,17 +150,17 @@ var LoginManagerContent = {
         msg.target.removeMessageListener(message, this);
     } else {
       this._managers.set(msg.target, count);
     }
 
     return request;
   },
 
-  _sendRequest: function(messageManager, requestData,
+  _sendRequest(messageManager, requestData,
                          name, messageData) {
     let count;
     if (!(count = this._managers.get(messageManager))) {
       this._managers.set(messageManager, 1);
 
       for (let message of this._messages)
         messageManager.addMessageListener(message, this);
     } else {
@@ -173,17 +173,17 @@ var LoginManagerContent = {
     messageManager.sendAsyncMessage(name, messageData);
 
     let deferred = Promise.defer();
     requestData.promise = deferred;
     this._requests.set(requestId, requestData);
     return deferred.promise;
   },
 
-  receiveMessage: function (msg, window) {
+  receiveMessage(msg, window) {
     if (msg.name == "RemoteLogins:fillForm") {
       this.fillForm({
         topDocument: window.document,
         loginFormOrigin: msg.data.loginFormOrigin,
         loginsFound: LoginHelper.vanillaObjectsToLogins(msg.data.logins),
         recipes: msg.data.recipes,
         inputElement: msg.objects.inputElement,
       });
@@ -219,17 +219,17 @@ var LoginManagerContent = {
 
   /**
    * Get relevant logins and recipes from the parent
    *
    * @param {HTMLFormElement} form - form to get login data for
    * @param {Object} options
    * @param {boolean} options.showMasterPassword - whether to show a master password prompt
    */
-  _getLoginDataFromParent: function(form, options) {
+  _getLoginDataFromParent(form, options) {
     let doc = form.ownerDocument;
     let win = doc.defaultView;
 
     let formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI);
     if (!formOrigin) {
       return Promise.reject("_getLoginDataFromParent: A form origin is required");
     }
     let actionOrigin = LoginUtils._getActionOrigin(form);
@@ -242,17 +242,17 @@ var LoginManagerContent = {
                         actionOrigin: actionOrigin,
                         options: options };
 
     return this._sendRequest(messageManager, requestData,
                              "RemoteLogins:findLogins",
                              messageData);
   },
 
-  _autoCompleteSearchAsync: function(aSearchString, aPreviousResult,
+  _autoCompleteSearchAsync(aSearchString, aPreviousResult,
                                      aElement, aRect) {
     let doc = aElement.ownerDocument;
     let form = FormLikeFactory.createFromField(aElement);
     let win = doc.defaultView;
 
     let formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI);
     let actionOrigin = LoginUtils._getActionOrigin(form);
 
@@ -496,29 +496,29 @@ var LoginManagerContent = {
       form = FormLikeFactory.createFromField(inputElement);
       if (inputElement.type == "password") {
         clobberUsername = false;
       }
     }
     this._fillForm(form, true, clobberUsername, true, true, loginsFound, recipes, options);
   },
 
-  loginsFound: function({ form, loginsFound, recipes }) {
+  loginsFound({ form, loginsFound, recipes }) {
     let doc = form.ownerDocument;
     let autofillForm = gAutofillForms && !PrivateBrowsingUtils.isContentWindowPrivate(doc.defaultView);
 
     this._fillForm(form, autofillForm, false, false, false, loginsFound, recipes);
   },
 
   /*
    * onUsernameInput
    *
    * Listens for DOMAutoComplete and blur events on an input field.
    */
-  onUsernameInput : function(event) {
+  onUsernameInput(event) {
     if (!event.isTrusted)
       return;
 
     if (!gEnabled)
       return;
 
     var acInputField = event.target;
 
@@ -619,17 +619,17 @@ var LoginManagerContent = {
    * "theLoginField". If not null, the form is apparently a
    * change-password field, with oldPasswordField containing the password
    * that is being changed.
    *
    * Note that even though we can create a FormLike from a text field,
    * this method will only return a non-null usernameField if the
    * FormLike has a password field.
    */
-  _getFormFields : function (form, isSubmission, recipes) {
+  _getFormFields(form, isSubmission, recipes) {
     var usernameField = null;
     var pwFields = null;
     var fieldOverrideRecipe = LoginRecipesContent.getFieldOverrides(recipes, form);
     if (fieldOverrideRecipe) {
       var pwOverrideField = LoginRecipesContent.queryLoginField(
         form,
         fieldOverrideRecipe.passwordSelector
       );
@@ -849,17 +849,17 @@ var LoginManagerContent = {
    *                               overwritten
    * @param {bool} userTriggered is an indication of whether this filling was triggered by
    *                             the user
    * @param {nsILoginInfo[]} foundLogins is an array of nsILoginInfo that could be used for the form
    * @param {Set} recipes that could be used to affect how the form is filled
    * @param {Object} [options = {}] is a list of options for this method.
             - [inputElement] is an optional target input element we want to fill
    */
-  _fillForm : function (form, autofillForm, clobberUsername, clobberPassword,
+  _fillForm(form, autofillForm, clobberUsername, clobberPassword,
                         userTriggered, foundLogins, recipes, {inputElement} = {}) {
     let ignoreAutocomplete = true;
     const AUTOFILL_RESULT = {
       FILLED: 0,
       NO_PASSWORD_FIELD: 1,
       PASSWORD_DISABLED_READONLY: 2,
       NO_LOGINS_FIT: 3,
       NO_SAVED_LOGINS: 4,
@@ -1226,44 +1226,44 @@ UserAutoCompleteResult.prototype = {
 
   // Interfaces from idl...
   searchString : null,
   searchResult : Ci.nsIAutoCompleteResult.RESULT_NOMATCH,
   defaultIndex : -1,
   errorDescription : "",
   matchCount : 0,
 
-  getValueAt : function (index) {
+  getValueAt(index) {
     if (index < 0 || index >= this.logins.length)
       throw new Error("Index out of range.");
 
     return this.logins[index].username;
   },
 
-  getLabelAt: function(index) {
+  getLabelAt(index) {
     return this.getValueAt(index);
   },
 
-  getCommentAt : function (index) {
+  getCommentAt(index) {
     return "";
   },
 
-  getStyleAt : function (index) {
+  getStyleAt(index) {
     return "";
   },
 
-  getImageAt : function (index) {
+  getImageAt(index) {
     return "";
   },
 
-  getFinalCompleteValueAt : function (index) {
+  getFinalCompleteValueAt(index) {
     return this.getValueAt(index);
   },
 
-  removeValueAt : function (index, removeFromDB) {
+  removeValueAt(index, removeFromDB) {
     if (index < 0 || index >= this.logins.length)
         throw new Error("Index out of range.");
 
     var [removedLogin] = this.logins.splice(index, 1);
 
     this.matchCount--;
     if (this.defaultIndex > this.logins.length)
       this.defaultIndex--;