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

Side by Side Diff: trunk/src/chrome/browser/password_manager/password_manager_unittest.cc

Issue 130183003: Revert 248117 "Password manager now ignores autocomplete='off' b..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.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 "chrome/browser/password_manager/mock_password_store.h" 10 #include "chrome/browser/password_manager/mock_password_store.h"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 EXPECT_CALL(delegate_, FillPasswordForm(_)); 497 EXPECT_CALL(delegate_, FillPasswordForm(_));
498 EXPECT_CALL(*store_.get(), 498 EXPECT_CALL(*store_.get(),
499 GetLogins(_, testing::Eq(PasswordStore::DISALLOW_PROMPT), _)) 499 GetLogins(_, testing::Eq(PasswordStore::DISALLOW_PROMPT), _))
500 .WillRepeatedly(DoAll(WithArg<2>(InvokeConsumer(result)), Return())); 500 .WillRepeatedly(DoAll(WithArg<2>(InvokeConsumer(result)), Return()));
501 std::vector<PasswordForm> observed; 501 std::vector<PasswordForm> observed;
502 PasswordForm form(MakeSimpleForm()); 502 PasswordForm form(MakeSimpleForm());
503 observed.push_back(form); 503 observed.push_back(form);
504 manager()->OnPasswordFormsParsed(observed); 504 manager()->OnPasswordFormsParsed(observed);
505 } 505 }
506 506
507 TEST_F(PasswordManagerTest, FormSavedWithAutocompleteOff) { 507 TEST_F(PasswordManagerTest, FormNotSavedAutocompleteOff) {
508 // Test password form with non-generated password will be saved even if 508 // Test password form with non-generated password will not be saved if
509 // autocomplete=off. 509 // autocomplete=off.
510 std::vector<PasswordForm*> result; // Empty password store. 510 std::vector<PasswordForm*> result; // Empty password store.
511 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0)); 511 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0));
512 EXPECT_CALL(*store_.get(), GetLogins(_, _, _)) 512 EXPECT_CALL(*store_.get(), GetLogins(_, _, _))
513 .WillOnce(DoAll(WithArg<2>(InvokeConsumer(result)), Return())); 513 .WillOnce(DoAll(WithArg<2>(InvokeConsumer(result)), Return()));
514 std::vector<PasswordForm> observed; 514 std::vector<PasswordForm> observed;
515 PasswordForm form(MakeSimpleForm()); 515 PasswordForm form(MakeSimpleForm());
516 form.password_autocomplete_set = false; 516 form.password_autocomplete_set = false;
517 observed.push_back(form); 517 observed.push_back(form);
518 manager()->OnPasswordFormsParsed(observed); // The initial load. 518 manager()->OnPasswordFormsParsed(observed); // The initial load.
519 manager()->OnPasswordFormsRendered(observed); // The initial layout. 519 manager()->OnPasswordFormsRendered(observed); // The initial layout.
520 520
521 // And the form submit contract is to call ProvisionallySavePassword. 521 // And the form submit contract is to call ProvisionallySavePassword.
522 manager()->ProvisionallySavePassword(form); 522 manager()->ProvisionallySavePassword(form);
523 523
524 // Password form should be saved. 524 // Password form should not be saved.
525 EXPECT_CALL(delegate_, 525 EXPECT_CALL(delegate_,
526 AddSavePasswordInfoBarIfPermitted(_)).Times(Exactly(1)); 526 AddSavePasswordInfoBarIfPermitted(_)).Times(Exactly(0));
527 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))).Times(Exactly(0)); 527 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))).Times(Exactly(0));
528 528
529 // Now the password manager waits for the navigation to complete. 529 // Now the password manager waits for the navigation to complete.
530 observed.clear(); 530 observed.clear();
531 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. 531 manager()->OnPasswordFormsParsed(observed); // The post-navigation load.
532 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. 532 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout.
533 } 533 }
534 534
535 TEST_F(PasswordManagerTest, GeneratedPasswordFormSavedAutocompleteOff) { 535 TEST_F(PasswordManagerTest, GeneratedPasswordFormSavedAutocompleteOff) {
536 // Test password form with generated password will still be saved if 536 // Test password form with generated password will still be saved if
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 manager()->ProvisionallySavePassword(login_form); 588 manager()->ProvisionallySavePassword(login_form);
589 589
590 PasswordForm failed_login_form(MakeTwitterFailedLoginForm()); 590 PasswordForm failed_login_form(MakeTwitterFailedLoginForm());
591 observed.clear(); 591 observed.clear();
592 observed.push_back(failed_login_form); 592 observed.push_back(failed_login_form);
593 // A PasswordForm appears, and is visible in the layout: 593 // A PasswordForm appears, and is visible in the layout:
594 // No expected calls to the PasswordStore... 594 // No expected calls to the PasswordStore...
595 manager()->OnPasswordFormsParsed(observed); 595 manager()->OnPasswordFormsParsed(observed);
596 manager()->OnPasswordFormsRendered(observed); 596 manager()->OnPasswordFormsRendered(observed);
597 } 597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698