Commit f72420b2 authored by mathp's avatar mathp Committed by Commit bot

[Payments] Handle clicking back on the CVC unmask dialog

Was previously crashing because the AutofillPaymentInstrument delegate
was not being reset properly on back navigation. Now it is.

BUG=715093
TEST=browser_tests

Review-Url: https://codereview.chromium.org/2844293002
Cr-Commit-Position: refs/heads/master@{#467747}
parent c693ba14
......@@ -109,7 +109,8 @@ void CvcUnmaskViewController::ShowUnmaskPrompt(
void CvcUnmaskViewController::OnUnmaskVerificationResult(
autofill::AutofillClient::PaymentsRpcResult result) {
// TODO(anthonyvd): Show result.
// TODO(crbug.com/716020): Handle FullCardRequest errors with more
// granularity and display an error in the UI.
}
base::string16 CvcUnmaskViewController::GetSheetTitle() {
......@@ -183,6 +184,10 @@ void CvcUnmaskViewController::ButtonPressed(views::Button* sender,
case static_cast<int>(Tags::CONFIRM_TAG):
CvcConfirmed();
break;
case static_cast<int>(PaymentRequestCommonTags::BACK_BUTTON_TAG):
unmask_delegate_->OnUnmaskPromptClosed();
dialog()->GoBack();
break;
default:
PaymentRequestSheetController::ButtonPressed(sender, event);
}
......
......@@ -8,17 +8,19 @@
namespace payments {
class CvcUnmaskViewControllerTest : public PaymentRequestBrowserTestBase {
class PaymentRequestCvcUnmaskViewControllerTest
: public PaymentRequestBrowserTestBase {
protected:
CvcUnmaskViewControllerTest()
PaymentRequestCvcUnmaskViewControllerTest()
: PaymentRequestBrowserTestBase(
"/payment_request_no_shipping_test.html") {}
private:
DISALLOW_COPY_AND_ASSIGN(CvcUnmaskViewControllerTest);
DISALLOW_COPY_AND_ASSIGN(PaymentRequestCvcUnmaskViewControllerTest);
};
IN_PROC_BROWSER_TEST_F(CvcUnmaskViewControllerTest, CvcSentToResponse) {
IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest,
CvcSentToResponse) {
AddCreditCard(autofill::test::GetCreditCard()); // Visa.
InvokePaymentRequestUI();
......@@ -28,4 +30,21 @@ IN_PROC_BROWSER_TEST_F(CvcUnmaskViewControllerTest, CvcSentToResponse) {
ExpectBodyContains({"\"cardSecurityCode\": \"012\""});
}
// Test that going in the CVC editor, backing out and opening it again to pay
// does not crash.
IN_PROC_BROWSER_TEST_F(PaymentRequestCvcUnmaskViewControllerTest,
OpenGoBackOpenPay) {
AddCreditCard(autofill::test::GetCreditCard()); // Visa.
InvokePaymentRequestUI();
OpenCVCPromptWithCVC(base::ASCIIToUTF16("012"));
// Go back before confirming the CVC.
ClickOnBackArrow();
// Now pay for real.
PayWithCreditCardAndWait(base::ASCIIToUTF16("012"));
ExpectBodyContains({"\"cardSecurityCode\": \"012\""});
}
} // namespace payments
......@@ -113,7 +113,9 @@ void AutofillPaymentInstrument::OnFullCardRequestSucceeded(
}
void AutofillPaymentInstrument::OnFullCardRequestFailed() {
// TODO(anthonyvd): Do something with the error.
// The user may have cancelled the unmask or something has gone wrong (e.g.,
// the network request failed). In all cases, reset the |delegate_| so another
// request can start.
delegate_ = nullptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment