| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 std::string fill_password = | 85 std::string fill_password = |
| 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 ASSERT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, | 96 ASSERT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, |
| 96 PasswordsModelDelegateFromWebContents(WebContents())->GetState()); | 97 PasswordsModelDelegateFromWebContents(WebContents())->GetState()); |
| 97 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential( | 98 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential( |
| 98 signin_form, | 99 signin_form, |
| 99 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); | 100 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| 100 | 101 |
| 101 NavigationObserver observer(WebContents()); | 102 NavigationObserver observer(WebContents()); |
| 102 observer.SetPathToWaitFor("/password/done.html"); | 103 observer.SetPathToWaitFor("/password/done.html"); |
| 103 observer.Wait(); | 104 observer.Wait(); |
| 104 | 105 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 signin_form.skip_zero_click = false; | 269 signin_form.skip_zero_click = false; |
| 269 signin_form.times_used = 1; | 270 signin_form.times_used = 1; |
| 270 signin_form.password_value = base::ASCIIToUTF16("API"); | 271 signin_form.password_value = base::ASCIIToUTF16("API"); |
| 271 password_manager::TestPasswordStore::PasswordMap stored = | 272 password_manager::TestPasswordStore::PasswordMap stored = |
| 272 password_store->stored_passwords(); | 273 password_store->stored_passwords(); |
| 273 ASSERT_EQ(1u, stored.size()); | 274 ASSERT_EQ(1u, stored.size()); |
| 274 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); | 275 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace | 278 } // namespace |
| OLD | NEW |