Backed out changeset 3fa420b71260 (bug 1477113) for bc failures on browser_total.js. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Thu, 13 Dec 2018 09:53:39 +0200
changeset 450382 2a9b1509c18f96d50c06cc29c2342b8c585b963b
parent 450381 4a2e65b750282683982627bbaf8f07a7de855d7a
child 450383 ee53b81938266fffd38972636e7f992989281048
push id35200
push userbtara@mozilla.com
push dateThu, 13 Dec 2018 21:51:24 +0000
treeherdermozilla-central@563996e91860 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1477113
milestone66.0a1
backs out3fa420b71260567a549549f1c57e32cd1bbcfcbb
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 3fa420b71260 (bug 1477113) for bc failures on browser_total.js. CLOSED TREE
browser/components/payments/content/paymentDialogWrapper.js
browser/components/payments/res/containers/payment-dialog.js
browser/components/payments/res/containers/payment-method-picker.js
browser/components/payments/res/paymentRequest.js
browser/components/payments/test/browser/browser_card_edit.js
browser/components/payments/test/browser/head.js
dom/interfaces/payments/nsIPaymentRequestService.idl
--- a/browser/components/payments/content/paymentDialogWrapper.js
+++ b/browser/components/payments/content/paymentDialogWrapper.js
@@ -636,37 +636,16 @@ var paymentDialogWrapper = {
         payerName,
         payerEmail,
         payerPhone,
       } = await this._convertProfileAddressToPayerData(payerAddressGUID);
       paymentSrv.changePayerDetail(this.request.requestId, payerName, payerEmail, payerPhone);
     }
   },
 
