Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: components/autofill/browser/autofill_manager_unittest.cc

Issue 13264002: Requery the autofill server when forms and input fields are dynamically added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes. you get the drill. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/browser/autofill_manager_unittest.cc b/components/autofill/browser/autofill_manager_unittest.cc
index e88906bd3def330699d20291aabd5124640ac079..db72605c4fb4f7c26bdc326b510cc8ea3a50f060 100644
--- a/components/autofill/browser/autofill_manager_unittest.cc
+++ b/components/autofill/browser/autofill_manager_unittest.cc
@@ -37,6 +37,7 @@
#include "components/autofill/common/autofill_messages.h"
#include "components/autofill/common/form_data.h"
#include "components/autofill/common/form_field_data.h"
+#include "components/autofill/common/forms_seen_param.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_render_process_host.h"
@@ -740,11 +741,23 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
}
void FormsSeen(const std::vector<FormData>& forms) {
- autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false);
+ autofill_manager_->OnFormsSeen(forms, base::TimeTicks(),
+ autofill::NO_SPECIAL_FORMS_SEEN);
}
void PartialFormsSeen(const std::vector<FormData>& forms) {
- autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true);
+ autofill_manager_->OnFormsSeen(forms, base::TimeTicks(),
+ autofill::PARTIAL_FORMS_SEEN);
+ }
+
+ void DynamicFormsSeen(const std::vector<FormData>& forms) {
+ autofill_manager_->OnFormsSeen(forms, base::TimeTicks(),
+ autofill::DYNAMIC_FORMS_SEEN);
+ }
+
+ void PartialDynamicFormsSeen(const std::vector<FormData>& forms) {
+ autofill_manager_->OnFormsSeen(forms, base::TimeTicks(),
+ autofill::PARTIAL_AND_DYNAMIC_FORMS_SEEN);
}
void FormSubmitted(const FormData& form) {
@@ -884,6 +897,20 @@ TEST_F(AutofillManagerTest, GetAllForms) {
ASSERT_TRUE(HasSeenAutofillGetAllFormsMessage());
}
+// Test that browser asks for all forms after DOM changes when
+// Autocheckout is enabled.
+TEST_F(AutofillManagerTest, GetAllDynamicForms) {
+ FormData form;
+ CreateTestAddressFormData(&form);
+ std::vector<FormData> forms(1, form);
+ // Enable autocheckout.
+ autofill_manager_->set_autocheckout_url_prefix("test-prefix");
+
+ PartialDynamicFormsSeen(forms);
+
+ EXPECT_TRUE(HasSeenAutofillGetAllFormsMessage());
+}
+
// Test that we return all address profile suggestions when all form fields are
// empty.
TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) {
@@ -963,6 +990,42 @@ TEST_F(AutofillManagerTest, AutocheckoutFormsSeen) {
EXPECT_EQ("/form.html", form_structures[2]->source_url().path());
}
+// Test that in the case of Autocheckout, forms seen are in order supplied.
+TEST_F(AutofillManagerTest, DynamicFormsSeen) {
+ FormData shipping_options;
+ CreateTestShippingOptionsFormData(&shipping_options);
+ FormData user_supplied;
+ CreateTestFormWithAutocompleteAttribute(&user_supplied);
+ FormData address;
+ CreateTestAddressFormData(&address);
+
+ autofill_manager_->set_autocheckout_url_prefix("test-prefix");
+ // Push user_supplied only
+ std::vector<FormData> forms;
+ forms.push_back(user_supplied);
+
+ // Make sure normal form is handled correctly.
+ FormsSeen(forms);
+ std::vector<FormStructure*> form_structures;
+ form_structures = autofill_manager_->GetFormStructures();
+ ASSERT_EQ(1U, form_structures.size());
+ EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path());
+
+ // Push other forms
+ forms.push_back(shipping_options);
+ forms.push_back(address);
+
+ // FormStructure should contain three and only three forms. Otherwise, it
+ // would indicate that the manager didn't reset upon being notified of
+ // the new forms;
+ DynamicFormsSeen(forms);
+ form_structures = autofill_manager_->GetFormStructures();
+ ASSERT_EQ(3U, form_structures.size());
+ EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path());
+ EXPECT_EQ("/shipping.html", form_structures[1]->source_url().path());
+ EXPECT_EQ("/form.html", form_structures[2]->source_url().path());
+}
+
// Test that we return only matching address profile suggestions when the
// selected form field has been partially filled out.
TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) {

Powered by Google App Engine
This is Rietveld 408576698