Bug 1427954 - Remove unused uninit code from editDialog.js and autofillEditForms.js. r=sfoster
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 14 Mar 2018 17:31:56 -0700
changeset 408636 e2eae899dc4ab8352dffdfeacc974ccdc83fa3bf
parent 408635 2f8bd1f13394a18448db08a7b62bf6c8afaabf99
child 408637 ac23b9ba0603839616105f4fbe7d015ddff28254
push id100996
push userbtara@mozilla.com
push dateSat, 17 Mar 2018 10:37:43 +0000
treeherdermozilla-inbound@97160a734959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1427954
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427954 - Remove unused uninit code from editDialog.js and autofillEditForms.js. r=sfoster MozReview-Commit-ID: 9GP1gsycgJo
browser/extensions/formautofill/content/autofillEditForms.js
browser/extensions/formautofill/content/editDialog.js
--- a/browser/extensions/formautofill/content/autofillEditForms.js
+++ b/browser/extensions/formautofill/content/autofillEditForms.js
@@ -1,32 +1,28 @@
 /* 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/. */
 
 /* exported EditAddress, EditCreditCard */
+/* eslint-disable mozilla/balanced-listeners */ // Not relevant since the document gets unloaded.
 
 "use strict";
 
 const AUTOFILL_BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties";
 const REGIONS_BUNDLE_URI = "chrome://global/locale/regionNames.properties";
 
 ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm");
 
 class EditAutofillForm {
   constructor(elements, record) {
     this._elements = elements;
     this._record = record;
   }
 
-  uninit() {
-    this.detachEventListeners();
-    this._elements = null;
-  }
-
   /**
    * Fill the form with a record object.
    * @param  {object} record
    */
   loadInitialValues(record) {
     for (let field in record) {
       let input = document.getElementById(field);
       if (input) {
@@ -50,20 +46,16 @@ class EditAutofillForm {
 
   /**
    * Handle events
    *
    * @param  {DOMEvent} event
    */
   handleEvent(event) {
     switch (event.type) {
-      case "unload": {
-        this.uninit();
-        break;
-      }
       case "input": {
         this.handleInput(event);
         break;
       }
       case "change": {
         this.handleChange(event);
         break;
       }
@@ -79,23 +71,16 @@ class EditAutofillForm {
 
   /**
    * Attach event listener
    */
   attachEventListeners() {
     this._elements.form.addEventListener("input", this);
   }
 
-  /**
-   * Remove event listener
-   */
-  detachEventListeners() {
-    this._elements.form.removeEventListener("input", this);
-  }
-
   // An interface to be inherited.
   localizeDocument() {}
 
   // An interface to be inherited.
   handleChange(event) {}
 }
 
 class EditAddress extends EditAutofillForm {
@@ -174,21 +159,16 @@ class EditAddress extends EditAutofillFo
   handleChange(event) {
     this.formatForm(event.target.value);
   }
 
   attachEventListeners() {
     this._elements.country.addEventListener("change", this);
     super.attachEventListeners();
   }
-
-  detachEventListeners() {
-    this._elements.country.removeEventListener("change", this);
-    super.detachEventListeners();
-  }
 }
 
 class EditCreditCard extends EditAutofillForm {
   constructor(elements, record) {
     super(elements, record);
     Object.assign(this._elements, {
       ccNumber: this._elements.form.querySelector("#cc-number"),
       year: this._elements.form.querySelector("#cc-exp-year"),
--- a/browser/extensions/formautofill/content/editDialog.js
+++ b/browser/extensions/formautofill/content/editDialog.js
@@ -1,13 +1,14 @@
 /* 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/. */
 
 /* exported EditAddressDialog, EditCreditCardDialog */
+/* eslint-disable mozilla/balanced-listeners */ // Not relevant since the document gets unloaded.
 
 "use strict";
 
 const AUTOFILL_BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties";
 
 ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "formAutofillStorage",
@@ -30,21 +31,16 @@ class AutofillEditDialog {
       await this.loadInitialValues(this._record);
     }
     this.attachEventListeners();
     // For testing only: loadInitialValues for credit card is an async method, and tests
     // need to wait until the values have been filled before editing the fields.
     window.dispatchEvent(new CustomEvent("FormReady"));
   }
 
-  uninit() {
-    this.detachEventListeners();
-    this._elements = null;
-  }
-
   /**
    * Fill the form with a record object.
    * @param  {object} record
    */
   loadInitialValues(record) {
     for (let field in record) {
       let input = document.getElementById(field);
       if (input) {
@@ -82,20 +78,16 @@ class AutofillEditDialog {
    * @param  {DOMEvent} event
    */
   handleEvent(event) {
     switch (event.type) {
       case "DOMContentLoaded": {
         this.init();
         break;
       }
-      case "unload": {
-        this.uninit();
-        break;
-      }
       case "click": {
         this.handleClick(event);
         break;
       }
       case "input": {
         this.handleInput(event);
         break;
       }
@@ -158,26 +150,16 @@ class AutofillEditDialog {
    */
   attachEventListeners() {
     window.addEventListener("keypress", this);
     window.addEventListener("contextmenu", this);
     this._elements.controlsContainer.addEventListener("click", this);
     document.addEventListener("input", this);
   }
 
-  /**
-   * Remove event listener
-   */
-  detachEventListeners() {
-    window.removeEventListener("keypress", this);
-    window.removeEventListener("contextmenu", this);
-    this._elements.controlsContainer.removeEventListener("click", this);
-    document.removeEventListener("input", this);
-  }
-
   // An interface to be inherited.
   localizeDocument() {}
 }
 
 class EditAddressDialog extends AutofillEditDialog {
   constructor(elements, record) {
     let country = record ? record.country :
                   FormAutofillUtils.supportedCountries.find(supported => supported == FormAutofillUtils.DEFAULT_REGION);