-  async onChangePaymentMethod({
-    selectedPaymentCardBillingAddressGUID: billingAddressGUID,
-  }) {
-    const methodName = "basic-card";
-    let methodDetails;
-    try {
-      let billingAddress = await this._convertProfileAddressToPaymentAddress(billingAddressGUID);
-      const basicCardChangeDetails = Cc["@mozilla.org/dom/payments/basiccard-change-details;1"]
-                                       .createInstance(Ci.nsIBasicCardChangeDetails);
-      basicCardChangeDetails.initData(billingAddress);
-      methodDetails = basicCardChangeDetails.QueryInterface(Ci.nsIMethodChangeDetails);
-    } catch (ex) {
-      // TODO (Bug 1498403): Some kind of "credit card storage error" here, perhaps asking user
-      // to re-enter credit card # from management UI.
-      Cu.reportError(ex);
-      return;
-    }
-
-    paymentSrv.changePaymentMethod(this.request.requestId, methodName, methodDetails);
-  },
-
   async onChangeShippingAddress({shippingAddressGUID}) {
     if (shippingAddressGUID) {
       // If a shipping address was de-selected e.g. the selected address was deleted, we'll
       // just wait to send the address change when the shipping address is eventually selected
       // before clicking Pay since it's a required field.
       let address = await this._convertProfileAddressToPaymentAddress(shippingAddressGUID);
       paymentSrv.changeShippingAddress(this.request.requestId, address);
     }
@@ -767,20 +746,16 @@ var paymentDialogWrapper = {
       case "initializeRequest": {
         this.initializeFrame();
         break;
       }
       case "changePayerAddress": {
         this.onChangePayerAddress(data);
         break;
       }
-      case "changePaymentMethod": {
-        this.onChangePaymentMethod(data);
-        break;
-      }
       case "changeShippingAddress": {
         this.onChangeShippingAddress(data);
         break;
       }
       case "changeShippingOption": {
         this.onChangeShippingOption(data);
         break;
       }
--- a/browser/components/payments/res/containers/payment-dialog.js
+++ b/browser/components/payments/res/containers/payment-dialog.js
@@ -151,26 +151,26 @@ export default class PaymentDialog exten
   changeShippingOption(optionID) {
     paymentRequest.changeShippingOption({
       optionID,
     });
   }
 
   /**
    * Called when the selectedPaymentCard or its relevant properties or billingAddress are changed.
-   * @param {string} selectedPaymentCardBillingAddressGUID
+   * @param {string} selectedPaymentCardGUID
    */
-  changePaymentMethod(selectedPaymentCardBillingAddressGUID) {
+  changePaymentMethod(selectedPaymentCardGUID) {
     // Clear paymentMethod merchant errors when the paymentMethod or billingAddress changes.
     let request = Object.assign({}, this.requestStore.getState().request);
     request.paymentDetails = Object.assign({}, request.paymentDetails);
     request.paymentDetails.paymentMethodErrors = null;
     this.requestStore.setState({request});
 
-    paymentRequest.changePaymentMethod({selectedPaymentCardBillingAddressGUID});
+    // TODO: Bug 1477113 - Dispatch paymentmethodchange
   }
 
   /**
    * Called when the selectedPayerAddress or its relevant properties are changed.
    * @param {string} payerAddressGUID
    */
   changePayerAddress(payerAddressGUID) {
     // Clear payer address merchant errors when the payer address changes.
@@ -299,20 +299,22 @@ export default class PaymentDialog exten
       let oldBillingAddress = billingAddressGUID && oldAddresses[billingAddressGUID];
 
       if (oldBillingAddress && billingAddress &&
           billingAddress.timeLastModified != oldBillingAddress.timeLastModified) {
         delete this._cachedState.selectedPaymentCard;
       }
     }
 
-    // Ensure `selectedPaymentCard` never refers to a deleted payment card.
-    if (selectedPaymentCard && !basicCards[selectedPaymentCard]) {
+    // Ensure `selectedPaymentCard` never refers to a deleted payment card and refers
+    // to a payment card if one exists.
+    if (!basicCards[selectedPaymentCard]) {
+      // Determining the initial selection is tracked in bug 1455789
       this.requestStore.setState({
-        selectedPaymentCard: null,
+        selectedPaymentCard: Object.keys(basicCards)[0] || null,
         selectedPaymentCardSecurityCode: null,
       });
     }
 
     if (this._isPayerRequested(state.request.paymentOptions)) {
       let payerAddress = selectedPayerAddress && addresses[selectedPayerAddress];
       let oldPayerAddress = selectedPayerAddress && oldAddresses[selectedPayerAddress];
 
@@ -425,34 +427,29 @@ export default class PaymentDialog exten
         this.changeShippingAddress(state.selectedShippingAddress);
       }
 
       if (state.selectedShippingOption != this._cachedState.selectedShippingOption) {
         this.changeShippingOption(state.selectedShippingOption);
       }
     }
 
-    let selectedPaymentCard = state.selectedPaymentCard;
-    let basicCards = paymentRequest.getBasicCards(state);
-    let billingAddressGUID = (basicCards[selectedPaymentCard] || {}).billingAddressGUID;
-    if (selectedPaymentCard != this._cachedState.selectedPaymentCard &&
-        billingAddressGUID) {
-      // Update _cachedState to prevent an infinite loop when changePaymentMethod updates state.
-      this._cachedState.selectedPaymentCard = state.selectedPaymentCard;
-      this.changePaymentMethod(billingAddressGUID);
+    if (state.selectedPaymentCard != this._cachedState.selectedPaymentCard) {
+      this.changePaymentMethod(state.selectedPaymentCard);
     }
 
     if (this._isPayerRequested(state.request.paymentOptions)) {
       if (state.selectedPayerAddress != this._cachedState.selectedPayerAddress) {
         this.changePayerAddress(state.selectedPayerAddress);
       }
     }
 
     this._cachedState.selectedShippingAddress = state.selectedShippingAddress;
     this._cachedState.selectedShippingOption = state.selectedShippingOption;
+    this._cachedState.selectedPaymentCard = state.selectedPaymentCard;
     this._cachedState.selectedPayerAddress = state.selectedPayerAddress;
   }
 
   render(state) {
     let request = state.request;
     let paymentDetails = request.paymentDetails;
     this._hostNameEl.textContent = request.topLevelPrincipal.URI.displayHost;
 
--- a/browser/components/payments/res/containers/payment-method-picker.js
+++ b/browser/components/payments/res/containers/payment-method-picker.js
@@ -62,25 +62,21 @@ export default class PaymentMethodPicker
 
     this.dropdown.popupBox.textContent = "";
     for (let option of desiredOptions) {
       this.dropdown.popupBox.appendChild(option);
     }
 
     // Update selectedness after the options are updated
     let selectedPaymentCardGUID = state[this.selectedStateKey];
-    if (selectedPaymentCardGUID) {
-      this.dropdown.value = selectedPaymentCardGUID;
+    this.dropdown.value = selectedPaymentCardGUID;
 
-      if (selectedPaymentCardGUID !== this.dropdown.value) {
-        throw new Error(`The option ${selectedPaymentCardGUID} ` +
-                        `does not exist in the payment method picker`);
-      }
-    } else {
-      this.dropdown.value = "";
+    if (selectedPaymentCardGUID && selectedPaymentCardGUID !== this.dropdown.value) {
+      throw new Error(`The option ${selectedPaymentCardGUID} ` +
+                      `does not exist in the payment method picker`);
     }
 
     let securityCodeState = state[this.selectedStateKey + "SecurityCode"];
     if (securityCodeState && securityCodeState != this.securityCodeInput.value) {
       this.securityCodeInput.defaultValue = securityCodeState;
     }
 
     let selectedCardType = (basicCards[selectedPaymentCardGUID] &&
--- a/browser/components/payments/res/paymentRequest.js
+++ b/browser/components/payments/res/paymentRequest.js
@@ -187,20 +187,16 @@ var paymentRequest = {
   pay(data) {
     this.sendMessageToChrome("pay", data);
   },
 
   closeDialog() {
     this.sendMessageToChrome("closeDialog");
   },
 
-  changePaymentMethod(data) {
-    this.sendMessageToChrome("changePaymentMethod", data);
-  },
-
   changeShippingAddress(data) {
     this.sendMessageToChrome("changeShippingAddress", data);
   },
 
   changeShippingOption(data) {
     this.sendMessageToChrome("changeShippingOption", data);
   },
 
--- a/browser/components/payments/test/browser/browser_card_edit.js
+++ b/browser/components/payments/test/browser/browser_card_edit.js
@@ -210,28 +210,18 @@ async function add_link(aOptions = {}) {
       field = content.document.getElementById("cc-csc");
       field.focus();
       content.fillField(field, "123");
       button.focus();
 
       ok(!button.disabled, "Save button should be enabled with valid CSC");
     });
 
-    ContentTask.spawn(browser, {
-      eventName: "paymentmethodchange",
-    }, PTU.ContentTasks.promisePaymentRequestEvent);
-    info("added paymentmethodchange handler");
-
     await spawnPaymentDialogTask(frame, PTU.DialogContentTasks.clickPrimaryButton);
 
-    info("waiting for paymentmethodchange event");
-    await ContentTask.spawn(browser, {
-      eventName: "paymentmethodchange",
-    }, PTU.ContentTasks.awaitPaymentEventPromise);
-
     await spawnPaymentDialogTask(frame, async function waitForSummaryPage(testArgs = {}) {
       let {
         PaymentTestUtils: PTU,
       } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
       await PTU.DialogContentUtils.waitForState(content, (state) => {
         return state.page.id == "payment-summary";
       }, "Check we are back on the summary page");
@@ -422,38 +412,32 @@ add_task(async function test_opt_out_per
 });
 
 add_task(async function test_edit_link() {
   // add an address and card linked to this address
   let prefilledGuids = await setup([PTU.Addresses.TimBL, PTU.Addresses.TimBL2]);
   {
     let card = Object.assign({}, PTU.BasicCards.JohnDoe,
                              { billingAddressGUID: prefilledGuids.address1GUID });
-    let guid = await addCardRecord(card);
-    prefilledGuids.card1GUID = guid;
+    await addCardRecord(card);
   }
 
   const args = {
     methodData: [PTU.MethodData.basicCard],
     details: PTU.Details.total60USD,
     prefilledGuids,
   };
   await spawnInDialogForMerchantTask(
     PTU.ContentTasks.createAndShowRequest,
     async function check({prefilledGuids}) {
       let {
         PaymentTestUtils: PTU,
       } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
-      let paymentMethodPicker = content.document.querySelector("payment-method-picker");
-      let editLink = paymentMethodPicker.querySelector(".edit-link");
-
-      content.fillField(Cu.waiveXrays(paymentMethodPicker).dropdown.popupBox,
-                        prefilledGuids.card1GUID);
-
+      let editLink = content.document.querySelector("payment-method-picker .edit-link");
       is(editLink.textContent, "Edit", "Edit link text");
 
       editLink.click();
 
       let state = await PTU.DialogContentUtils.waitForState(content, (state) => {
         return state.page.id == "basic-card-page" && state["basic-card-page"].guid;
       }, "Check edit page state");
 
@@ -624,83 +608,74 @@ add_task(async function test_edit_link()
 add_task(async function test_invalid_network_card_edit() {
   // add an address and card linked to this address
   let prefilledGuids = await setup([PTU.Addresses.TimBL]);
   {
     let card = Object.assign({}, PTU.BasicCards.JohnDoe,
                              { billingAddressGUID: prefilledGuids.address1GUID });
     // create a record with an unknown network id
     card["cc-type"] = "asiv";
-    let guid = await addCardRecord(card);
-    prefilledGuids.card1GUID = guid;
+    await addCardRecord(card);
   }
 
   const args = {
     methodData: [PTU.MethodData.basicCard],
     details: PTU.Details.total60USD,
-    prefilledGuids,
   };
-  await spawnInDialogForMerchantTask(
-    PTU.ContentTasks.createAndShowRequest,
-    async function check({prefilledGuids}) {
-      let {
-        PaymentTestUtils: PTU,
-      } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
+  await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, async function check() {
+    let {
+      PaymentTestUtils: PTU,
+    } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
-      let paymentMethodPicker = content.document.querySelector("payment-method-picker");
-      let editLink = paymentMethodPicker.querySelector(".edit-link");
+    let editLink = content.document.querySelector("payment-method-picker .edit-link");
+    is(editLink.textContent, "Edit", "Edit link text");
+
+    editLink.click();
 
-      content.fillField(Cu.waiveXrays(paymentMethodPicker).dropdown.popupBox,
-                        prefilledGuids.card1GUID);
-
-      is(editLink.textContent, "Edit", "Edit link text");
-
-      editLink.click();
+    let state = await PTU.DialogContentUtils.waitForState(content, (state) => {
+      return state.page.id == "basic-card-page" && state["basic-card-page"].guid;
+    }, "Check edit page state");
 
-      let state = await PTU.DialogContentUtils.waitForState(content, (state) => {
-        return state.page.id == "basic-card-page" && state["basic-card-page"].guid;
-      }, "Check edit page state");
+    state = await PTU.DialogContentUtils.waitForState(content, (state) => {
+      return Object.keys(state.savedBasicCards).length == 1 &&
+             Object.keys(state.savedAddresses).length == 1;
+    }, "Check card and address present at beginning of test");
 
-      state = await PTU.DialogContentUtils.waitForState(content, (state) => {
-        return Object.keys(state.savedBasicCards).length == 1 &&
-               Object.keys(state.savedAddresses).length == 1;
-      }, "Check card and address present at beginning of test");
+    let networkSelector = content.document.querySelector("basic-card-form #cc-type");
+    is(Cu.waiveXrays(networkSelector).selectedIndex, -1,
+       "An invalid cc-type should result in no selection");
+    is(Cu.waiveXrays(networkSelector).value, "",
+       "An invalid cc-type should result in an empty string as value");
 
-      let networkSelector = content.document.querySelector("basic-card-form #cc-type");
-      is(Cu.waiveXrays(networkSelector).selectedIndex, -1,
-         "An invalid cc-type should result in no selection");
-      is(Cu.waiveXrays(networkSelector).value, "",
-         "An invalid cc-type should result in an empty string as value");
+    ok(content.document.querySelector("basic-card-form button.save-button").disabled,
+       "Save button should be disabled due to a missing cc-type");
 
-      ok(content.document.querySelector("basic-card-form button.save-button").disabled,
-         "Save button should be disabled due to a missing cc-type");
+    content.fillField(Cu.waiveXrays(networkSelector), "visa");
 
-      content.fillField(Cu.waiveXrays(networkSelector), "visa");
-
-      ok(!content.document.querySelector("basic-card-form button.save-button").disabled,
-         "Save button should be enabled after fixing cc-type");
-      content.document.querySelector("basic-card-form button.save-button").click();
+    ok(!content.document.querySelector("basic-card-form button.save-button").disabled,
+       "Save button should be enabled after fixing cc-type");
+    content.document.querySelector("basic-card-form button.save-button").click();
 
-      // We expect that saving a card with a fixed network will result in the
-      // cc-type property being changed to the new value.
-      state = await PTU.DialogContentUtils.waitForState(content, (state) => {
-        let cards = Object.entries(state.savedBasicCards);
-        return cards.length == 1 &&
-               cards[0][1]["cc-type"] == "visa";
-      }, "Check card was edited");
+    // We expect that saving a card with a fixed network will result in the
+    // cc-type property being changed to the new value.
+    state = await PTU.DialogContentUtils.waitForState(content, (state) => {
+      let cards = Object.entries(state.savedBasicCards);
+      return cards.length == 1 &&
+             cards[0][1]["cc-type"] == "visa";
+    }, "Check card was edited");
 
-      let cardGUIDs = Object.keys(state.savedBasicCards);
-      is(cardGUIDs.length, 1, "Check there is still one card");
-      let savedCard = state.savedBasicCards[cardGUIDs[0]];
-      is(savedCard["cc-type"], "visa", "We expect the cc-type value to be updated");
+    let cardGUIDs = Object.keys(state.savedBasicCards);
+    is(cardGUIDs.length, 1, "Check there is still one card");
+    let savedCard = state.savedBasicCards[cardGUIDs[0]];
+    is(savedCard["cc-type"], "visa", "We expect the cc-type value to be updated");
 
-      state = await PTU.DialogContentUtils.waitForState(content, (state) => {
-        return state.page.id == "payment-summary";
-      }, "Switched back to payment-summary");
-    }, args);
+    state = await PTU.DialogContentUtils.waitForState(content, (state) => {
+      return state.page.id == "payment-summary";
+    }, "Switched back to payment-summary");
+  }, args);
 });
 
 add_task(async function test_private_card_adding() {
   await setup([PTU.Addresses.TimBL], [PTU.BasicCards.JohnDoe]);
   let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
 
   await BrowserTestUtils.withNewTab({
     gBrowser: privateWin.gBrowser,
--- a/browser/components/payments/test/browser/head.js
+++ b/browser/components/payments/test/browser/head.js
@@ -661,24 +661,19 @@ async function fillInCardForm(frame, aCa
       ok(!field.value, "Field value should be reset before typing");
       field.blur();
       field.focus();
       // Using waitForEvent here causes the test to hang, but
       // waitForCondition and checking activeElement does the trick. The root cause
       // of this should be investigated further.
       await ContentTaskUtils.waitForCondition(() => field == content.document.activeElement,
                                               `Waiting for field #${key} to get focus`);
-      if (key == "billingAddressGUID") {
-        // Can't type the value in, press Down until the value is found
-        content.fillField(field, val);
-      } else {
-        // cc-exp-* fields are numbers so convert to strings and pad left with 0
-        let fillValue = val.toString().padStart(2, "0");
-        EventUtils.synthesizeKey(fillValue, {}, Cu.waiveXrays(content.window));
-      }
+      // cc-exp-* fields are numbers so convert to strings and pad left with 0
+      let fillValue = val.toString().padStart(2, "0");
+      EventUtils.synthesizeKey(fillValue, {}, Cu.waiveXrays(content.window));
       // cc-exp-* field values are not padded, so compare with unpadded string.
       is(field.value, val.toString(), `${key} value is correct after sendString`);
     }
 
     info([...content.document.getElementById("cc-exp-year").options].map(op => op.label).join(","));
 
     let persistCheckbox = content.document.querySelector(options.checkboxSelector);
     // only touch the checked state if explicitly told to in the options
--- a/dom/interfaces/payments/nsIPaymentRequestService.idl
+++ b/dom/interfaces/payments/nsIPaymentRequestService.idl
@@ -36,17 +36,17 @@ interface nsIPaymentRequestService : nsI
 
   /**
    *  Send the user's response to the merchant.
    *  @param aResponse - the user's response.
    */
   void respondPayment(in nsIPaymentActionResponse aResponse);
 
   /**
-   *  Inform the merchant the shipping address has changed.
+   *  Inform the merchant the shipping addres has changed.
    *  @param requestId - the request identifier of the payment request.
    *  @param aAddress - the new payment address.
    */
   void changeShippingAddress(in AString requestId, in nsIPaymentAddress aAddress);
 
   /**
    *  Inform the merchant the shipping option has changed.
    *  @param requestId - the request identifier of the payment request.