| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ASSERT_EQ(1u, passwords_map.size()); | 110 ASSERT_EQ(1u, passwords_map.size()); |
| 111 const std::vector<autofill::PasswordForm>& passwords_vector = | 111 const std::vector<autofill::PasswordForm>& passwords_vector = |
| 112 passwords_map.begin()->second; | 112 passwords_map.begin()->second; |
| 113 ASSERT_EQ(1u, passwords_vector.size()); | 113 ASSERT_EQ(1u, passwords_vector.size()); |
| 114 const autofill::PasswordForm& form = passwords_vector[0]; | 114 const autofill::PasswordForm& form = passwords_vector[0]; |
| 115 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); | 115 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); |
| 116 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); | 116 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); |
| 117 EXPECT_FALSE(form.skip_zero_click); | 117 EXPECT_FALSE(form.skip_zero_click); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // TODO(crbug.com/626759): flakily failing on Mac. | 120 |
| 121 #if defined(OS_MACOSX) | |
| 122 #define MAYBE_AutoSigninOldCredentialAndNavigation \ | |
| 123 DISABLED_AutoSigninOldCredentialAndNavigation | |
| 124 #else | |
| 125 #define MAYBE_AutoSigninOldCredentialAndNavigation \ | |
| 126 AutoSigninOldCredentialAndNavigation | |
| 127 #endif | |
| 128 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, | 121 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, |
| 129 MAYBE_AutoSigninOldCredentialAndNavigation) { | 122 AutoSigninOldCredentialAndNavigation) { |
| 130 // Save credentials with 'skip_zero_click' false. | 123 // Save credentials with 'skip_zero_click' false. |
| 131 scoped_refptr<password_manager::TestPasswordStore> password_store = | 124 scoped_refptr<password_manager::TestPasswordStore> password_store = |
| 132 static_cast<password_manager::TestPasswordStore*>( | 125 static_cast<password_manager::TestPasswordStore*>( |
| 133 PasswordStoreFactory::GetForProfile( | 126 PasswordStoreFactory::GetForProfile( |
| 134 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 127 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
| 135 autofill::PasswordForm signin_form; | 128 autofill::PasswordForm signin_form; |
| 136 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 129 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 137 signin_form.password_value = base::ASCIIToUTF16("password"); | 130 signin_form.password_value = base::ASCIIToUTF16("password"); |
| 138 signin_form.username_value = base::ASCIIToUTF16("user"); | 131 signin_form.username_value = base::ASCIIToUTF16("user"); |
| 139 signin_form.origin = embedded_test_server()->base_url(); | 132 signin_form.origin = embedded_test_server()->base_url(); |
| 140 signin_form.skip_zero_click = false; | 133 signin_form.skip_zero_click = false; |
| 141 password_store->AddLogin(signin_form); | 134 password_store->AddLogin(signin_form); |
| 142 | 135 |
| 143 // Enable 'auto signin' for the profile. | 136 // Enable 'auto signin' for the profile. |
| 144 password_bubble_experiment::RecordAutoSignInPromptFirstRunExperienceWasShown( | 137 password_bubble_experiment::RecordAutoSignInPromptFirstRunExperienceWasShown( |
| 145 browser()->profile()->GetPrefs()); | 138 browser()->profile()->GetPrefs()); |
| 146 | 139 |
| 147 NavigateToFile("/password/password_form.html"); | 140 NavigateToFile("/password/password_form.html"); |
| 148 std::string fill_password = | 141 std::string fill_password = |
| 149 "document.getElementById('username_field').value = 'trash';" | 142 "document.getElementById('username_field').value = 'trash';" |
| 150 "document.getElementById('password_field').value = 'trash';"; | 143 "document.getElementById('password_field').value = 'trash';"; |
| 151 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); | 144 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); |
| 152 | 145 |
| 153 // Call the API to trigger the notification to the client. | 146 // Call the API with a delay to trigger the notification to the client. The |
| 147 // delay ensures that parsing password forms won't happen again after the API |
| 148 // call making the test flaky. |
| 154 ASSERT_TRUE(content::ExecuteScript( | 149 ASSERT_TRUE(content::ExecuteScript( |
| 155 RenderViewHost(), | 150 RenderViewHost(), |
| 156 "navigator.credentials.get({password: true})" | 151 "setTimeout( function() {" |
| 157 ".then(cred => window.location = '/password/done.html')")); | 152 "navigator.credentials.get({password: true})" |
| 153 ".then(cred => window.location = '/password/done.html');" |
| 154 "}, 1000)")); |
| 158 | 155 |
| 159 NavigationObserver observer(WebContents()); | 156 NavigationObserver observer(WebContents()); |
| 160 observer.SetPathToWaitFor("/password/done.html"); | 157 observer.SetPathToWaitFor("/password/done.html"); |
| 161 observer.Wait(); | 158 observer.Wait(); |
| 162 | 159 |
| 163 std::unique_ptr<BubbleObserver> prompt_observer( | 160 std::unique_ptr<BubbleObserver> prompt_observer( |
| 164 new BubbleObserver(WebContents())); | 161 new BubbleObserver(WebContents())); |
| 165 // The autofill password manager shouldn't react to the successful login. | 162 // The autofill password manager shouldn't react to the successful login. |
| 166 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 163 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); |
| 167 } | 164 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 signin_form.skip_zero_click = false; | 268 signin_form.skip_zero_click = false; |
| 272 signin_form.times_used = 1; | 269 signin_form.times_used = 1; |
| 273 signin_form.password_value = base::ASCIIToUTF16("API"); | 270 signin_form.password_value = base::ASCIIToUTF16("API"); |
| 274 password_manager::TestPasswordStore::PasswordMap stored = | 271 password_manager::TestPasswordStore::PasswordMap stored = |
| 275 password_store->stored_passwords(); | 272 password_store->stored_passwords(); |
| 276 ASSERT_EQ(1u, stored.size()); | 273 ASSERT_EQ(1u, stored.size()); |
| 277 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); | 274 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); |
| 278 } | 275 } |
| 279 | 276 |
| 280 } // namespace | 277 } // namespace |
| OLD | NEW |