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

Side by Side Diff: chrome/renderer/autofill/form_autofill_browsertest.cc

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bug Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 4110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 frame->document().all(), &fieldsets); 4121 frame->document().all(), &fieldsets);
4122 ASSERT_TRUE(control_elements.empty()); 4122 ASSERT_TRUE(control_elements.empty());
4123 ASSERT_TRUE(fieldsets.empty()); 4123 ASSERT_TRUE(fieldsets.empty());
4124 4124
4125 FormData form; 4125 FormData form;
4126 EXPECT_FALSE(UnownedCheckoutFormElementsAndFieldSetsToFormData( 4126 EXPECT_FALSE(UnownedCheckoutFormElementsAndFieldSetsToFormData(
4127 fieldsets, control_elements, nullptr, frame->document(), extract_mask, 4127 fieldsets, control_elements, nullptr, frame->document(), extract_mask,
4128 &form, nullptr)); 4128 &form, nullptr));
4129 } 4129 }
4130 4130
4131 TEST_F(FormAutofillTest, FormCache_ExtractNewForms) {
4132 struct {
4133 const char* html;
4134 const size_t expected_forms;
4135 } test_cases[] = {
4136 // An empty form should not be extracted
4137 {"<FORM name='TestForm' action='http://buh.com' method='post'>"
4138 "</FORM>",
4139 0},
4140 // A form with less than three fields with no autocomplete type(s) should
4141 // not be extracted.
4142 {"<FORM name='TestForm' action='http://buh.com' method='post'>"
4143 " <INPUT type='name' id='firstname'/>"
4144 "</FORM>",
4145 0},
4146 // A form with less than three fields with at least one autocomplete type
4147 // should be extracted.
4148 {"<FORM name='TestForm' action='http://buh.com' method='post'>"
4149 " <INPUT type='name' id='firstname' autocomplete='given-name'/>"
4150 "</FORM>",
4151 1},
4152 // A form with three or more fields should be extracted.
4153 {"<FORM name='TestForm' action='http://buh.com' method='post'>"
4154 " <INPUT type='text' id='firstname'/>"
4155 " <INPUT type='text' id='lastname'/>"
4156 " <INPUT type='text' id='email'/>"
4157 " <INPUT type='submit' value='Send'/>"
4158 "</FORM>",
4159 1},
4160 };
4161
4162 for (auto test_case : test_cases) {
4163 LoadHTML(test_case.html);
4164
4165 WebFrame* web_frame = GetMainFrame();
4166 ASSERT_NE(nullptr, web_frame);
4167
4168 FormCache form_cache(*web_frame);
4169 std::vector<FormData> forms = form_cache.ExtractNewForms();
4170 EXPECT_EQ(test_case.expected_forms, forms.size());
4171 }
4172 }
4173
4131 } // namespace form_util 4174 } // namespace form_util
4132 } // namespace autofill 4175 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | components/autofill/content/renderer/form_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698