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

Side by Side Diff: components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc

Issue 2771833002: Password Manager should skip fields with credit card autocomplete attribute. (Closed)
Patch Set: Do not create string in HasAutocompleteAttributeValue Created 3 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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 1498
1499 TEST_F(MAYBE_PasswordFormConversionUtilsTest, TooManyFieldsToParseForm) { 1499 TEST_F(MAYBE_PasswordFormConversionUtilsTest, TooManyFieldsToParseForm) {
1500 PasswordFormBuilder builder(kTestFormActionURL); 1500 PasswordFormBuilder builder(kTestFormActionURL);
1501 for (size_t i = 0; i < form_util::kMaxParseableFields + 1; ++i) 1501 for (size_t i = 0; i < form_util::kMaxParseableFields + 1; ++i)
1502 builder.AddTextField("id", "value", "autocomplete"); 1502 builder.AddTextField("id", "value", "autocomplete");
1503 std::unique_ptr<PasswordForm> password_form = 1503 std::unique_ptr<PasswordForm> password_form =
1504 LoadHTMLAndConvertForm(builder.ProduceHTML(), nullptr, false); 1504 LoadHTMLAndConvertForm(builder.ProduceHTML(), nullptr, false);
1505 EXPECT_FALSE(password_form); 1505 EXPECT_FALSE(password_form);
1506 } 1506 }
1507 1507
1508 TEST_F(MAYBE_PasswordFormConversionUtilsTest, OnlyCreditCardFields) {
1509 PasswordFormBuilder builder(kTestFormActionURL);
1510 builder.AddTextField("ccname", "johnsmith", "cc-name");
1511 builder.AddPasswordField("cc_security_code", "0123456789", "cc-csc");
1512 builder.AddSubmitButton("submit");
1513 std::string html = builder.ProduceHTML();
1514
1515 std::unique_ptr<PasswordForm> password_form =
1516 LoadHTMLAndConvertForm(html, nullptr, false);
1517 EXPECT_FALSE(password_form);
1518 }
1519
1520 TEST_F(MAYBE_PasswordFormConversionUtilsTest,
1521 FieldsWithAndWithoutCreditCardAttributes) {
1522 PasswordFormBuilder builder(kTestFormActionURL);
1523 builder.AddTextField("username", "johnsmith", nullptr);
1524 builder.AddTextField("ccname", "john_smith", "cc-name");
1525 builder.AddPasswordField("cc_security_code", "0123456789", "random cc-csc");
1526 builder.AddPasswordField("password", "secret", nullptr);
1527 builder.AddSubmitButton("submit");
1528 std::string html = builder.ProduceHTML();
1529
1530 std::unique_ptr<PasswordForm> password_form =
1531 LoadHTMLAndConvertForm(html, nullptr, false);
1532
1533 ASSERT_TRUE(password_form);
1534
1535 EXPECT_EQ(base::UTF8ToUTF16("username"), password_form->username_element);
1536 EXPECT_EQ(base::UTF8ToUTF16("johnsmith"), password_form->username_value);
1537 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element);
1538 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value);
1539 }
1540
1508 } // namespace autofill 1541 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698