forked from mirrors/gecko-dev
Backed out changeset 3fa420b71260 (bug 1477113) for bc failures on browser_total.js. CLOSED TREE
This commit is contained in:
parent
5f7099b985
commit
99f7b49656
7 changed files with 62 additions and 128 deletions
|
|
@ -641,27 +641,6 @@ var paymentDialogWrapper = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
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}) {
|
async onChangeShippingAddress({shippingAddressGUID}) {
|
||||||
if (shippingAddressGUID) {
|
if (shippingAddressGUID) {
|
||||||
// If a shipping address was de-selected e.g. the selected address was deleted, we'll
|
// If a shipping address was de-selected e.g. the selected address was deleted, we'll
|
||||||
|
|
@ -772,10 +751,6 @@ var paymentDialogWrapper = {
|
||||||
this.onChangePayerAddress(data);
|
this.onChangePayerAddress(data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "changePaymentMethod": {
|
|
||||||
this.onChangePaymentMethod(data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "changeShippingAddress": {
|
case "changeShippingAddress": {
|
||||||
this.onChangeShippingAddress(data);
|
this.onChangeShippingAddress(data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -156,16 +156,16 @@ export default class PaymentDialog extends PaymentStateSubscriberMixin(HTMLEleme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the selectedPaymentCard or its relevant properties or billingAddress are changed.
|
* 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.
|
// Clear paymentMethod merchant errors when the paymentMethod or billingAddress changes.
|
||||||
let request = Object.assign({}, this.requestStore.getState().request);
|
let request = Object.assign({}, this.requestStore.getState().request);
|
||||||
request.paymentDetails = Object.assign({}, request.paymentDetails);
|
request.paymentDetails = Object.assign({}, request.paymentDetails);
|
||||||
request.paymentDetails.paymentMethodErrors = null;
|
request.paymentDetails.paymentMethodErrors = null;
|
||||||
this.requestStore.setState({request});
|
this.requestStore.setState({request});
|
||||||
|
|
||||||
paymentRequest.changePaymentMethod({selectedPaymentCardBillingAddressGUID});
|
// TODO: Bug 1477113 - Dispatch paymentmethodchange
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -304,10 +304,12 @@ export default class PaymentDialog extends PaymentStateSubscriberMixin(HTMLEleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure `selectedPaymentCard` never refers to a deleted payment card.
|
// Ensure `selectedPaymentCard` never refers to a deleted payment card and refers
|
||||||
if (selectedPaymentCard && !basicCards[selectedPaymentCard]) {
|
// to a payment card if one exists.
|
||||||
|
if (!basicCards[selectedPaymentCard]) {
|
||||||
|
// Determining the initial selection is tracked in bug 1455789
|
||||||
this.requestStore.setState({
|
this.requestStore.setState({
|
||||||
selectedPaymentCard: null,
|
selectedPaymentCard: Object.keys(basicCards)[0] || null,
|
||||||
selectedPaymentCardSecurityCode: null,
|
selectedPaymentCardSecurityCode: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -430,14 +432,8 @@ export default class PaymentDialog extends PaymentStateSubscriberMixin(HTMLEleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectedPaymentCard = state.selectedPaymentCard;
|
if (state.selectedPaymentCard != this._cachedState.selectedPaymentCard) {
|
||||||
let basicCards = paymentRequest.getBasicCards(state);
|
this.changePaymentMethod(state.selectedPaymentCard);
|
||||||
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 (this._isPayerRequested(state.request.paymentOptions)) {
|
if (this._isPayerRequested(state.request.paymentOptions)) {
|
||||||
|
|
@ -448,6 +444,7 @@ export default class PaymentDialog extends PaymentStateSubscriberMixin(HTMLEleme
|
||||||
|
|
||||||
this._cachedState.selectedShippingAddress = state.selectedShippingAddress;
|
this._cachedState.selectedShippingAddress = state.selectedShippingAddress;
|
||||||
this._cachedState.selectedShippingOption = state.selectedShippingOption;
|
this._cachedState.selectedShippingOption = state.selectedShippingOption;
|
||||||
|
this._cachedState.selectedPaymentCard = state.selectedPaymentCard;
|
||||||
this._cachedState.selectedPayerAddress = state.selectedPayerAddress;
|
this._cachedState.selectedPayerAddress = state.selectedPayerAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,11 @@ export default class PaymentMethodPicker extends RichPicker {
|
||||||
|
|
||||||
// Update selectedness after the options are updated
|
// Update selectedness after the options are updated
|
||||||
let selectedPaymentCardGUID = state[this.selectedStateKey];
|
let selectedPaymentCardGUID = state[this.selectedStateKey];
|
||||||
if (selectedPaymentCardGUID) {
|
this.dropdown.value = selectedPaymentCardGUID;
|
||||||
this.dropdown.value = selectedPaymentCardGUID;
|
|
||||||
|
|
||||||
if (selectedPaymentCardGUID !== this.dropdown.value) {
|
if (selectedPaymentCardGUID && selectedPaymentCardGUID !== this.dropdown.value) {
|
||||||
throw new Error(`The option ${selectedPaymentCardGUID} ` +
|
throw new Error(`The option ${selectedPaymentCardGUID} ` +
|
||||||
`does not exist in the payment method picker`);
|
`does not exist in the payment method picker`);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.dropdown.value = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let securityCodeState = state[this.selectedStateKey + "SecurityCode"];
|
let securityCodeState = state[this.selectedStateKey + "SecurityCode"];
|
||||||
|
|
|
||||||
|
|
@ -192,10 +192,6 @@ var paymentRequest = {
|
||||||
this.sendMessageToChrome("closeDialog");
|
this.sendMessageToChrome("closeDialog");
|
||||||
},
|
},
|
||||||
|
|
||||||
changePaymentMethod(data) {
|
|
||||||
this.sendMessageToChrome("changePaymentMethod", data);
|
|
||||||
},
|
|
||||||
|
|
||||||
changeShippingAddress(data) {
|
changeShippingAddress(data) {
|
||||||
this.sendMessageToChrome("changeShippingAddress", data);
|
this.sendMessageToChrome("changeShippingAddress", data);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -215,18 +215,8 @@ async function add_link(aOptions = {}) {
|
||||||
ok(!button.disabled, "Save button should be enabled with valid CSC");
|
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);
|
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 = {}) {
|
await spawnPaymentDialogTask(frame, async function waitForSummaryPage(testArgs = {}) {
|
||||||
let {
|
let {
|
||||||
PaymentTestUtils: PTU,
|
PaymentTestUtils: PTU,
|
||||||
|
|
@ -427,8 +417,7 @@ add_task(async function test_edit_link() {
|
||||||
{
|
{
|
||||||
let card = Object.assign({}, PTU.BasicCards.JohnDoe,
|
let card = Object.assign({}, PTU.BasicCards.JohnDoe,
|
||||||
{ billingAddressGUID: prefilledGuids.address1GUID });
|
{ billingAddressGUID: prefilledGuids.address1GUID });
|
||||||
let guid = await addCardRecord(card);
|
await addCardRecord(card);
|
||||||
prefilledGuids.card1GUID = guid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
|
|
@ -443,12 +432,7 @@ add_task(async function test_edit_link() {
|
||||||
PaymentTestUtils: PTU,
|
PaymentTestUtils: PTU,
|
||||||
} = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
|
} = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
|
||||||
|
|
||||||
let paymentMethodPicker = content.document.querySelector("payment-method-picker");
|
let editLink = content.document.querySelector("payment-method-picker .edit-link");
|
||||||
let editLink = paymentMethodPicker.querySelector(".edit-link");
|
|
||||||
|
|
||||||
content.fillField(Cu.waiveXrays(paymentMethodPicker).dropdown.popupBox,
|
|
||||||
prefilledGuids.card1GUID);
|
|
||||||
|
|
||||||
is(editLink.textContent, "Edit", "Edit link text");
|
is(editLink.textContent, "Edit", "Edit link text");
|
||||||
|
|
||||||
editLink.click();
|
editLink.click();
|
||||||
|
|
@ -629,73 +613,64 @@ add_task(async function test_invalid_network_card_edit() {
|
||||||
{ billingAddressGUID: prefilledGuids.address1GUID });
|
{ billingAddressGUID: prefilledGuids.address1GUID });
|
||||||
// create a record with an unknown network id
|
// create a record with an unknown network id
|
||||||
card["cc-type"] = "asiv";
|
card["cc-type"] = "asiv";
|
||||||
let guid = await addCardRecord(card);
|
await addCardRecord(card);
|
||||||
prefilledGuids.card1GUID = guid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
methodData: [PTU.MethodData.basicCard],
|
methodData: [PTU.MethodData.basicCard],
|
||||||
details: PTU.Details.total60USD,
|
details: PTU.Details.total60USD,
|
||||||
prefilledGuids,
|
|
||||||
};
|
};
|
||||||
await spawnInDialogForMerchantTask(
|
await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, async function check() {
|
||||||
PTU.ContentTasks.createAndShowRequest,
|
let {
|
||||||
async function check({prefilledGuids}) {
|
PaymentTestUtils: PTU,
|
||||||
let {
|
} = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
|
||||||
PaymentTestUtils: PTU,
|
|
||||||
} = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
|
|
||||||
|
|
||||||
let paymentMethodPicker = content.document.querySelector("payment-method-picker");
|
let editLink = content.document.querySelector("payment-method-picker .edit-link");
|
||||||
let editLink = paymentMethodPicker.querySelector(".edit-link");
|
is(editLink.textContent, "Edit", "Edit link text");
|
||||||
|
|
||||||
content.fillField(Cu.waiveXrays(paymentMethodPicker).dropdown.popupBox,
|
editLink.click();
|
||||||
prefilledGuids.card1GUID);
|
|
||||||
|
|
||||||
is(editLink.textContent, "Edit", "Edit link text");
|
let state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
|
return state.page.id == "basic-card-page" && state["basic-card-page"].guid;
|
||||||
|
}, "Check edit page state");
|
||||||
|
|
||||||
editLink.click();
|
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 state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
let networkSelector = content.document.querySelector("basic-card-form #cc-type");
|
||||||
return state.page.id == "basic-card-page" && state["basic-card-page"].guid;
|
is(Cu.waiveXrays(networkSelector).selectedIndex, -1,
|
||||||
}, "Check edit page state");
|
"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");
|
||||||
|
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
ok(content.document.querySelector("basic-card-form button.save-button").disabled,
|
||||||
return Object.keys(state.savedBasicCards).length == 1 &&
|
"Save button should be disabled due to a missing cc-type");
|
||||||
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");
|
content.fillField(Cu.waiveXrays(networkSelector), "visa");
|
||||||
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,
|
ok(!content.document.querySelector("basic-card-form button.save-button").disabled,
|
||||||
"Save button should be disabled due to a missing cc-type");
|
"Save button should be enabled after fixing cc-type");
|
||||||
|
content.document.querySelector("basic-card-form button.save-button").click();
|
||||||
|
|
||||||
content.fillField(Cu.waiveXrays(networkSelector), "visa");
|
// 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");
|
||||||
|
|
||||||
ok(!content.document.querySelector("basic-card-form button.save-button").disabled,
|
let cardGUIDs = Object.keys(state.savedBasicCards);
|
||||||
"Save button should be enabled after fixing cc-type");
|
is(cardGUIDs.length, 1, "Check there is still one card");
|
||||||
content.document.querySelector("basic-card-form button.save-button").click();
|
let savedCard = state.savedBasicCards[cardGUIDs[0]];
|
||||||
|
is(savedCard["cc-type"], "visa", "We expect the cc-type value to be updated");
|
||||||
|
|
||||||
// We expect that saving a card with a fixed network will result in the
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
// cc-type property being changed to the new value.
|
return state.page.id == "payment-summary";
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
}, "Switched back to payment-summary");
|
||||||
let cards = Object.entries(state.savedBasicCards);
|
}, args);
|
||||||
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");
|
|
||||||
|
|
||||||
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() {
|
add_task(async function test_private_card_adding() {
|
||||||
|
|
|
||||||
|
|
@ -666,14 +666,9 @@ async function fillInCardForm(frame, aCard, aOptions = {}) {
|
||||||
// of this should be investigated further.
|
// of this should be investigated further.
|
||||||
await ContentTaskUtils.waitForCondition(() => field == content.document.activeElement,
|
await ContentTaskUtils.waitForCondition(() => field == content.document.activeElement,
|
||||||
`Waiting for field #${key} to get focus`);
|
`Waiting for field #${key} to get focus`);
|
||||||
if (key == "billingAddressGUID") {
|
// cc-exp-* fields are numbers so convert to strings and pad left with 0
|
||||||
// Can't type the value in, press Down until the value is found
|
let fillValue = val.toString().padStart(2, "0");
|
||||||
content.fillField(field, val);
|
EventUtils.synthesizeKey(fillValue, {}, Cu.waiveXrays(content.window));
|
||||||
} 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-* field values are not padded, so compare with unpadded string.
|
// cc-exp-* field values are not padded, so compare with unpadded string.
|
||||||
is(field.value, val.toString(), `${key} value is correct after sendString`);
|
is(field.value, val.toString(), `${key} value is correct after sendString`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ interface nsIPaymentRequestService : nsISupports
|
||||||
void respondPayment(in nsIPaymentActionResponse aResponse);
|
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 requestId - the request identifier of the payment request.
|
||||||
* @param aAddress - the new payment address.
|
* @param aAddress - the new payment address.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue