Backed out changeset 3df92480890e (bug 1495122) as it was requested by the dev on irc
authorshindli <shindli@mozilla.com>
Thu, 15 Nov 2018 23:13:12 +0200
changeset 503100 fa108f29df87ab02f5de32132da35184cdd03ead
parent 503099 3df92480890e8a4b7f63fdff91cc704707a06d85
child 503101 081704356a9370001159c8bed0d554b738d5c622
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1495122
milestone65.0a1
backs out3df92480890e8a4b7f63fdff91cc704707a06d85
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 3df92480890e (bug 1495122) as it was requested by the dev on irc
browser/components/payments/content/paymentDialogWrapper.js
browser/components/payments/res/containers/address-form.js
browser/components/payments/res/debugging.js
browser/components/payments/res/unprivileged-fallbacks.js
browser/components/payments/test/PaymentTestUtils.jsm
browser/components/payments/test/browser/browser_shippingaddresschange_error.js
browser/components/payments/test/mochitest/test_address_form.html
--- a/browser/components/payments/content/paymentDialogWrapper.js
+++ b/browser/components/payments/content/paymentDialogWrapper.js
@@ -134,34 +134,25 @@ var paymentDialogWrapper = {
   async _convertProfileAddressToPaymentAddress(guid) {
     let addressData = this.temporaryStore.addresses.get(guid) ||
                       await formAutofillStorage.addresses.get(guid);
     if (!addressData) {
       throw new Error(`Address not found: ${guid}`);
     }
 
     let address = this.createPaymentAddress({
+      country: addressData.country,
       addressLines: addressData["street-address"].split("\n"),
-      city: addressData["address-level2"],
-      country: addressData.country,
-      dependentLocality: addressData["address-level3"],
-      organization: addressData.organization,
-      phone: addressData.tel,
-      postalCode: addressData["postal-code"],
-      recipient: addressData.name,
       region: addressData["address-level1"],
-      // TODO (bug 1474905), The regionCode will be available when bug 1474905 is fixed
-      // and the region text box is changed to a dropdown with the regionCode being the
-      // value of the option and the region being the label for the option.
-      // A regionCode should be either the empty string or one to three code points
-      // that represent a region as the code element of an [ISO3166-2] country subdivision
-      // name (i.e., the characters after the hyphen in an ISO3166-2 country subdivision
-      // code element, such as "CA" for the state of California in the USA, or "11" for
-      // the Lisbon district of Portugal).
-      regionCode: "",
+      city: addressData["address-level2"],
+      dependentLocality: addressData["address-level3"],
+      postalCode: addressData["postal-code"],
+      organization: addressData.organization,
+      recipient: addressData.name,
+      phone: addressData.tel,
     });
 
     return address;
   },
 
   /**
    * @param {string} guid The GUID of the basic card record from storage.
    * @param {string} cardSecurityCode The associated card security code (CVV/CCV/etc.)
@@ -305,27 +296,27 @@ var paymentDialogWrapper = {
                                    expiryMonth,
                                    expiryYear,
                                    cardSecurityCode,
                                    billingAddress);
     return basicCardResponseData;
   },
 
   createPaymentAddress({
+    country = "",
     addressLines = [],
-    city = "",
-    country = "",
-    dependentLocality = "",
-    organization = "",
-    postalCode = "",
-    phone = "",
-    recipient = "",
     region = "",
     regionCode = "",
+    city = "",
+    dependentLocality = "",
+    postalCode = "",
     sortingCode = "",
+    organization = "",
+    recipient = "",
+    phone = "",
   }) {
     const paymentAddress = Cc["@mozilla.org/dom/payments/payment-address;1"]
                            .createInstance(Ci.nsIPaymentAddress);
     const addressLine = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
     for (let line of addressLines) {
       const address = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
       address.data = line;
       addressLine.appendElement(address);
--- a/browser/components/payments/res/containers/address-form.js
+++ b/browser/components/payments/res/containers/address-form.js
@@ -43,33 +43,29 @@ export default class AddressForm extends
     this.persistCheckbox = new LabelledCheckbox();
     this.persistCheckbox.className = "persist-checkbox";
 
     // Combination of AddressErrors and PayerErrors as keys
     this._errorFieldMap = {
       addressLine: "#street-address",
       city: "#address-level2",
       country: "#country",
-      dependentLocality: "#address-level3",
       email: "#email",
       // Bug 1472283 is on file to support
       // additional-name and family-name.
       // XXX: For now payer name errors go on the family-name and address-errors
       //      go on the given-name so they don't overwrite each other.
       name: "#family-name",
       organization: "#organization",
       phone: "#tel",
       postalCode: "#postal-code",
       // Bug 1472283 is on file to support
       // additional-name and family-name.
       recipient: "#given-name",
       region: "#address-level1",
-      // Bug 1474905 is on file to properly support regionCode. See
-      // full note in paymentDialogWrapper.js
-      regionCode: "#address-level1",
     };
 
     // The markup is shared with form autofill preferences.
     let url = "formautofill/editAddress.xhtml";
     this.promiseReady = this._fetchMarkup(url).then(doc => {
       this.form = doc.getElementById("form");
       return this.form;
     });
@@ -192,27 +188,20 @@ export default class AddressForm extends
 
     // Add validation to some address fields
     this.updateRequiredState();
 
     // Show merchant errors for the appropriate address form.
     let merchantFieldErrors = AddressForm.merchantFieldErrorsForForm(state,
                                                                      addressPage.selectedStateKey);
     for (let [errorName, errorSelector] of Object.entries(this._errorFieldMap)) {
-      let errorText = "";
-      // Never show errors on an 'add' screen as they would be for a different address.
-      if (editing && merchantFieldErrors) {
-        if (errorName == "region" || errorName == "regionCode") {
-          errorText = merchantFieldErrors.region || merchantFieldErrors.regionCode || "";
-        } else {
-          errorText = merchantFieldErrors[errorName] || "";
-        }
-      }
       let container = this.form.querySelector(errorSelector + "-container");
       let field = this.form.querySelector(errorSelector);
+      // Never show errors on an 'add' screen as they would be for a different address.
+      let errorText = (editing && merchantFieldErrors && merchantFieldErrors[errorName]) || "";
       field.setCustomValidity(errorText);
       let span = paymentRequest.maybeCreateFieldErrorElement(container);
       span.textContent = errorText;
     }
 
     this.updateSaveButtonState();
   }
 
--- a/browser/components/payments/res/debugging.js
+++ b/browser/components/payments/res/debugging.js
@@ -254,31 +254,16 @@ let ADDRESSES_1 = {
     "given-name": "Kristin",
     "guid": "missing-country",
     "name": "Kristin Bogard",
     "postal-code": "H0H 0H0",
     "street-address": "123 Yonge Street\nSuite 2300",
     "tel": "+1 416 555-5555",
     timeLastUsed: 90000,
   },
-  TimBR: {
-    "given-name": "Timothy",
-    "additional-name": "João",
-    "family-name": "Berners-Lee",
-    organization: "World Wide Web Consortium",
-    "street-address": "Rua Adalberto Pajuaba, 404",
-    "address-level3": "Campos Elísios",
-    "address-level2": "Ribeirão Preto",
-    "address-level1": "SP",
-    "postal-code": "14055-220",
-    country: "BR",
-    tel: "+0318522222222",
-    email: "timbr@example.org",
-    timeLastUsed: 110000,
-  },
 };
 
 let DUPED_ADDRESSES = {
   "a9e830667189": {
     "street-address": "Unit 1\n1505 Northeast Kentucky Industrial Parkway \n",
     "address-level2": "Greenup",
     "address-level1": "KY",
     "postal-code": "41144",
@@ -492,23 +477,21 @@ let buttonActions = {
       cardholderName: "",
       cardSecurityCode: "",
       expiryMonth: "",
       expiryYear: "",
       billingAddress: {
         addressLine: "Can only buy from ROADS, not DRIVES, BOULEVARDS, or STREETS",
         city: "Can only buy from CITIES, not TOWNSHIPS or VILLAGES",
         country: "Can only buy from US, not CA",
-        dependentLocality: "Can only be SUBURBS, not NEIGHBORHOODS",
         organization: "Can only buy from CORPORATIONS, not CONSORTIUMS",
         phone: "Only allowed to buy from area codes that start with 9",
         postalCode: "Only allowed to buy from postalCodes that start with 0",
         recipient: "Can only buy from names that start with J",
         region: "Can only buy from regions that start with M",
-        regionCode: "Regions must be 1 to 3 characters in length",
       },
     };
     requestStore.setState({
       request,
     });
   },
 
 
@@ -585,23 +568,21 @@ let buttonActions = {
 
   setShippingAddressErrors() {
     let request = Object.assign({}, requestStore.getState().request);
     request.paymentDetails = Object.assign({}, requestStore.getState().request.paymentDetails);
     request.paymentDetails.shippingAddressErrors = {
       addressLine: "Can only ship to ROADS, not DRIVES, BOULEVARDS, or STREETS",
       city: "Can only ship to CITIES, not TOWNSHIPS or VILLAGES",
       country: "Can only ship to USA, not CA",
-      dependentLocality: "Can only be SUBURBS, not NEIGHBORHOODS",
       organization: "Can only ship to CORPORATIONS, not CONSORTIUMS",
       phone: "Only allowed to ship to area codes that start with 9",
       postalCode: "Only allowed to ship to postalCodes that start with 0",
       recipient: "Can only ship to names that start with J",
       region: "Can only ship to regions that start with M",
-      regionCode: "Regions must be 1 to 3 characters in length",
     };
     requestStore.setState({
       request,
     });
   },
 
   toggleDirectionality() {
     let body = paymentDialog.ownerDocument.body;
--- a/browser/components/payments/res/unprivileged-fallbacks.js
+++ b/browser/components/payments/res/unprivileged-fallbacks.js
@@ -74,34 +74,29 @@ var PaymentDialogUtils = {
           {fieldId: "postal-code"},
           {fieldId: "address-level2"},
         ],
         postalCodePattern: "\\d{5}",
         countryRequiredFields: ["street-address", "address-level2", "postal-code"],
       };
     }
 
-    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",
       postalCodeLabel: country == "US" ? "zip" : "postalCode",
-      fieldsOrder,
+      fieldsOrder: [
+        {fieldId: "name", newLine: true},
+        {fieldId: "street-address", newLine: true},
+        {fieldId: "address-level2"},
+        {fieldId: "address-level1"},
+        {fieldId: "postal-code"},
+        {fieldId: "organization"},
+      ],
       // 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"],
     };
   },
--- a/browser/components/payments/test/PaymentTestUtils.jsm
+++ b/browser/components/payments/test/PaymentTestUtils.jsm
@@ -462,23 +462,21 @@ var PaymentTestUtils = {
       error: "Cannot ship with option 1 on days that end with Y",
     },
     fieldSpecificErrors: {
       error: "There are errors related to specific parts of the address",
       shippingAddressErrors: {
         addressLine: "Can only ship to ROADS, not DRIVES, BOULEVARDS, or STREETS",
         city: "Can only ship to CITIES, not TOWNSHIPS or VILLAGES",
         country: "Can only ship to USA, not CA",
-        dependentLocality: "Can only be SUBURBS, not NEIGHBORHOODS",
         organization: "Can only ship to CORPORATIONS, not CONSORTIUMS",
         phone: "Only allowed to ship to area codes that start with 9",
         postalCode: "Only allowed to ship to postalCodes that start with 0",
         recipient: "Can only ship to names that start with J",
         region: "Can only ship to regions that start with M",
-        regionCode: "Regions must be 1 to 3 characters in length (sometimes ;) )",
       },
     },
   },
 
   Options: {
     requestShippingOption: {
       requestShipping: true,
     },
@@ -489,30 +487,16 @@ var PaymentTestUtils = {
     requestPayerNameEmailAndPhone: {
       requestPayerName: true,
       requestPayerEmail: true,
       requestPayerPhone: true,
     },
   },
 
   Addresses: {
-    TimBR: {
-      "given-name": "Timothy",
-      "additional-name": "João",
-      "family-name": "Berners-Lee",
-      organization: "World Wide Web Consortium",
-      "street-address": "Rua Adalberto Pajuaba, 404",
-      "address-level3": "Campos Elísios",
-      "address-level2": "Ribeirão Preto",
-      "address-level1": "SP",
-      "postal-code": "14055-220",
-      country: "BR",
-      tel: "+0318522222222",
-      email: "timbr@example.org",
-    },
     TimBL: {
       "given-name": "Timothy",
       "additional-name": "John",
       "family-name": "Berners-Lee",
       organization: "World Wide Web Consortium",
       "street-address": "32 Vassar Street\nMIT Room 32-G524",
       "address-level2": "Cambridge",
       "address-level1": "MA",
--- a/browser/components/payments/test/browser/browser_shippingaddresschange_error.js
+++ b/browser/components/payments/test/browser/browser_shippingaddresschange_error.js
@@ -121,24 +121,21 @@ add_task(async function test_show_field_
 
       await PTU.DialogContentUtils.waitForState(content, (state) => {
         return state.page.id == "address-page" && state["address-page"].guid;
       }, "Check edit page state");
 
       // check errors and make corrections
       let {shippingAddressErrors} = PTU.Details.fieldSpecificErrors;
       is(content.document.querySelectorAll("address-form .error-text:not(:empty)").length,
-         Object.keys(shippingAddressErrors).length - 1,
-         "Each error should be presented, but region and regionCode are combined");
+         Object.keys(shippingAddressErrors).length,
+         "Each error should be presented");
       let errorFieldMap =
         Cu.waiveXrays(content.document.querySelector("address-form"))._errorFieldMap;
       for (let [errorName, errorValue] of Object.entries(shippingAddressErrors)) {
-        if (errorName == "region" || errorName == "regionCode") {
-          errorValue = shippingAddressErrors.region + " " + shippingAddressErrors.regionCode;
-        }
         let fieldSelector = errorFieldMap[errorName];
         let containerSelector = fieldSelector + "-container";
         let container = content.document.querySelector(containerSelector);
         try {
           is(container.querySelector(".error-text").textContent, errorValue,
              "Field specific error should be associated with " + errorName);
         } catch (ex) {
           ok(false, `no container for ${errorName}. selector= ${containerSelector}`);
--- a/browser/components/payments/test/mochitest/test_address_form.html
+++ b/browser/components/payments/test/mochitest/test_address_form.html
@@ -405,17 +405,17 @@ add_task(async function test_field_valid
   form.remove();
 });
 
 add_task(async function test_merchantShippingAddressErrors() {
   let form = new AddressForm();
   await form.promiseReady;
 
   // Merchant errors only make sense when editing a record so add one.
-  let address1 = deepClone(PTU.Addresses.TimBR);
+  let address1 = deepClone(PTU.Addresses.TimBL);
   address1.guid = "9864798564";
 
   const state = {
     page: {
       id: "address-page",
     },
     "address-page": {
       guid: address1.guid,
@@ -423,57 +423,48 @@ add_task(async function test_merchantShi
       title: "Sample page title",
     },
     request: {
       paymentDetails: {
         shippingAddressErrors: {
           addressLine: "Street address needs to start with a D",
           city: "City needs to start with a B",
           country: "Country needs to start with a C",
-          dependentLocality: "Can only be SUBURBS, not NEIGHBORHOODS",
           organization: "organization needs to start with an A",
           phone: "Telephone needs to start with a 9",
           postalCode: "Postal code needs to start with a 0",
           recipient: "Name needs to start with a Z",
           region: "Region needs to start with a Y",
-          regionCode: "Regions must be 1 to 3 characters in length (sometimes ;) )",
         },
       },
     },
     savedAddresses: {
       [address1.guid]: deepClone(address1),
     },
   };
   await form.requestStore.setState(state);
   display.appendChild(form);
   await asyncElementRendered();
 
   function checkValidationMessage(selector, property) {
-    let expected = state.request.paymentDetails.shippingAddressErrors[property];
-    let container = form.form.querySelector(selector + "-container");
-    ok(!isHidden(container), selector + "-container should be visible");
     is(form.form.querySelector(selector).validationMessage,
-       expected,
+       state.request.paymentDetails.shippingAddressErrors[property],
        "Validation message should match for " + selector);
   }
 
   ok(form.saveButton.disabled, "Save button should be disabled due to validation errors");
 
   checkValidationMessage("#street-address", "addressLine");
   checkValidationMessage("#address-level2", "city");
-  checkValidationMessage("#address-level3", "dependentLocality");
   checkValidationMessage("#country", "country");
   checkValidationMessage("#organization", "organization");
   checkValidationMessage("#tel", "phone");
   checkValidationMessage("#postal-code", "postalCode");
   checkValidationMessage("#given-name", "recipient");
   checkValidationMessage("#address-level1", "region");
-  isnot(form.form.querySelector("#address-level1"),
-        state.request.paymentDetails.shippingAddressErrors.regionCode,
-        "When both region and regionCode are supplied we only show the 'region' error");
 
   // TODO: bug 1482808 - the save button should be enabled after editing the fields
 
   form.remove();
 });
 
 add_task(async function test_customMerchantValidity_reset() {
   let form = new AddressForm();