summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 20:34:13 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 20:34:13 +0000
commit121428853b0d6c2e2ec5ba4afdb90bbbb36cf8b5 (patch)
treede766ef7392bfe2a41e1a3ad031b92a83d35cd38
parent31510ef9ab63bbf3487f2793cb1f26bfef3cef1d (diff)
downloadchromium_src-121428853b0d6c2e2ec5ba4afdb90bbbb36cf8b5.zip
chromium_src-121428853b0d6c2e2ec5ba4afdb90bbbb36cf8b5.tar.gz
chromium_src-121428853b0d6c2e2ec5ba4afdb90bbbb36cf8b5.tar.bz2
Merge 279302 "rAc: Fix crash when there are no valid countries t..."
> rAc: Fix crash when there are no valid countries to choose from > > BUG=388018 > > Review URL: https://codereview.chromium.org/355523004 TBR=estade@chromium.org Review URL: https://codereview.chromium.org/387673003 git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@282420 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc11
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc28
2 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index c6372f8..be524fb4 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -764,6 +764,17 @@ void AutofillDialogControllerImpl::Show() {
base::Bind(CountryFilter,
form_structure_.PossibleValues(ADDRESS_HOME_COUNTRY))));
+ // If the form has a country <select> but none of the options are valid, bail.
+ if (billing_country_combobox_model_->GetItemCount() == 0 ||
+ shipping_country_combobox_model_->GetItemCount() == 0) {
+ callback_.Run(AutofillClient::AutocompleteResultErrorDisabled,
+ base::ASCIIToUTF16("No valid/supported country options"
+ " found."),
+ NULL);
+ delete this;
+ return;
+ }
+
// Log any relevant UI metrics and security exceptions.
GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN);
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index 662a24b..acdbddb 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -3435,6 +3435,34 @@ TEST_F(AutofillDialogControllerTest, LimitedCountryChoices) {
billing_country_model->GetItemCount());
}
+// http://crbug.com/388018
+TEST_F(AutofillDialogControllerTest, NoCountryChoices) {
+ // Create a form data that simulates:
+ // <select autocomplete="billing country">
+ // <option value="ATL">Atlantis</option>
+ // <option value="ELD">Eldorado</option>
+ // </select>
+ // i.e. contains a list of no valid countries.
+ FormData form_data;
+ FormFieldData field;
+ field.autocomplete_attribute = "billing country";
+ field.option_contents.push_back(ASCIIToUTF16("Atlantis"));
+ field.option_values.push_back(ASCIIToUTF16("ATL"));
+ field.option_contents.push_back(ASCIIToUTF16("Eldorado"));
+ field.option_values.push_back(ASCIIToUTF16("ELD"));
+
+ FormFieldData cc_field;
+ cc_field.autocomplete_attribute = "cc-csc";
+
+ form_data.fields.push_back(field);
+ form_data.fields.push_back(cc_field);
+ ResetControllerWithFormData(form_data);
+ controller()->Show();
+
+ // Controller aborts and self destructs.
+ EXPECT_EQ(0, controller());
+}
+
TEST_F(AutofillDialogControllerTest, LimitedCcChoices) {
SwitchToAutofill();
// Typically, MC and Visa are both valid.