Commit 941c32aa authored by Jinho Bang's avatar Jinho Bang Committed by Commit Bot

PaymentRequest: Fix a memory leak in retry()

In the current implementation, memory leaks occur becuase the internal
view_stack_ for payment sheet grows incrementally whenver calling
retry(). So, this patch uses GoBackToPaymentSheet() instead of
ShowInitialPaymentSheet() in RetryDialog(). The method has a logic to
reduce stack's size internally.

Bug: 861704
Change-Id: I2cb94772485165d1fa96463f16f39edf20ccf7bc
Reviewed-on: https://chromium-review.googlesource.com/1255082Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#595644}
parent 3424e405
......@@ -344,7 +344,7 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestContactInfoEditorTest,
" phone: 'PHONE ERROR'"
" }"
"}",
DialogEvent::CONTACT_INFO_EDITOR_OPENED);
DialogEvent::CONTACT_INFO_EDITOR_OPENED, dialog_view());
EXPECT_EQ(base::ASCIIToUTF16("EMAIL ERROR"),
GetErrorLabelForType(autofill::EMAIL_ADDRESS));
......@@ -381,7 +381,7 @@ IN_PROC_BROWSER_TEST_F(
" phone: 'PHONE ERROR'"
" }"
"}",
DialogEvent::CONTACT_INFO_EDITOR_OPENED);
DialogEvent::CONTACT_INFO_EDITOR_OPENED, dialog_view());
EXPECT_EQ(base::ASCIIToUTF16("EMAIL ERROR"),
GetErrorLabelForType(autofill::EMAIL_ADDRESS));
......@@ -411,7 +411,8 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestContactInfoEditorTest,
" name: 'NAME ERROR',"
" phone: 'PHONE ERROR'"
" }"
"}");
"}",
dialog_view());
const int kErrorLabelOffset =
static_cast<int>(DialogViewID::ERROR_LABEL_OFFSET);
......
......@@ -638,10 +638,13 @@ void PaymentRequestBrowserTestBase::PayWithCreditCard(
}
void PaymentRequestBrowserTestBase::RetryPaymentRequest(
const std::string& validation_errors) {
ResetEventWaiterForSequence(
{DialogEvent::PROCESSING_SPINNER_HIDDEN, DialogEvent::SPEC_DONE_UPDATING,
DialogEvent::PROCESSING_SPINNER_HIDDEN, DialogEvent::DIALOG_OPENED});
const std::string& validation_errors,
PaymentRequestDialogView* dialog_view) {
EXPECT_EQ(2U, dialog_view->view_stack_for_testing()->size());
ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_HIDDEN,
DialogEvent::SPEC_DONE_UPDATING,
DialogEvent::PROCESSING_SPINNER_HIDDEN,
DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION});
ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(),
"retry(" + validation_errors + ");"));
......@@ -651,11 +654,13 @@ void PaymentRequestBrowserTestBase::RetryPaymentRequest(
void PaymentRequestBrowserTestBase::RetryPaymentRequest(
const std::string& validation_errors,
const DialogEvent& dialog_event) {
const DialogEvent& dialog_event,
PaymentRequestDialogView* dialog_view) {
EXPECT_EQ(2U, dialog_view->view_stack_for_testing()->size());
ResetEventWaiterForSequence(
{DialogEvent::PROCESSING_SPINNER_HIDDEN, DialogEvent::SPEC_DONE_UPDATING,
DialogEvent::PROCESSING_SPINNER_HIDDEN, DialogEvent::DIALOG_OPENED,
dialog_event});
DialogEvent::PROCESSING_SPINNER_HIDDEN,
DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION, dialog_event});
ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(),
"retry(" + validation_errors + ");"));
......
......@@ -209,9 +209,11 @@ class PaymentRequestBrowserTestBase
void PayWithCreditCardAndWait(const base::string16& cvc,
PaymentRequestDialogView* dialog_view);
void PayWithCreditCard(const base::string16& cvc);
void RetryPaymentRequest(const std::string& validation_errors);
void RetryPaymentRequest(const std::string& validation_errors,
const DialogEvent& dialog_event);
PaymentRequestDialogView* dialog_view);
void RetryPaymentRequest(const std::string& validation_errors,
const DialogEvent& dialog_event,
PaymentRequestDialogView* dialog_view);
// Getting/setting the |value| in the textfield of a given |type|.
base::string16 GetEditorTextfieldValue(autofill::ServerFieldType type);
......
......@@ -189,7 +189,7 @@ void PaymentRequestDialogView::ShowPaymentHandlerScreen(
void PaymentRequestDialogView::RetryDialog() {
HideProcessingSpinner();
ShowInitialPaymentSheet();
GoBackToPaymentSheet();
if (request_->spec()->has_shipping_address_error()) {
autofill::AutofillProfile* profile =
......
......@@ -1286,7 +1286,7 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
" city: 'CITY ERROR'"
" }"
"}",
DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED);
DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED, dialog_view());
EXPECT_EQ(base::ASCIIToUTF16("ADDRESS LINE ERROR"),
GetErrorLabelForType(autofill::ADDRESS_HOME_STREET_ADDRESS));
......@@ -1322,7 +1322,7 @@ IN_PROC_BROWSER_TEST_F(
" city: 'CITY ERROR'"
" }"
"}",
DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED);
DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED, dialog_view());
EXPECT_EQ(base::ASCIIToUTF16("ADDRESS LINE ERROR"),
GetErrorLabelForType(autofill::ADDRESS_HOME_STREET_ADDRESS));
......@@ -1349,7 +1349,8 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
" addressLine: 'ADDRESS LINE ERROR',"
" city: 'CITY ERROR'"
" }"
"}");
"}",
dialog_view());
const int kErrorLabelOffset =
static_cast<int>(DialogViewID::ERROR_LABEL_OFFSET);
......
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