Backed out changeset c4d1729c029e (bug 1474905) for browser chrome failures on browser_editCreditCardDialog.js. CLOSED TREE
authorCosmin Sabou <csabou@mozilla.com>
Fri, 14 Dec 2018 21:44:32 +0200
changeset 450567 9e64208641b85674cde06b89592f5ef273a0b02e
parent 450566 b40c8b4f9cae7ed33a7383d0f5dbc883608b6531
child 450568 83707acc26efcaba1f28b6b427e8a80a11e4d5c4
push id35207
push useraciure@mozilla.com
push dateSat, 15 Dec 2018 02:27:37 +0000
treeherdermozilla-central@d8a944c012a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1474905
milestone66.0a1
backs outc4d1729c029e2c17058c0f093fe9cc0037be0e51
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
Backed out changeset c4d1729c029e (bug 1474905) for browser chrome failures on browser_editCreditCardDialog.js. CLOSED TREE
browser/components/payments/content/paymentDialogFrameScript.js
browser/components/payments/res/containers/address-form.js
browser/components/payments/res/unprivileged-fallbacks.js
browser/components/payments/test/mochitest/test_address_form.html
browser/extensions/formautofill/FormAutofillUtils.jsm
browser/extensions/formautofill/content/autofillEditForms.js
browser/extensions/formautofill/content/editAddress.xhtml
browser/extensions/formautofill/content/editDialog.js
browser/extensions/formautofill/test/browser/browser_editAddressDialog.js
--- a/browser/components/payments/content/paymentDialogFrameScript.js
+++ b/browser/components/payments/content/paymentDialogFrameScript.js
@@ -91,20 +91,16 @@ let PaymentFrameScript = {
         return FormAutofillUtils.isCCNumber(value);
       },
 
       getFormFormat(country) {
         let format = FormAutofillUtils.getFormFormat(country);
         return Cu.cloneInto(format, waivedContent);
       },
 
-      findAddressSelectOption(selectEl, address, fieldName) {
-        return FormAutofillUtils.findAddressSelectOption(selectEl, address, fieldName);
-      },
-
       getDefaultPreferences() {
         let prefValues = Cu.cloneInto({
           saveCreditCardDefaultChecked:
             Services.prefs.getBoolPref(SAVE_CREDITCARD_DEFAULT_PREF, false),
           saveAddressDefaultChecked:
             Services.prefs.getBoolPref(SAVE_ADDRESS_DEFAULT_PREF, false),
         }, waivedContent);
         return Cu.cloneInto(prefValues, waivedContent);
--- a/browser/components/payments/res/containers/address-form.js
+++ b/browser/components/payments/res/containers/address-form.js
@@ -93,17 +93,16 @@ export default class AddressForm extends
       this.body.appendChild(form);
 
       let record = undefined;
       this.formHandler = new EditAddress({
         form,
       }, record, {
         DEFAULT_REGION: PaymentDialogUtils.DEFAULT_REGION,
         getFormFormat: PaymentDialogUtils.getFormFormat,
-        findAddressSelectOption: PaymentDialogUtils.findAddressSelectOption,
         countries: PaymentDialogUtils.countries,
       });
 
       // The EditAddress constructor adds `input` event listeners on the same element,
       // which update field validity. By adding our event listeners after this constructor,
       // validity will be updated before our handlers get the event
       this.form.addEventListener("input", this);
       this.form.addEventListener("invalid", this);
--- a/browser/components/payments/res/unprivileged-fallbacks.js
+++ b/browser/components/payments/res/unprivileged-fallbacks.js
@@ -52,17 +52,16 @@ var PaymentDialogUtils = {
   DEFAULT_REGION: "US",
   countries: new Map([["US", "United States"], ["CA", "Canada"], ["DE", "Germany"]]),
   getFormFormat(country) {
     if (country == "DE") {
       return {
         addressLevel3Label: "suburb",
         addressLevel2Label: "city",
         addressLevel1Label: "province",
-        addressLevel1Options: null,
         postalCodeLabel: "postalCode",
         fieldsOrder: [
           {
             fieldId: "name",
             newLine: true,
           },
           {
             fieldId: "organization",
@@ -75,61 +74,42 @@ var PaymentDialogUtils = {
           {fieldId: "postal-code"},
           {fieldId: "address-level2"},
         ],
         postalCodePattern: "\\d{5}",
         countryRequiredFields: ["street-address", "address-level2", "postal-code"],
       };
     }
 
-    let addressLevel1Options = null;
-    if (country == "US") {
-      addressLevel1Options = new Map([
-        ["CA", "California"],
-        ["MA", "Massachusetts"],
-        ["MI", "Michigan"],
-      ]);
-    } else if (country == "CA") {
-      addressLevel1Options = new Map([
-        ["NS", "Nova Scotia"],
-        ["ON", "Ontario"],
-        ["YT", "Yukon"],
-      ]);
-    }
-
     let fieldsOrder = [
       {fieldId: "name", newLine: true},
       {fieldId: "street-address", newLine: true},
       {fieldId: "address-level2"},
       {fieldId: "address-level1"},
       {fieldId: "postal-code"},
       {fieldId: "organization"},
     ];
     if (country == "BR") {
       fieldsOrder.splice(2, 0, {fieldId: "address-level3"});
     }
 
     return {
       addressLevel3Label: "suburb",
       addressLevel2Label: "city",
       addressLevel1Label: country == "US" ? "state" : "province",
-      addressLevel1Options,
       postalCodeLabel: country == "US" ? "zip" : "postalCode",
       fieldsOrder,
       // The following values come from addressReferences.js and should not be changed.
       /* eslint-disable-next-line max-len */
       postalCodePattern: country == "US" ? "(\\d{5})(?:[ \\-](\\d{4}))?" : "[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z] ?\\d[ABCEGHJ-NPRSTV-Z]\\d",
       countryRequiredFields: country == "US" || country == "CA" ?
         ["street-address", "address-level2", "address-level1", "postal-code"] :
         ["street-address", "address-level2", "postal-code"],
     };
   },
-  findAddressSelectOption(selectEl, address, fieldName) {
-    return null;
-  },
   getDefaultPreferences() {
     let prefValues = {
       saveCreditCardDefaultChecked: false,
       saveAddressDefaultChecked: true,
     };
     return prefValues;
   },
   isOfficialBranding() {
--- a/browser/components/payments/test/mochitest/test_address_form.html
+++ b/browser/components/payments/test/mochitest/test_address_form.html
@@ -200,21 +200,17 @@ add_task(async function test_saveButton(
 
   fillField(form.form.querySelector("#street-address"), "404 Internet Super Highway");
   is(form.querySelectorAll(":-moz-ui-invalid").length, 0, "Check no fields visibly invalid");
   ok(!form.saveButton.disabled, "Save button is enabled after re-filling street-address");
 
   fillField(form.form.querySelector("#country"), "CA");
   ok(form.saveButton.disabled, "Save button is disabled after changing the country to Canada");
   fillField(form.form.querySelector("#country"), "US");
-  ok(form.saveButton.disabled,
-     "Save button is disabled after changing the country back to US since address-level1 " +
-     "got cleared when changing countries");
-  fillField(form.form.querySelector("#address-level1"), "CA");
-  ok(!form.saveButton.disabled, "Save button is enabled after re-entering address-level1");
+  ok(!form.saveButton.disabled, "Save button is enabled after changing the country to US");
 
   let messagePromise = promiseContentToChromeMessage("updateAutofillRecord");
   is(form.saveButton.textContent, "Next", "Check label");
   form.saveButton.scrollIntoView();
   synthesizeMouseAtCenter(form.saveButton, {});
 
   let details = await messagePromise;
   ok(typeof(details.messageID) == "number" && details.messageID > 0, "Check messageID type");
@@ -443,35 +439,35 @@ add_task(async function test_field_valid
 
   ok(form.saveButton.disabled, "Save button should be disabled upon load");
 
   fillField(countrySelect, "US");
 
   sendStringAndCheckValidity(addressLevel1Input, "MI", true);
   sendStringAndCheckValidity(addressLevel1Input, "", false);
   sendStringAndCheckValidity(postalCodeInput, "B4N4N4", false);
-  sendStringAndCheckValidity(addressLevel1Input, "NS", false);
+  sendStringAndCheckValidity(addressLevel1Input, "Nova Scotia", true);
   sendStringAndCheckValidity(postalCodeInput, "R3J 3C7", false);
   sendStringAndCheckValidity(addressLevel1Input, "", false);
   sendStringAndCheckValidity(postalCodeInput, "11109", true);
-  sendStringAndCheckValidity(addressLevel1Input, "NS", false);
+  sendStringAndCheckValidity(addressLevel1Input, "Nova Scotia", true);
   sendStringAndCheckValidity(postalCodeInput, "06390-0001", true);
 
   fillField(countrySelect, "CA");
 
   sendStringAndCheckValidity(postalCodeInput, "00001", false);
-  sendStringAndCheckValidity(addressLevel1Input, "CA", false);
+  sendStringAndCheckValidity(addressLevel1Input, "CA", true);
   sendStringAndCheckValidity(postalCodeInput, "94043", false);
   sendStringAndCheckValidity(addressLevel1Input, "", false);
   sendStringAndCheckValidity(postalCodeInput, "B4N4N4", true);
-  sendStringAndCheckValidity(addressLevel1Input, "MI", false);
+  sendStringAndCheckValidity(addressLevel1Input, "MI", true);
   sendStringAndCheckValidity(postalCodeInput, "R3J 3C7", true);
   sendStringAndCheckValidity(addressLevel1Input, "", false);
   sendStringAndCheckValidity(postalCodeInput, "11109", false);
-  sendStringAndCheckValidity(addressLevel1Input, "NS", true);
+  sendStringAndCheckValidity(addressLevel1Input, "Nova Scotia", true);
   sendStringAndCheckValidity(postalCodeInput, "06390-0001", false);
 
   form.remove();
 });
 
 add_task(async function test_merchantShippingAddressErrors() {
   let form = new AddressForm();
   form.id = "shipping-address-page";
--- a/browser/extensions/formautofill/FormAutofillUtils.jsm
+++ b/browser/extensions/formautofill/FormAutofillUtils.jsm
@@ -89,17 +89,17 @@ let AddressDataLoader = {
    * @param   {object} data Original metadata from addressReferences.
    * @returns {object} parsed metadata with property value that converts to array.
    */
   _parse(data) {
     if (!data) {
       return null;
     }
 
-    const properties = ["languages", "sub_keys", "sub_isoids", "sub_names", "sub_lnames"];
+    const properties = ["languages", "sub_keys", "sub_names", "sub_lnames"];
     for (let key of properties) {
       if (!data[key]) {
         continue;
       }
       // No need to normalize data if the value is array already.
       if (Array.isArray(data[key])) {
         return data;
       }
@@ -496,50 +496,16 @@ this.FormAutofillUtils = {
         }
         return parsed;
       }
       return parsed.concat({fieldId});
     }, []);
   },
 
   /**
-   * Used to populate dropdowns in the UI (e.g. FormAutofill preferences, Web Payments).
-   * Use findAddressSelectOption for matching a value to a region.
-   *
-   * @param {string[]} subKeys An array of regionCode strings
-   * @param {string[]} subIsoids An array of ISO ID strings, if provided will be preferred over the key
-   * @param {string[]} subNames An array of regionName strings
-   * @param {string[]} subLnames An array of latinised regionName strings
-   * @returns {Map?} Returns null if subKeys or subNames are not truthy.
-   *                   Otherwise, a Map will be returned mapping keys -> names.
-   */
-  buildRegionMapIfAvailable(subKeys, subIsoids, subNames, subLnames) {
-    // Not all regions have sub_keys. e.g. DE
-    if (!subKeys || !subKeys.length ||
-        (!subNames && !subLnames) ||
-        (subNames && subKeys.length != subNames.length ||
-         subLnames && subKeys.length != subLnames.length)) {
-      return null;
-    }
-
-    // Overwrite subKeys with subIsoids, when available
-    if (subIsoids && subIsoids.length && subIsoids.length == subKeys.length) {
-      for (let i = 0; i < subIsoids.length; i++) {
-        if (subIsoids[i]) {
-          subKeys[i] = subIsoids[i];
-        }
-      }
-    }
-
-    // Apply sub_lnames if sub_names does not exist
-    let names = subNames || subLnames;
-    return new Map(subKeys.map((key, index) => [key, names[index]]));
-  },
-
-  /**
    * Parse a require string and outputs an array of fields.
    * Spaces, commas, and other literals are ignored in this implementation.
    * For example, a require string "ACS" should return:
    * ["street-address", "address-level2", "address-level1"]
    *
    * @param   {string} requireString Country address require string
    * @returns {array<string>} List of fields
    */
@@ -859,21 +825,20 @@ this.FormAutofillUtils = {
   getFormFormat(country) {
     const dataset = this.getCountryAddressData(country);
     return {
       // When particular values are missing for a country, the
       // data/ZZ value should be used instead.
       addressLevel3Label: dataset.sublocality_name_type || "suburb",
       addressLevel2Label: dataset.locality_name_type || "city",
       addressLevel1Label: dataset.state_name_type || "province",
-      addressLevel1Options: this.buildRegionMapIfAvailable(dataset.sub_keys, dataset.sub_isoids, dataset.sub_names, dataset.sub_lnames),
-      countryRequiredFields: this.parseRequireString(dataset.require || "AC"),
+      postalCodeLabel: dataset.zip_name_type || "postalCode",
       fieldsOrder: this.parseAddressFormat(dataset.fmt || "%N%n%O%n%A%n%C"),
-      postalCodeLabel: dataset.zip_name_type || "postalCode",
       postalCodePattern: dataset.zip,
+      countryRequiredFields: this.parseRequireString(dataset.require || "AC"),
     };
   },
 
   /**
    * Localize "data-localization" or "data-localization-region" attributes.
    * @param {Element} element
    * @param {string} attributeName
    */
--- a/browser/extensions/formautofill/content/autofillEditForms.js
+++ b/browser/extensions/formautofill/content/autofillEditForms.js
@@ -130,18 +130,16 @@ class EditAutofillForm {
 
 class EditAddress extends EditAutofillForm {
   /**
    * @param {HTMLElement[]} elements
    * @param {object} record
    * @param {object} config
    * @param {string[]} config.DEFAULT_REGION
    * @param {function} config.getFormFormat Function to return form layout info for a given country.
-   * @param {function} config.findAddressSelectOption Finds the matching select option for a given
-                                                      select element, address, and fieldName.
    * @param {string[]} config.countries
    * @param {boolean} [config.noValidate=undefined] Whether to validate the form
    */
   constructor(elements, record, config) {
     super(elements);
 
     Object.assign(this, config);
     let {form} = this._elements;
@@ -164,22 +162,17 @@ class EditAddress extends EditAutofillFo
 
   loadRecord(record) {
     this._record = record;
     if (!record) {
       record = {
         country: this.DEFAULT_REGION,
       };
     }
-
-    let {addressLevel1Options} = this.getFormFormat(record.country);
-    this.populateAddressLevel1(addressLevel1Options, record.country);
-
     super.loadRecord(record);
-    this.loadAddressLevel1(record["address-level1"], record.country);
     this.formatForm(record.country);
   }
 
   get hasMailingAddressFields() {
     let {addressFields} = this._elements.form.dataset;
     return !addressFields || addressFields.trim().split(/\s+/).includes("mailing-address");
   }
 
@@ -230,17 +223,16 @@ class EditAddress extends EditAutofillFo
    * should be specific to the given country.
    * @param  {string} country
    */
   formatForm(country) {
     const {
       addressLevel3Label,
       addressLevel2Label,
       addressLevel1Label,
-      addressLevel1Options,
       postalCodeLabel,
       fieldsOrder: mailingFieldsOrder,
       postalCodePattern,
       countryRequiredFields,
     } = this.getFormFormat(country);
     this._elements.addressLevel3Label.dataset.localization = addressLevel3Label;
     this._elements.addressLevel2Label.dataset.localization = addressLevel2Label;
     this._elements.addressLevel1Label.dataset.localization = addressLevel1Label;
@@ -251,17 +243,16 @@ class EditAddress extends EditAutofillFo
     let requiredFields = new Set(countryRequiredFields);
     if (extraRequiredFields) {
       for (let extraRequiredField of extraRequiredFields.trim().split(/\s+/)) {
         requiredFields.add(extraRequiredField);
       }
     }
     this.arrangeFields(fieldClasses, requiredFields);
     this.updatePostalCodeValidation(postalCodePattern);
-    this.populateAddressLevel1(addressLevel1Options, country);
   }
 
   /**
    * Update address field visibility and order based on libaddressinput data.
    *
    * @param {object[]} fieldsOrder array of objects with `fieldId` and optional `newLine` properties
    * @param {Set} requiredFields Set of `fieldId` strings that mark which fields are required
    */
@@ -322,95 +313,16 @@ class EditAddress extends EditAutofillFo
     let postalCodeInput = this._elements.form.querySelector("#postal-code");
     if (postalCodePattern && postalCodeInput.style.display != "none") {
       postalCodeInput.setAttribute("pattern", postalCodePattern);
     } else {
       postalCodeInput.removeAttribute("pattern");
     }
   }
 
-  /**
-   * Set the address-level1 value on the form field (input or select, whichever is present).
-   *
-   * @param {string} addressLevel1Value Value of the address-level1 from the autofill record
-   * @param {string} country The corresponding country
-   */
-  loadAddressLevel1(addressLevel1Value, country) {
-    let field = this._elements.form.querySelector("#address-level1");
-
-    if (field.localName == "input") {
-      field.value = addressLevel1Value || "";
-      return;
-    }
-
-    let matchedSelectOption = this.findAddressSelectOption(field, {
-      country,
-      "address-level1": addressLevel1Value,
-    }, "address-level1");
-    if (matchedSelectOption && !matchedSelectOption.selected) {
-      field.value = matchedSelectOption.value;
-      field.dispatchEvent(new Event("input", {bubbles: true}));
-      field.dispatchEvent(new Event("change", {bubbles: true}));
-    } else if (addressLevel1Value) {
-      // If the option wasn't found, insert an option at the beginning of
-      // the select that matches the stored value.
-      field.insertBefore(new Option(addressLevel1Value, addressLevel1Value, true, true), field.firstChild);
-    }
-  }
-
-  /**
-   * Replace the text input for address-level1 with a select dropdown if
-   * a fixed set of names exists. Otherwise show a text input.
-   *
-   * @param {Map?} options Map of options with regionCode -> name mappings
-   * @param {string} country The corresponding country
-   */
-  populateAddressLevel1(options, country) {
-    let field = this._elements.form.querySelector("#address-level1");
-
-    if (field.dataset.country == country) {
-      return;
-    }
-
-    if (!options) {
-      if (field.localName == "input") {
-        return;
-      }
-
-      let input = document.createElement("input");
-      input.setAttribute("type", "text");
-      input.id = "address-level1";
-      input.required = field.required;
-      input.disabled = field.disabled;
-      input.tabIndex = field.tabIndex;
-      field.replaceWith(input);
-      return;
-    }
-
-    if (field.localName == "input") {
-      let select = document.createElement("select");
-      select.id = "address-level1";
-      select.required = field.required;
-      select.disabled = field.disabled;
-      select.tabIndex = field.tabIndex;
-      field.replaceWith(select);
-      field = select;
-    }
-
-    field.textContent = "";
-    field.dataset.country = country;
-    let fragment = document.createDocumentFragment();
-    fragment.appendChild(new Option(undefined, undefined, true, true));
-    for (let [regionCode, regionName] of options) {
-      let option = new Option(regionName, regionCode);
-      fragment.appendChild(option);
-    }
-    field.appendChild(fragment);
-  }
-
   populateCountries() {
     let fragment = document.createDocumentFragment();
     // Sort countries by their visible names.
     let countries = [...this.countries.entries()].sort((e1, e2) => e1[1].localeCompare(e2[1]));
     for (let country of countries) {
       let option = new Option();
       option.value = country[0];
       option.dataset.localizationRegion = country[0].toLowerCase();
--- a/browser/extensions/formautofill/content/editAddress.xhtml
+++ b/browser/extensions/formautofill/content/editAddress.xhtml
@@ -48,19 +48,16 @@
       <input id="address-level3" type="text"/>
       <span class="label-text"/>
     </label>
     <label id="address-level2-container" class="container">
       <input id="address-level2" type="text"/>
       <span class="label-text"/>
     </label>
     <label id="address-level1-container" class="container">
-      <!-- The address-level1 input will get replaced by a select dropdown
-           by autofillEditForms.js when the selected country has provided
-           specific options. -->
       <input id="address-level1" type="text"/>
       <span class="label-text"/>
     </label>
     <label id="postal-code-container" class="container">
       <input id="postal-code" type="text"/>
       <span class="label-text"/>
     </label>
     <label id="country-container" class="container">
@@ -87,31 +84,29 @@
     "use strict";
 
     let {
       DEFAULT_REGION,
       countries,
     } = FormAutofill;
     let {
       getFormFormat,
-      findAddressSelectOption,
     } = FormAutofillUtils;
     let args = window.arguments || [];
     let {
       record,
       noValidate,
     } = args[0] || {};
 
     /* import-globals-from autofillEditForms.js */
     var fieldContainer = new EditAddress({
       form: document.getElementById("form"),
     }, record, {
       DEFAULT_REGION,
       getFormFormat: getFormFormat.bind(FormAutofillUtils),
-      findAddressSelectOption: findAddressSelectOption.bind(FormAutofillUtils),
       countries,
       noValidate,
     });
 
     /* import-globals-from editDialog.js */
     new EditAddressDialog({
       title: document.querySelector("title"),
       fieldContainer,
--- a/browser/extensions/formautofill/content/editDialog.js
+++ b/browser/extensions/formautofill/content/editDialog.js
@@ -20,17 +20,16 @@ class AutofillEditDialog {
     this._subStorageName = subStorageName;
     this._elements = elements;
     this._record = record;
     this.localizeDocument();
     window.addEventListener("DOMContentLoaded", this, {once: true});
   }
 
   async init() {
-    this.updateSaveButtonState();
     this.attachEventListeners();
     // For testing only: signal to tests that the dialog is ready for testing.
     // This is likely no longer needed since retrieving from storage is fully
     // handled in manageDialog.js now.
     window.dispatchEvent(new CustomEvent("FormReady"));
   }
 
   /**
@@ -104,40 +103,36 @@ class AutofillEditDialog {
   }
 
   /**
    * Handle input events
    *
    * @param  {DOMEvent} event
    */
   handleInput(event) {
-    this.updateSaveButtonState();
+    // Toggle disabled attribute on the save button based on
+    // whether the form is filled or empty.
+    if (Object.keys(this._elements.fieldContainer.buildFormObject()).length == 0) {
+      this._elements.save.setAttribute("disabled", true);
+    } else {
+      this._elements.save.removeAttribute("disabled");
+    }
   }
 
   /**
    * Handle key press events
    *
    * @param  {DOMEvent} event
    */
   handleKeyPress(event) {
     if (event.keyCode == KeyEvent.DOM_VK_ESCAPE) {
       window.close();
     }
   }
 
-  updateSaveButtonState() {
-    // Toggle disabled attribute on the save button based on
-    // whether the form is filled or empty.
-    if (Object.keys(this._elements.fieldContainer.buildFormObject()).length == 0) {
-      this._elements.save.setAttribute("disabled", true);
-    } else {
-      this._elements.save.removeAttribute("disabled");
-    }
-  }
-
   /**
    * Attach event listener
    */
   attachEventListeners() {
     window.addEventListener("keypress", this);
     window.addEventListener("contextmenu", this);
     this._elements.controlsContainer.addEventListener("click", this);
     document.addEventListener("input", this);
--- a/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js
+++ b/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js
@@ -51,17 +51,17 @@ add_task(async function test_saveAddress
   await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
     let doc = win.document;
     // Verify labels
     is(doc.querySelector("#address-level1-container > .label-text").textContent, "State",
                          "US address-level1 label should be 'State'");
     is(doc.querySelector("#postal-code-container > .label-text").textContent, "ZIP Code",
                          "US postal-code label should be 'ZIP Code'");
     // Input address info and verify move through form with tab keys
-    const keypresses = [
+    const keyInputs = [
       "VK_TAB",
       TEST_ADDRESS_1["given-name"],
       "VK_TAB",
       TEST_ADDRESS_1["additional-name"],
       "VK_TAB",
       TEST_ADDRESS_1["family-name"],
       "VK_TAB",
       TEST_ADDRESS_1["street-address"],
@@ -78,86 +78,47 @@ add_task(async function test_saveAddress
       "VK_TAB",
       TEST_ADDRESS_1.tel,
       "VK_TAB",
       TEST_ADDRESS_1.email,
       "VK_TAB",
       "VK_TAB",
       "VK_RETURN",
     ];
-    keypresses.forEach(keypress => {
-      if (doc.activeElement.localName == "select" && !keypress.startsWith("VK_")) {
-        let field = doc.activeElement;
-        while (field.value != keypress) {
-          EventUtils.synthesizeKey(keypress[0], {}, win);
-        }
-      } else {
-        EventUtils.synthesizeKey(keypress, {}, win);
-      }
-    });
+    keyInputs.forEach(input => EventUtils.synthesizeKey(input, {}, win));
   });
   let addresses = await getAddresses();
 
   is(addresses.length, 1, "only one address is in storage");
   is(Object.keys(TEST_ADDRESS_1).length, 11, "Sanity check number of properties");
   for (let [fieldName, fieldValue] of Object.entries(TEST_ADDRESS_1)) {
     is(addresses[0][fieldName], fieldValue, "check " + fieldName);
   }
 });
 
 add_task(async function test_editAddress() {
   let addresses = await getAddresses();
   await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey("VK_RIGHT", {}, win);
     EventUtils.synthesizeKey("test", {}, win);
-
-    let stateSelect = win.document.querySelector("#address-level1");
-    is(stateSelect.selectedOptions[0].value, TEST_ADDRESS_1["address-level1"],
-       "address-level1 should be selected in the dropdown");
-
     win.document.querySelector("#save").click();
   }, {
     record: addresses[0],
   });
   addresses = await getAddresses();
 
   is(addresses.length, 1, "only one address is in storage");
   is(addresses[0]["given-name"], TEST_ADDRESS_1["given-name"] + "test", "given-name changed");
   await removeAddresses([addresses[0].guid]);
 
   addresses = await getAddresses();
   is(addresses.length, 0, "Address storage is empty");
 });
 
-add_task(async function test_editAddressFrenchCanadianChangedToEnglishRepresentation() {
-  let addressClone = Object.assign({}, TEST_ADDRESS_CA_1);
-  addressClone["address-level1"] = "Colombie-Britannique";
-  await saveAddress(addressClone);
-
-  let addresses = await getAddresses();
-  await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
-    let stateSelect = win.document.querySelector("#address-level1");
-    is(stateSelect.selectedOptions[0].value, "BC",
-       "address-level1 should have 'BC' selected in the dropdown");
-
-    win.document.querySelector("#save").click();
-  }, {
-    record: addresses[0],
-  });
-  addresses = await getAddresses();
-
-  is(addresses.length, 1, "only one address is in storage");
-  is(addresses[0]["address-level1"], "BC", "address-level1 changed");
-  await removeAddresses([addresses[0].guid]);
-
-  addresses = await getAddresses();
-  is(addresses.length, 0, "Address storage is empty");
-});
-
 add_task(async function test_editSparseAddress() {
   let record = {...TEST_ADDRESS_1};
   info("delete some usually required properties");
   delete record["street-address"];
   delete record["address-level1"];
   delete record["address-level2"];
   await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
     is(win.document.querySelectorAll(":-moz-ui-invalid").length, 0,
@@ -328,32 +289,32 @@ add_task(async function test_saveAddress
 
   let addresses = await getAddresses();
   for (let [fieldName, fieldValue] of Object.entries(TEST_ADDRESS_IE_1)) {
     is(addresses[0][fieldName], fieldValue, "check " + fieldName);
   }
   await removeAllRecords();
 });
 
-add_task(async function test_countryAndStateFieldLabels() {
+add_task(async function test_countryFieldLabels() {
   await testDialog(EDIT_ADDRESS_DIALOG_URL, async win => {
     let doc = win.document;
     // Change country to verify labels
     doc.querySelector("#country").focus();
 
     let mutatableLabels = [
       "postal-code-container",
       "address-level1-container",
       "address-level2-container",
       "address-level3-container",
     ].map(containerID => doc.getElementById(containerID).querySelector(":scope > .label-text"));
 
     for (let countryOption of doc.querySelector("#country").options) {
       if (countryOption.value == "") {
-        info("Skipping the empty country option");
+        info("Skipping the empty option");
         continue;
       }
 
       // Clear L10N attributes and textContent to not leave leftovers between country tests
       for (let labelEl of mutatableLabels) {
         labelEl.textContent = "";
         delete labelEl.dataset.localization;
       }
@@ -368,41 +329,16 @@ add_task(async function test_countryAndS
                                            "Wait for label to be populated by the mutation observer",
                                            10);
         }
         isnot(labelEl.textContent, "",
               "Ensure textContent is non-empty for: " + countryOption.value);
         is(labelEl.dataset.localization, undefined,
            "Ensure data-localization was removed: " + countryOption.value);
       }
-
-      let stateOptions = doc.querySelector("#address-level1").options;
-      /* eslint-disable max-len */
-      let expectedStateOptions = {
-        "BS": {
-          // The Bahamas is an interesting testcase because they have some keys that are full names, and others are replaced with ISO IDs.
-          "keys": "Abaco~AK~Andros~BY~BI~CI~Crooked Island~Eleuthera~EX~Grand Bahama~HI~IN~LI~MG~N.P.~RI~RC~SS~SW".split("~"),
-          "names": "Abaco Islands~Acklins~Andros Island~Berry Islands~Bimini~Cat Island~Crooked Island~Eleuthera~Exuma and Cays~Grand Bahama~Harbour Island~Inagua~Long Island~Mayaguana~New Providence~Ragged Island~Rum Cay~San Salvador~Spanish Wells".split("~"),
-        },
-        "US": {
-          "keys": "AL~AK~AS~AZ~AR~AA~AE~AP~CA~CO~CT~DE~DC~FL~GA~GU~HI~ID~IL~IN~IA~KS~KY~LA~ME~MH~MD~MA~MI~FM~MN~MS~MO~MT~NE~NV~NH~NJ~NM~NY~NC~ND~MP~OH~OK~OR~PW~PA~PR~RI~SC~SD~TN~TX~UT~VT~VI~VA~WA~WV~WI~WY".split("~"),
-          "names": "Alabama~Alaska~American Samoa~Arizona~Arkansas~Armed Forces (AA)~Armed Forces (AE)~Armed Forces (AP)~California~Colorado~Connecticut~Delaware~District of Columbia~Florida~Georgia~Guam~Hawaii~Idaho~Illinois~Indiana~Iowa~Kansas~Kentucky~Louisiana~Maine~Marshall Islands~Maryland~Massachusetts~Michigan~Micronesia~Minnesota~Mississippi~Missouri~Montana~Nebraska~Nevada~New Hampshire~New Jersey~New Mexico~New York~North Carolina~North Dakota~Northern Mariana Islands~Ohio~Oklahoma~Oregon~Palau~Pennsylvania~Puerto Rico~Rhode Island~South Carolina~South Dakota~Tennessee~Texas~Utah~Vermont~Virgin Islands~Virginia~Washington~West Virginia~Wisconsin~Wyoming".split("~"),
-        },
-      };
-      /* eslint-enable max-len */
-
-      if (expectedStateOptions[countryOption.value]) {
-        let {keys, names} = expectedStateOptions[countryOption.value];
-        is(stateOptions.length, keys.length + 1, "stateOptions should list all options plus a blank entry");
-        is(stateOptions[0].value, "", "First State option should be blank");
-        for (let i = 1; i < stateOptions.length; i++) {
-          is(stateOptions[i].value, keys[i - 1], "Each State should be listed in alphabetical name order (key)");
-          is(stateOptions[i].text, names[i - 1], "Each State should be listed in alphabetical name order (name)");
-        }
-      }
     }
 
     doc.querySelector("#cancel").click();
   });
 });
 
 add_task(async function test_combined_name_fields() {
   await testDialog(EDIT_ADDRESS_DIALOG_URL, async win => {
@@ -513,19 +449,17 @@ add_task(async function test_hiddenField
 add_task(async function test_hiddenFieldRemovedWhenCountryChanged() {
   let addresses = await getAddresses();
   ok(!addresses.length, "no addresses at start of test");
   await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
     let doc = win.document;
     doc.querySelector("#address-level2").focus();
     EventUtils.synthesizeKey(TEST_ADDRESS_1["address-level2"], {}, win);
     doc.querySelector("#address-level1").focus();
-    while (doc.querySelector("#address-level1").value != TEST_ADDRESS_1["address-level1"]) {
-      EventUtils.synthesizeKey(TEST_ADDRESS_1["address-level1"][0], {}, win);
-    }
+    EventUtils.synthesizeKey(TEST_ADDRESS_1["address-level1"], {}, win);
     doc.querySelector("#save").focus();
     EventUtils.synthesizeKey("VK_RETURN", {}, win);
   });
   addresses = await getAddresses();
   is(addresses[0].country, "US", "check country");
   is(addresses[0]["address-level2"], TEST_ADDRESS_1["address-level2"], "check address-level2");
   is(addresses[0]["address-level1"], TEST_ADDRESS_1["address-level1"], "check address-level1");
 
@@ -557,28 +491,26 @@ add_task(async function test_countrySpec
     ok(provinceField.disabled, "address-level1 should be marked as disabled");
     is(provinceField.parentNode.style.display, "none",
        "address-level1 is hidden for Romania");
 
     doc.querySelector("#country").focus();
     EventUtils.synthesizeKey("United States", {}, win);
 
     await TestUtils.waitForCondition(() => {
-      provinceField = doc.getElementById("address-level1");
       return provinceField.parentNode.style.display != "none";
     }, "Wait for address-level1 to become visible", 10);
 
     ok(provinceField.required, "address-level1 should be marked as required");
     ok(!provinceField.disabled, "address-level1 should not be marked as disabled");
 
     doc.querySelector("#country").focus();
     EventUtils.synthesizeKey("Romania", {}, win);
 
     await TestUtils.waitForCondition(() => {
-      provinceField = doc.getElementById("address-level1");
       return provinceField.parentNode.style.display == "none";
     }, "Wait for address-level1 to become hidden", 10);
 
     ok(provinceField.required, "address-level1 will still be marked as required");
     ok(provinceField.disabled, "address-level1 should be marked as disabled");
 
     doc.querySelector("#cancel").click();
   });