Bug 1509147 - Rename payer and paymentMethod on nsIPaymentDetails to payerErrors and paymentMethodErrors respectively r=baku
authorDiego Pino Garcia <dpino@igalia.com>
Mon, 26 Nov 2018 03:08:00 +0200
changeset 448221 e9a02a8a62e5ee81c00ff7cff86744cc0f4d4e41
parent 448220 deb83c7936386cd93471ee58e300a2e561782295
child 448222 3d330442ef3b3beddb0e71a95573e5cce49207dc
push id110146
push userrmaries@mozilla.com
push dateTue, 27 Nov 2018 15:17:32 +0000
treeherdermozilla-inbound@e9a02a8a62e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1509147
milestone65.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 1509147 - Rename payer and paymentMethod on nsIPaymentDetails to payerErrors and paymentMethodErrors respectively r=baku
browser/components/payments/res/containers/address-form.js
browser/components/payments/res/debugging.js
browser/components/payments/res/mixins/PaymentStateSubscriberMixin.js
browser/components/payments/test/mochitest/test_address_form.html
browser/components/payments/test/mochitest/test_address_picker.html
dom/interfaces/payments/nsIPaymentRequest.idl
dom/payments/PaymentRequestData.cpp
dom/payments/PaymentRequestData.h
dom/payments/test/BasicCardErrorsChromeScript.js
dom/payments/test/PayerDetailsChromeScript.js
dom/payments/test/RetryPaymentChromeScript.js
--- a/browser/components/payments/res/containers/address-form.js
+++ b/browser/components/payments/res/containers/address-form.js
@@ -407,22 +407,22 @@ export default class AddressForm extends
    */
   static merchantFieldErrorsForForm(state, stateKey) {
     let {paymentDetails} = state.request;
     switch (stateKey.join("|")) {
       case "selectedShippingAddress": {
         return paymentDetails.shippingAddressErrors;
       }
       case "selectedPayerAddress": {
-        return paymentDetails.payer;
+        return paymentDetails.payerErrors;
       }
       case "basic-card-page|billingAddressGUID": {
         // `paymentMethod` can be null.
-        return (paymentDetails.paymentMethod
-                && paymentDetails.paymentMethod.billingAddress) || {};
+        return (paymentDetails.paymentMethodErrors
+                && paymentDetails.paymentMethodErrors.billingAddress) || {};
       }
       default: {
         throw new Error("Unknown selectedStateKey");
       }
     }
   }
 }
 
--- a/browser/components/payments/res/debugging.js
+++ b/browser/components/payments/res/debugging.js
@@ -48,18 +48,18 @@ let REQUEST_1 = {
       {
         label: "Square",
         amount: {
           currency: "USD",
           value: "5",
         },
       },
     ],
