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

Side by Side Diff: chrome/browser/password_manager/credential_manager_browsertest.cc

Issue 2166823004: Place WaitForPasswordStore() before checking the store/prompt in CredentialManagerBrowserTest* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential( 97 PasswordsModelDelegateFromWebContents(WebContents())->ChooseCredential(
98 signin_form, 98 signin_form,
99 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 99 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
100 100
101 NavigationObserver observer(WebContents()); 101 NavigationObserver observer(WebContents());
102 observer.SetPathToWaitFor("/password/done.html"); 102 observer.SetPathToWaitFor("/password/done.html");
103 observer.Wait(); 103 observer.Wait();
104 104
105 // Verify that the form's 'skip_zero_click' is updated and not overwritten 105 // Verify that the form's 'skip_zero_click' is updated and not overwritten
106 // by the autofill password manager on successful login. 106 // by the autofill password manager on successful login.
107 auto& passwords_map = password_store->stored_passwords(); 107 WaitForPasswordStore();
108 password_manager::TestPasswordStore::PasswordMap passwords_map =
109 password_store->stored_passwords();
108 ASSERT_EQ(1u, passwords_map.size()); 110 ASSERT_EQ(1u, passwords_map.size());
109 auto& passwords_vector = passwords_map.begin()->second; 111 const std::vector<autofill::PasswordForm>& passwords_vector =
112 passwords_map.begin()->second;
110 ASSERT_EQ(1u, passwords_vector.size()); 113 ASSERT_EQ(1u, passwords_vector.size());
111 const autofill::PasswordForm& form = passwords_vector[0]; 114 const autofill::PasswordForm& form = passwords_vector[0];
112 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); 115 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value);
113 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); 116 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value);
114 EXPECT_FALSE(form.skip_zero_click); 117 EXPECT_FALSE(form.skip_zero_click);
115 } 118 }
116 119
117 // TODO(crbug.com/626759): flakily failing on Mac. 120 // TODO(crbug.com/626759): flakily failing on Mac.
118 #if defined(OS_MACOSX) 121 #if defined(OS_MACOSX)
119 #define MAYBE_AutoSigninOldCredentialAndNavigation \ 122 #define MAYBE_AutoSigninOldCredentialAndNavigation \
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 std::string fill_password = 173 std::string fill_password =
171 "document.getElementById('username_field').value = 'user';" 174 "document.getElementById('username_field').value = 'user';"
172 "document.getElementById('password_field').value = '12345';"; 175 "document.getElementById('password_field').value = '12345';";
173 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); 176 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password));
174 177
175 // Call the API to save the form. 178 // Call the API to save the form.
176 ASSERT_TRUE(content::ExecuteScript( 179 ASSERT_TRUE(content::ExecuteScript(
177 RenderViewHost(), 180 RenderViewHost(),
178 "var c = new PasswordCredential({ id: 'user', password: '12345' });" 181 "var c = new PasswordCredential({ id: 'user', password: '12345' });"
179 "navigator.credentials.store(c);")); 182 "navigator.credentials.store(c);"));
183 // Wait for the password store before checking the prompt because it pops up
184 // after the store replies.
185 WaitForPasswordStore();
180 std::unique_ptr<BubbleObserver> prompt_observer( 186 std::unique_ptr<BubbleObserver> prompt_observer(
181 new BubbleObserver(WebContents())); 187 new BubbleObserver(WebContents()));
182 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); 188 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
183 prompt_observer->Dismiss(); 189 prompt_observer->Dismiss();
184 190
185 NavigationObserver form_submit_observer(WebContents()); 191 NavigationObserver form_submit_observer(WebContents());
186 ASSERT_TRUE(content::ExecuteScript( 192 ASSERT_TRUE(content::ExecuteScript(
187 RenderViewHost(), 193 RenderViewHost(),
188 "document.getElementById('input_submit_button').click();")); 194 "document.getElementById('input_submit_button').click();"));
189 form_submit_observer.Wait(); 195 form_submit_observer.Wait();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // API should suppress the autofill password manager and overwrite the 234 // API should suppress the autofill password manager and overwrite the
229 // password. 235 // password.
230 NavigationObserver form_submit_observer(WebContents()); 236 NavigationObserver form_submit_observer(WebContents());
231 ASSERT_TRUE(content::ExecuteScript( 237 ASSERT_TRUE(content::ExecuteScript(
232 RenderViewHost(), 238 RenderViewHost(),
233 "document.getElementById('username_field').value = 'user';" 239 "document.getElementById('username_field').value = 'user';"
234 "document.getElementById('password_field').value = 'autofill';" 240 "document.getElementById('password_field').value = 'autofill';"
235 "document.getElementById('input_submit_button').click();")); 241 "document.getElementById('input_submit_button').click();"));
236 form_submit_observer.Wait(); 242 form_submit_observer.Wait();
237 243
244 // Wait for the password store before checking the prompt because it pops up
245 // after the store replies.
246 WaitForPasswordStore();
238 std::unique_ptr<BubbleObserver> prompt_observer( 247 std::unique_ptr<BubbleObserver> prompt_observer(
239 new BubbleObserver(WebContents())); 248 new BubbleObserver(WebContents()));
240 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); 249 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
241 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); 250 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
242 WaitForPasswordStore();
243 signin_form.skip_zero_click = false; 251 signin_form.skip_zero_click = false;
244 signin_form.times_used = 1; 252 signin_form.times_used = 1;
245 signin_form.password_value = base::ASCIIToUTF16("API"); 253 signin_form.password_value = base::ASCIIToUTF16("API");
246 password_manager::TestPasswordStore::PasswordMap stored = 254 password_manager::TestPasswordStore::PasswordMap stored =
247 password_store->stored_passwords(); 255 password_store->stored_passwords();
248 ASSERT_EQ(1u, stored.size()); 256 ASSERT_EQ(1u, stored.size());
249 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); 257 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]);
250 } 258 }
251 259
252 } // namespace 260 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698