| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/password_manager/password_manager_test_base.h" | 7 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 8 #include "chrome/browser/password_manager/password_store_factory.h" | 8 #include "chrome/browser/password_manager/password_store_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 base::RunLoop run_loop_; | 37 base::RunLoop run_loop_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver); | 39 DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase { | 42 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase { |
| 43 public: | 43 public: |
| 44 CredentialManagerBrowserTest() = default; | 44 CredentialManagerBrowserTest() = default; |
| 45 | 45 |
| 46 bool IsShowingAccountChooser() { | 46 bool IsShowingAccountChooser() { |
| 47 return PasswordsModelDelegateFromWebContents(WebContents())->GetState() == | 47 return PasswordsModelDelegateFromWebContents(WebContents())-> |
| 48 password_manager::ui::CREDENTIAL_REQUEST_STATE; | 48 GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Make sure that the password store processed all the previous calls which | 51 // Make sure that the password store processed all the previous calls which |
| 52 // are executed on another thread. | 52 // are executed on another thread. |
| 53 void WaitForPasswordStore() { | 53 void WaitForPasswordStore() { |
| 54 scoped_refptr<password_manager::PasswordStore> password_store = | 54 scoped_refptr<password_manager::PasswordStore> password_store = |
| 55 PasswordStoreFactory::GetForProfile( | 55 PasswordStoreFactory::GetForProfile( |
| 56 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS); | 56 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS); |
| 57 PasswordStoreResultsObserver syncer; | 57 PasswordStoreResultsObserver syncer; |
| 58 password_store->GetAutofillableLoginsWithAffiliatedRealms(&syncer); | 58 password_store->GetAutofillableLoginsWithAffiliatedRealms(&syncer); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 "document.getElementById('username_field').value = 'user';" | 86 "document.getElementById('username_field').value = 'user';" |
| 87 "document.getElementById('password_field').value = 'password';"; | 87 "document.getElementById('password_field').value = 'password';"; |
| 88 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); | 88 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); |
| 89 | 89 |
| 90 // Call the API to trigger the notification to the client. | 90 // Call the API to trigger the notification to the client. |
| 91 ASSERT_TRUE(content::ExecuteScript( | 91 ASSERT_TRUE(content::ExecuteScript( |
| 92 RenderViewHost(), | 92 RenderViewHost(), |
| 93 "navigator.credentials.get({password: true})" | 93 "navigator.credentials.get({password: true})" |
| 94 ".then(cred => window.location = '/password/done.html')")); | 94 ".then(cred => window.location = '/password/done.html')")); |
| 95 WaitForPasswordStore(); | 95 WaitForPasswordStore(); |
| 96 ASSERT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, | 96 ASSERT_EQ( |
| 97 PasswordsModelDelegateFromWebContents(WebContents())->GetState()); | 97 password_manager::ui::CREDENTIAL_REQUEST_STATE, |
| 98 PasswordsModelDelegateFromWebContents(WebContents())->GetState()); |
| 98 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential( | 99 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential( |
| 99 signin_form, | 100 signin_form, |
| 100 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); | 101 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| 101 | 102 |
| 102 NavigationObserver observer(WebContents()); | 103 NavigationObserver observer(WebContents()); |
| 103 observer.SetPathToWaitFor("/password/done.html"); | 104 observer.SetPathToWaitFor("/password/done.html"); |
| 104 observer.Wait(); | 105 observer.Wait(); |
| 105 | 106 |
| 106 // Verify that the form's 'skip_zero_click' is updated and not overwritten | 107 // Verify that the form's 'skip_zero_click' is updated and not overwritten |
| 107 // by the autofill password manager on successful login. | 108 // by the autofill password manager on successful login. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 signin_form.skip_zero_click = false; | 249 signin_form.skip_zero_click = false; |
| 249 signin_form.times_used = 1; | 250 signin_form.times_used = 1; |
| 250 signin_form.password_value = base::ASCIIToUTF16("API"); | 251 signin_form.password_value = base::ASCIIToUTF16("API"); |
| 251 password_manager::TestPasswordStore::PasswordMap stored = | 252 password_manager::TestPasswordStore::PasswordMap stored = |
| 252 password_store->stored_passwords(); | 253 password_store->stored_passwords(); |
| 253 ASSERT_EQ(1u, stored.size()); | 254 ASSERT_EQ(1u, stored.size()); |
| 254 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); | 255 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); |
| 255 } | 256 } |
| 256 | 257 |
| 257 } // namespace | 258 } // namespace |
| OLD | NEW |