-    payer: {},
-    paymentMethod: {},
+    payerErrors: {},
+    paymentMethodErrors: {},
     shippingAddressErrors: {},
     shippingOptions: [
       {
         id: "std",
         label: "Standard (3-5 business days)",
         amount: {
           currency: "USD",
           value: 10,
@@ -130,18 +130,18 @@ let REQUEST_2 = {
         label: "Tax",
         type: "tax",
         amount: {
           currency: "USD",
           value: "1.50",
         },
       },
     ],
-    payer: {},
-    paymentMethod: {},
+    payerErrors: {},
+    paymentMethoErrors: {},
     shippingAddressErrors: {},
     shippingOptions: [
       {
         id: "123",
         label: "Fast (default)",
         amount: {
           currency: "USD",
           value: 10,
@@ -482,17 +482,17 @@ let buttonActions = {
 
   setBasicCards1() {
     paymentDialog.setStateFromParent({savedBasicCards: BASIC_CARDS_1});
   },
 
   setBasicCardErrors() {
     let request = Object.assign({}, requestStore.getState().request);
     request.paymentDetails = Object.assign({}, requestStore.getState().request.paymentDetails);
-    request.paymentDetails.paymentMethod = {
+    request.paymentDetails.paymentMethodErrors = {
       cardNumber: "",
       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",
@@ -525,17 +525,17 @@ let buttonActions = {
     paymentDialog.setStateFromParent({
       request: Object.assign({}, request, { completeStatus }),
     });
   },
 
   setPayerErrors() {
     let request = Object.assign({}, requestStore.getState().request);
     request.paymentDetails = Object.assign({}, requestStore.getState().request.paymentDetails);
-    request.paymentDetails.payer = {
+    request.paymentDetails.payerErrors = {
       email: "Only @mozilla.com emails are supported",
       name: "Payer name must start with M",
       phone: "Payer area codes must start with 1",
     };
     requestStore.setState({
       request,
     });
   },
--- a/browser/components/payments/res/mixins/PaymentStateSubscriberMixin.js
+++ b/browser/components/payments/res/mixins/PaymentStateSubscriberMixin.js
@@ -41,18 +41,18 @@ export let requestStore = new PaymentsSt
     tabId: null,
     topLevelPrincipal: {URI: {displayHost: null}},
     requestId: null,
     paymentMethods: [],
     paymentDetails: {
       id: null,
       totalItem: {label: null, amount: {currency: null, value: 0}},
       displayItems: [],
-      payer: {},
-      paymentMethod: null,
+      payerErrors: {},
+      paymentMethodErrors: null,
       shippingAddressErrors: {},
       shippingOptions: [],
       modifiers: null,
       error: "",
     },
     paymentOptions: {
       requestPayerName: false,
       requestPayerEmail: false,
--- a/browser/components/payments/test/mochitest/test_address_form.html
+++ b/browser/components/payments/test/mochitest/test_address_form.html
@@ -703,17 +703,17 @@ add_task(async function test_customMerch
   await asyncElementRendered();
 
   is(form.querySelectorAll(":-moz-ui-invalid").length, 0,
      "Check fields are visibly valid - shipping errors are not relevant to a billing address form");
 
   await form.requestStore.setState({
     request: {
       paymentDetails: {
-        paymentMethod: {
+        paymentMethodErrors: {
           billingAddress: {
             addressLine: "Billing Street address needs to start with a D",
             city: "Billing City needs to start with a B",
             country: "Billing Country needs to start with a C",
             organization: "Billing organization needs to start with an A",
             phone: "Billing Telephone needs to start with a 9",
             postalCode: "Billing Postal code needs to start with a 0",
             recipient: "Billing Name needs to start with a Z",
@@ -748,17 +748,17 @@ add_task(async function test_merchantPay
       id: "payer-address-page",
     },
     "payer-address-page": {
       addressFields: "name email tel",
       guid: address1.guid,
     },
     request: {
       paymentDetails: {
-        payer: {
+        payerErrors: {
           email: "Email must be @mozilla.org",
           name: "Name needs to start with a W",
           phone: "Telephone needs to start with a 1",
         },
       },
       paymentOptions: {},
     },
     savedAddresses: {
@@ -766,32 +766,32 @@ add_task(async function test_merchantPay
     },
   };
   await form.requestStore.setState(state);
   display.appendChild(form);
   await asyncElementRendered();
 
   function checkValidationMessage(selector, property) {
     is(form.form.querySelector(selector).validationMessage,
-       state.request.paymentDetails.payer[property],
+       state.request.paymentDetails.payerErrors[property],
        "Validation message should match for " + selector);
   }
 
   ok(form.saveButton.disabled, "Save button should be disabled due to validation errors");
 
   checkValidationMessage("#tel", "phone");
   checkValidationMessage("#family-name", "name");
   checkValidationMessage("#email", "email");
 
   is(form.querySelectorAll(":-moz-ui-invalid").length, 3, "Check payer fields are visibly invalid");
 
   await form.requestStore.setState({
     request: {
       paymentDetails: {
-        payer: {},
+        payerErrors: {},
       },
       paymentOptions: {},
     },
   });
   await asyncElementRendered();
 
   is(form.querySelectorAll(":-moz-ui-invalid").length, 0,
      "Check payer fields are visibly valid after clearing merchant errors");
--- a/browser/components/payments/test/mochitest/test_address_picker.html
+++ b/browser/components/payments/test/mochitest/test_address_picker.html
@@ -251,20 +251,20 @@ add_task(async function test_merchantErr
   await asyncElementRendered();
   ok(!picker1.classList.contains("invalid-selected-option"),
      "No errors visible when merchant errors cleared");
   ok(isHidden(picker1.invalidLabel), "The invalid label should be hidden");
 
   info("Set billing address and payer errors which aren't relevant to this picker");
   let requestWithNonShippingAddressErrors = deepClone(request);
   Object.assign(requestWithNonShippingAddressErrors.paymentDetails, {
-    payer: {
+    payerErrors: {
       name: "Your name is too short",
     },
-    paymentMethod: {
+    paymentMethodErrors: {
       billingAddress: {
         country: "Your billing country is not supported",
       },
     },
     shippingAddressErrors: {},
   });
   picker1.requestStore.setState({
     request: requestWithNonShippingAddressErrors,
--- a/dom/interfaces/payments/nsIPaymentRequest.idl
+++ b/dom/interfaces/payments/nsIPaymentRequest.idl
@@ -58,19 +58,19 @@ interface nsIPaymentDetails : nsISupport
   readonly attribute nsIPaymentItem totalItem;
   readonly attribute nsIArray displayItems;
   readonly attribute nsIArray shippingOptions;
   readonly attribute nsIArray modifiers;
   readonly attribute AString error;
   [implicit_jscontext]
   readonly attribute jsval shippingAddressErrors;
   [implicit_jscontext]
-  readonly attribute jsval payer;
+  readonly attribute jsval payerErrors;
   [implicit_jscontext]
-  readonly attribute jsval paymentMethod;
+  readonly attribute jsval paymentMethodErrors;
 };
 
 [scriptable, builtinclass, uuid(d53f9f20-138e-47cc-9fd5-db16a3f6d301)]
 interface nsIPaymentOptions : nsISupports
 {
   readonly attribute boolean requestPayerName;
   readonly attribute boolean requestPayerEmail;
   readonly attribute boolean requestPayerPhone;
--- a/dom/payments/PaymentRequestData.cpp
+++ b/dom/payments/PaymentRequestData.cpp
@@ -476,28 +476,28 @@ PaymentDetails::GetShippingAddressErrors
   errors.Init(mShippingAddressErrors);
   if (!ToJSValue(aCx, errors, aErrors)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PaymentDetails::GetPayer(JSContext* aCx, JS::MutableHandleValue aErrors)
+PaymentDetails::GetPayerErrors(JSContext* aCx, JS::MutableHandleValue aErrors)
 {
   PayerErrors errors;
   errors.Init(mPayerErrors);
   if (!ToJSValue(aCx, errors, aErrors)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PaymentDetails::GetPaymentMethod(JSContext* aCx, JS::MutableHandleValue aErrors)
+PaymentDetails::GetPaymentMethodErrors(JSContext* aCx, JS::MutableHandleValue aErrors)
 {
   if (mPaymentMethodErrors.IsEmpty()) {
     aErrors.set(JS::NullValue());
     return NS_OK;
   }
   nsresult rv = DeserializeToJSValue(mPaymentMethodErrors, aCx ,aErrors);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -553,37 +553,37 @@ PaymentDetails::Update(nsIPaymentDetails
   rv = aDetails->GetError(mError);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   PaymentDetails* rowDetails = static_cast<PaymentDetails*>(aDetails);
   MOZ_ASSERT(rowDetails);
   mShippingAddressErrors = rowDetails->GetShippingAddressErrors();
-  mPayerErrors = rowDetails->GetPayer();
-  mPaymentMethodErrors = rowDetails->GetPaymentMethod();
+  mPayerErrors = rowDetails->GetPayerErrors();
+  mPaymentMethodErrors = rowDetails->GetPaymentMethodErrors();
 
   return NS_OK;
 
 }
 
 const nsString&
 PaymentDetails::GetShippingAddressErrors() const
 {
   return mShippingAddressErrors;
 }
 
 const nsString&
-PaymentDetails::GetPayer() const
+PaymentDetails::GetPayerErrors() const
 {
   return mPayerErrors;
 }
 
 const nsString&
-PaymentDetails::GetPaymentMethod() const
+PaymentDetails::GetPaymentMethodErrors() const
 {
   return mPaymentMethodErrors;
 }
 
 nsresult
 PaymentDetails::UpdateErrors(const nsAString& aError,
                              const nsAString& aPayerErrors,
                              const nsAString& aPaymentMethodErrors,
--- a/dom/payments/PaymentRequestData.h
+++ b/dom/payments/PaymentRequestData.h
@@ -126,18 +126,18 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPAYMENTDETAILS
 
 
   static nsresult Create(const IPCPaymentDetails& aIPCDetails,
                          nsIPaymentDetails** aDetails);
   nsresult Update(nsIPaymentDetails* aDetails, const bool aRequestShipping);
   const nsString& GetShippingAddressErrors() const;
-  const nsString& GetPayer() const;
-  const nsString& GetPaymentMethod() const;
+  const nsString& GetPayerErrors() const;
+  const nsString& GetPaymentMethodErrors() const;
   nsresult UpdateErrors(const nsAString& aError,
                         const nsAString& aPayerErrors,
                         const nsAString& aPaymentMethodErrors,
                         const nsAString& aShippingAddressErrors);
 
 private:
   PaymentDetails(const nsAString& aId,
                  nsIPaymentItem* aTotalItem,
--- a/dom/payments/test/BasicCardErrorsChromeScript.js
+++ b/dom/payments/test/BasicCardErrorsChromeScript.js
@@ -94,17 +94,17 @@ const TestingUIService = {
     paymentSrv.respondPayment(
       showResponse.QueryInterface(Ci.nsIPaymentActionResponse)
     );
   },
   // Handles response.retry({ paymentMethod }):
   updatePayment(requestId) {
     // Let's echo what was sent in by the error...
     const request = paymentSrv.getPaymentRequestById(requestId);
-    this.showPayment(requestId, request.paymentDetails.paymentMethod);
+    this.showPayment(requestId, request.paymentDetails.paymentMethodErrors);
   },
   // Handles response.complete()
   completePayment(requestId) {
     const request = paymentSrv.getPaymentRequestById(requestId);
     const completeResponse = Cc[
       "@mozilla.org/dom/payments/payment-complete-action-response;1"
     ].createInstance(Ci.nsIPaymentCompleteActionResponse);
     completeResponse.init(
--- a/dom/payments/test/PayerDetailsChromeScript.js
+++ b/dom/payments/test/PayerDetailsChromeScript.js
@@ -30,17 +30,17 @@ const TestingUIService = {
     paymentSrv.respondPayment(
       showResponse.QueryInterface(Ci.nsIPaymentActionResponse)
     );
   },
   // .retry({ payer }) and .updateWith({payerErrors}) both get routed here:
   updatePayment(requestId) {
     // Let's echo what was sent in by the error...
     const request = paymentSrv.getPaymentRequestById(requestId);
-    const { name, email, phone } = request.paymentDetails.payer;
+    const { name, email, phone } = request.paymentDetails.payerErrors;
     const { error } = request.paymentDetails;
     // Let's use the .error as the switch
     switch (error) {
       case "retry-fire-payerdetaichangeevent": {
         paymentSrv.changePayerDetail(requestId, name, email, phone);
         break;
       }
       case "update-with": {
--- a/dom/payments/test/RetryPaymentChromeScript.js
+++ b/dom/payments/test/RetryPaymentChromeScript.js
@@ -107,17 +107,17 @@ function checkPayerErrors(testName, erro
       emitTestFail(`${testName}: Expected '${expected}' on payerErrors.${key}, but got '${msg}'.`);
       return;
     }
   }
 }
 
 function checkPaymentMethodErrors(testName, errors) {
   if (!errors) {
-    emitTestFail(`${testName} :Expect non-null payerMethodErrors, but got null.`);
+    emitTestFail(`${testName} :Expect non-null paymentMethodErrors, but got null.`);
     return;
   }
   for (const [key, msg] of Object.entries(errors)) {
     const expected = `method ${key} error`;
     if (msg !== expected) {
       emitTestFail(
         `${testName}: Expected '${expected}' on paymentMethodErrors.${key}, but got '${msg}'.`
       );
@@ -143,18 +143,18 @@ const DummyUIService = {
   },
   updatePayment(requestId) {
     const payment = paymentSrv.getPaymentRequestById(requestId);
     if (payment.paymentDetails.error !== "error") {
       emitTestFail("Expect 'error' on details.error, but got '" +
                    payment.paymentDetails.error + "'");
     }
     checkAddressErrors(this.testName, payment.paymentDetails.shippingAddressErrors)
-    checkPayerErrors(this.testName, payment.paymentDetails.payer);
-    checkPaymentMethodErrors(this.testName, payment.paymentDetails.paymentMethod);
+    checkPayerErrors(this.testName, payment.paymentDetails.payerErrors);
+    checkPaymentMethodErrors(this.testName, payment.paymentDetails.paymentMethodErrors);
     if (this.rejectRetry) {
       rejectPayment(requestId);
     } else {
       acceptPayment(requestId, "retry");
     }
   },
   closePayment: (requestId) => {respondRequestId = requestId},
   QueryInterface: ChromeUtils.generateQI([Ci.nsIPaymentUIService]),