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

Side by Side Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 23432002: Generate passwords only for forms that autofill server marks as account creation forms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix password generation manager browser test. Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_metrics.h" 10 #include "components/autofill/core/browser/autofill_metrics.h"
(...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 field.form_control_type = "text"; 2254 field.form_control_type = "text";
2255 2255
2256 field.label = ASCIIToUTF16("email"); 2256 field.label = ASCIIToUTF16("email");
2257 field.name = ASCIIToUTF16("email"); 2257 field.name = ASCIIToUTF16("email");
2258 form.fields.push_back(field); 2258 form.fields.push_back(field);
2259 2259
2260 field.label = ASCIIToUTF16("First Name"); 2260 field.label = ASCIIToUTF16("First Name");
2261 field.name = ASCIIToUTF16("first"); 2261 field.name = ASCIIToUTF16("first");
2262 form.fields.push_back(field); 2262 form.fields.push_back(field);
2263 2263
2264 // Password fields shouldn't affect the signature. 2264 // Checkable fields shouldn't affect the signature.
2265 field.label = ASCIIToUTF16("Password"); 2265 field.label = ASCIIToUTF16("Select");
2266 field.name = ASCIIToUTF16("password"); 2266 field.name = ASCIIToUTF16("Select");
2267 field.form_control_type = "password"; 2267 field.form_control_type = "checkbox";
2268 field.is_checkable = true;
2268 form.fields.push_back(field); 2269 form.fields.push_back(field);
2269 2270
2270 form_structure.reset(new FormStructure(form)); 2271 form_structure.reset(new FormStructure(form));
2271 2272
2272 EXPECT_EQ(FormStructureTest::Hash64Bit( 2273 EXPECT_EQ(FormStructureTest::Hash64Bit(
2273 std::string("://&&email&first")), 2274 std::string("://&&email&first")),
2274 form_structure->FormSignature()); 2275 form_structure->FormSignature());
2275 2276
2276 form.origin = GURL(std::string("http://www.facebook.com")); 2277 form.origin = GURL(std::string("http://www.facebook.com"));
2277 form_structure.reset(new FormStructure(form)); 2278 form_structure.reset(new FormStructure(form));
2278 EXPECT_EQ(FormStructureTest::Hash64Bit( 2279 EXPECT_EQ(FormStructureTest::Hash64Bit(
2279 std::string("http://www.facebook.com&&email&first")), 2280 std::string("http://www.facebook.com&&email&first")),
2280 form_structure->FormSignature()); 2281 form_structure->FormSignature());
2281 2282
2282 form.action = GURL(std::string("https://login.facebook.com/path")); 2283 form.action = GURL(std::string("https://login.facebook.com/path"));
2283 form_structure.reset(new FormStructure(form)); 2284 form_structure.reset(new FormStructure(form));
2284 EXPECT_EQ(FormStructureTest::Hash64Bit( 2285 EXPECT_EQ(FormStructureTest::Hash64Bit(
2285 std::string("https://login.facebook.com&&email&first")), 2286 std::string("https://login.facebook.com&&email&first")),
2286 form_structure->FormSignature()); 2287 form_structure->FormSignature());
2287 2288
2288 form.name = ASCIIToUTF16("login_form"); 2289 form.name = ASCIIToUTF16("login_form");
2289 form_structure.reset(new FormStructure(form)); 2290 form_structure.reset(new FormStructure(form));
2290 EXPECT_EQ(FormStructureTest::Hash64Bit( 2291 EXPECT_EQ(FormStructureTest::Hash64Bit(
2291 std::string("https://login.facebook.com&login_form&email&first")), 2292 std::string("https://login.facebook.com&login_form&email&first")),
2292 form_structure->FormSignature()); 2293 form_structure->FormSignature());
2293 2294
2295 field.is_checkable = false;
2294 field.label = ASCIIToUTF16("Random Field label"); 2296 field.label = ASCIIToUTF16("Random Field label");
2295 field.name = ASCIIToUTF16("random1234"); 2297 field.name = ASCIIToUTF16("random1234");
2296 field.form_control_type = "text"; 2298 field.form_control_type = "text";
2297 form.fields.push_back(field); 2299 form.fields.push_back(field);
2298 field.label = ASCIIToUTF16("Random Field label2"); 2300 field.label = ASCIIToUTF16("Random Field label2");
2299 field.name = ASCIIToUTF16("random12345"); 2301 field.name = ASCIIToUTF16("random12345");
2300 form.fields.push_back(field); 2302 form.fields.push_back(field);
2301 field.label = ASCIIToUTF16("Random Field label3"); 2303 field.label = ASCIIToUTF16("Random Field label3");
2302 field.name = ASCIIToUTF16("1random12345678"); 2304 field.name = ASCIIToUTF16("1random12345678");
2303 form.fields.push_back(field); 2305 form.fields.push_back(field);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 form.method = ASCIIToUTF16("POST"); 2351 form.method = ASCIIToUTF16("POST");
2350 form.origin = GURL("http://cool.com"); 2352 form.origin = GURL("http://cool.com");
2351 form.action = form.origin.Resolve("/login"); 2353 form.action = form.origin.Resolve("/login");
2352 2354
2353 FormFieldData field; 2355 FormFieldData field;
2354 field.label = ASCIIToUTF16("username"); 2356 field.label = ASCIIToUTF16("username");
2355 field.name = ASCIIToUTF16("username"); 2357 field.name = ASCIIToUTF16("username");
2356 field.form_control_type = "text"; 2358 field.form_control_type = "text";
2357 form.fields.push_back(field); 2359 form.fields.push_back(field);
2358 2360
2359 field.label = ASCIIToUTF16("password"); 2361 field.label = ASCIIToUTF16("select");
2360 field.name = ASCIIToUTF16("password"); 2362 field.name = ASCIIToUTF16("select");
2361 field.form_control_type = "password"; 2363 field.form_control_type = "checkbox";
2364 field.is_checkable = true;
2362 form.fields.push_back(field); 2365 form.fields.push_back(field);
2363 2366
2364 field.label = base::string16(); 2367 field.label = base::string16();
2365 field.name = ASCIIToUTF16("email"); 2368 field.name = ASCIIToUTF16("email");
2366 field.form_control_type = "text"; 2369 field.form_control_type = "text";
2370 field.is_checkable = false;
2367 form.fields.push_back(field); 2371 form.fields.push_back(field);
2368 2372
2369 ScopedVector<FormStructure> forms; 2373 ScopedVector<FormStructure> forms;
2370 forms.push_back(new FormStructure(form)); 2374 forms.push_back(new FormStructure(form));
2371 std::vector<std::string> encoded_signatures; 2375 std::vector<std::string> encoded_signatures;
2372 std::string encoded_xml; 2376 std::string encoded_xml;
2373 2377
2374 const char * const kSignature = "18006745212084723782"; 2378 const char * const kSignature = "18006745212084723782";
2375 const char * const kResponse = 2379 const char * const kResponse =
2376 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery " 2380 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery "
2377 "clientversion=\"6.1.1715.1442/en (GGLL)\" accepts=\"e\"><form " 2381 "clientversion=\"6.1.1715.1442/en (GGLL)\" accepts=\"e\"><form "
2378 "signature=\"18006745212084723782\"><field signature=\"239111655\"/>" 2382 "signature=\"18006745212084723782\"><field signature=\"239111655\"/>"
2379 "<field signature=\"420638584\"/></form></autofillquery>"; 2383 "<field signature=\"420638584\"/></form></autofillquery>";
2380 ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), 2384 ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(),
2381 &encoded_signatures, 2385 &encoded_signatures,
2382 &encoded_xml)); 2386 &encoded_xml));
2383 ASSERT_EQ(1U, encoded_signatures.size()); 2387 ASSERT_EQ(1U, encoded_signatures.size());
2384 EXPECT_EQ(kSignature, encoded_signatures[0]); 2388 EXPECT_EQ(kSignature, encoded_signatures[0]);
2385 EXPECT_EQ(kResponse, encoded_xml); 2389 EXPECT_EQ(kResponse, encoded_xml);
2386 } 2390 }
2387 2391
2388 } // namespace autofill 2392 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/browser/test_autofill_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698