Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/password_manager/password_manager_test_base.h" | 5 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // ManagePasswordsUIController subclass to capture the UI events. | 61 // ManagePasswordsUIController subclass to capture the UI events. |
| 62 class CustomManagePasswordsUIController : public ManagePasswordsUIController { | 62 class CustomManagePasswordsUIController : public ManagePasswordsUIController { |
| 63 public: | 63 public: |
| 64 explicit CustomManagePasswordsUIController( | 64 explicit CustomManagePasswordsUIController( |
| 65 content::WebContents* web_contents); | 65 content::WebContents* web_contents); |
| 66 | 66 |
| 67 void WaitForState(password_manager::ui::State target_state); | 67 void WaitForState(password_manager::ui::State target_state); |
| 68 | 68 |
| 69 void WaitForFallbackForSaving(); | |
| 70 | |
| 71 bool was_prompt_automatically_shown() { | |
| 72 return was_prompt_automatically_shown_; | |
| 73 } | |
| 74 | |
| 69 private: | 75 private: |
| 70 // PasswordsClientUIDelegate: | 76 // PasswordsClientUIDelegate: |
| 71 void OnPasswordSubmitted( | 77 void OnPasswordSubmitted( |
| 72 std::unique_ptr<password_manager::PasswordFormManager> form_manager) | 78 std::unique_ptr<password_manager::PasswordFormManager> form_manager) |
| 73 override; | 79 override; |
| 80 void OnUpdatePasswordSubmitted( | |
| 81 std::unique_ptr<password_manager::PasswordFormManager> form_manager) | |
| 82 override; | |
| 83 void OnShowManualFallbackForSaving( | |
| 84 std::unique_ptr<password_manager::PasswordFormManager> form_manager, | |
| 85 bool has_generated_password, | |
| 86 bool is_update) override; | |
| 74 bool OnChooseCredentials( | 87 bool OnChooseCredentials( |
| 75 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 88 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 76 const GURL& origin, | 89 const GURL& origin, |
| 77 const ManagePasswordsState::CredentialsCallback& callback) override; | 90 const ManagePasswordsState::CredentialsCallback& callback) override; |
| 78 void OnPasswordAutofilled( | 91 void OnPasswordAutofilled( |
| 79 const std::map<base::string16, const autofill::PasswordForm*>& | 92 const std::map<base::string16, const autofill::PasswordForm*>& |
| 80 password_form_map, | 93 password_form_map, |
| 81 const GURL& origin, | 94 const GURL& origin, |
| 82 const std::vector<const autofill::PasswordForm*>* federated_matches) | 95 const std::vector<const autofill::PasswordForm*>* federated_matches) |
| 83 override; | 96 override; |
| 84 | 97 |
| 85 // The loop to be stopped when the target state is observed. | 98 void CheckIfTargetStateIsObserved(password_manager::ui::State new_state); |
| 99 | |
| 100 // Should be called before initialization of a waiting loop. | |
| 101 void CheckThatThereIsNoAnotherWaitLoop(); | |
|
vasilii
2017/08/07 17:13:24
Why should it be called? What are you trying to pr
kolos1
2017/08/08 12:37:16
Yes, it is not possible to call a sequence of two
| |
| 102 | |
| 103 // The loop to be stopped when the target state or fallback is observed. | |
| 86 base::RunLoop* run_loop_; | 104 base::RunLoop* run_loop_; |
| 87 | 105 |
| 88 // The state CustomManagePasswordsUIController is currently waiting for. | 106 // The state CustomManagePasswordsUIController is currently waiting for. |
| 107 // Manual fallback events don't interrupt waiting. | |
| 89 password_manager::ui::State target_state_; | 108 password_manager::ui::State target_state_; |
| 90 | 109 |
| 110 // True iff showing fallback is waited. | |
| 111 bool wait_for_fallback_; | |
| 112 | |
| 113 // True iff a prompt was automatically shown. | |
| 114 bool was_prompt_automatically_shown_; | |
| 115 | |
| 91 DISALLOW_COPY_AND_ASSIGN(CustomManagePasswordsUIController); | 116 DISALLOW_COPY_AND_ASSIGN(CustomManagePasswordsUIController); |
| 92 }; | 117 }; |
| 93 | 118 |
| 94 CustomManagePasswordsUIController::CustomManagePasswordsUIController( | 119 CustomManagePasswordsUIController::CustomManagePasswordsUIController( |
| 95 content::WebContents* web_contents) | 120 content::WebContents* web_contents) |
| 96 : ManagePasswordsUIController(web_contents), | 121 : ManagePasswordsUIController(web_contents), |
| 97 run_loop_(nullptr), | 122 run_loop_(nullptr), |
| 98 target_state_(password_manager::ui::INACTIVE_STATE) { | 123 target_state_(password_manager::ui::INACTIVE_STATE), |
| 124 wait_for_fallback_(false), | |
| 125 was_prompt_automatically_shown_(false) { | |
| 99 // Attach CustomManagePasswordsUIController to |web_contents| so the default | 126 // Attach CustomManagePasswordsUIController to |web_contents| so the default |
| 100 // ManagePasswordsUIController isn't created. | 127 // ManagePasswordsUIController isn't created. |
| 101 // Do not silently replace an existing ManagePasswordsUIController because it | 128 // Do not silently replace an existing ManagePasswordsUIController because it |
| 102 // unregisters itself in WebContentsDestroyed(). | 129 // unregisters itself in WebContentsDestroyed(). |
| 103 EXPECT_FALSE(web_contents->GetUserData(UserDataKey())); | 130 EXPECT_FALSE(web_contents->GetUserData(UserDataKey())); |
| 104 web_contents->SetUserData(UserDataKey(), base::WrapUnique(this)); | 131 web_contents->SetUserData(UserDataKey(), base::WrapUnique(this)); |
| 105 } | 132 } |
| 106 | 133 |
| 107 void CustomManagePasswordsUIController::WaitForState( | 134 void CustomManagePasswordsUIController::WaitForState( |
| 108 password_manager::ui::State target_state) { | 135 password_manager::ui::State target_state) { |
| 136 if (GetState() == target_state) | |
|
vasilii
2017/08/07 17:13:24
I'm concerned that if there is a manual fallback c
kolos1
2017/08/08 12:37:16
Alright. Fixed.
| |
| 137 return; | |
| 138 CheckThatThereIsNoAnotherWaitLoop(); | |
| 139 | |
| 109 base::RunLoop run_loop; | 140 base::RunLoop run_loop; |
| 110 target_state_ = target_state; | 141 target_state_ = target_state; |
| 111 run_loop_ = &run_loop; | 142 run_loop_ = &run_loop; |
| 112 run_loop_->Run(); | 143 run_loop_->Run(); |
| 113 } | 144 } |
| 114 | 145 |
| 146 void CustomManagePasswordsUIController::WaitForFallbackForSaving() { | |
| 147 if (!was_prompt_automatically_shown_ && | |
| 148 GetState() == password_manager::ui::PENDING_PASSWORD_STATE) | |
| 149 return; | |
| 150 | |
| 151 CheckThatThereIsNoAnotherWaitLoop(); | |
| 152 | |
| 153 base::RunLoop run_loop; | |
| 154 wait_for_fallback_ = true; | |
| 155 run_loop_ = &run_loop; | |
| 156 run_loop_->Run(); | |
| 157 } | |
| 158 | |
| 115 void CustomManagePasswordsUIController::OnPasswordSubmitted( | 159 void CustomManagePasswordsUIController::OnPasswordSubmitted( |
| 116 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { | 160 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { |
| 117 if (target_state_ == password_manager::ui::PENDING_PASSWORD_STATE) { | 161 CheckIfTargetStateIsObserved(password_manager::ui::PENDING_PASSWORD_STATE); |
| 162 was_prompt_automatically_shown_ = true; | |
| 163 return ManagePasswordsUIController::OnPasswordSubmitted( | |
| 164 std::move(form_manager)); | |
| 165 } | |
| 166 | |
| 167 void CustomManagePasswordsUIController::OnUpdatePasswordSubmitted( | |
| 168 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { | |
| 169 CheckIfTargetStateIsObserved( | |
| 170 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); | |
| 171 was_prompt_automatically_shown_ = true; | |
| 172 return ManagePasswordsUIController::OnUpdatePasswordSubmitted( | |
| 173 std::move(form_manager)); | |
| 174 } | |
| 175 | |
| 176 void CustomManagePasswordsUIController::OnShowManualFallbackForSaving( | |
| 177 std::unique_ptr<password_manager::PasswordFormManager> form_manager, | |
| 178 bool has_generated_password, | |
| 179 bool is_update) { | |
| 180 if (wait_for_fallback_) { | |
|
vasilii
2017/08/07 17:13:23
Should we assign false?
kolos1
2017/08/08 12:37:16
Yep, created a method where all expectations are r
| |
| 118 run_loop_->Quit(); | 181 run_loop_->Quit(); |
| 119 run_loop_ = nullptr; | 182 run_loop_ = nullptr; |
| 120 target_state_ = password_manager::ui::INACTIVE_STATE; | 183 target_state_ = password_manager::ui::INACTIVE_STATE; |
| 121 } | 184 } |
| 122 return ManagePasswordsUIController::OnPasswordSubmitted( | 185 |
| 123 std::move(form_manager)); | 186 ManagePasswordsUIController::OnShowManualFallbackForSaving( |
| 187 std::move(form_manager), has_generated_password, is_update); | |
| 124 } | 188 } |
| 125 | 189 |
| 126 bool CustomManagePasswordsUIController::OnChooseCredentials( | 190 bool CustomManagePasswordsUIController::OnChooseCredentials( |
| 127 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 191 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 128 const GURL& origin, | 192 const GURL& origin, |
| 129 const ManagePasswordsState::CredentialsCallback& callback) { | 193 const ManagePasswordsState::CredentialsCallback& callback) { |
| 130 if (target_state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 194 CheckIfTargetStateIsObserved(password_manager::ui::CREDENTIAL_REQUEST_STATE); |
| 131 run_loop_->Quit(); | |
| 132 run_loop_ = nullptr; | |
| 133 target_state_ = password_manager::ui::INACTIVE_STATE; | |
| 134 } | |
| 135 return ManagePasswordsUIController::OnChooseCredentials( | 195 return ManagePasswordsUIController::OnChooseCredentials( |
| 136 std::move(local_credentials), origin, callback); | 196 std::move(local_credentials), origin, callback); |
| 137 } | 197 } |
| 138 | 198 |
| 139 void CustomManagePasswordsUIController::OnPasswordAutofilled( | 199 void CustomManagePasswordsUIController::OnPasswordAutofilled( |
| 140 const std::map<base::string16, const autofill::PasswordForm*>& | 200 const std::map<base::string16, const autofill::PasswordForm*>& |
| 141 password_form_map, | 201 password_form_map, |
| 142 const GURL& origin, | 202 const GURL& origin, |
| 143 const std::vector<const autofill::PasswordForm*>* federated_matches) { | 203 const std::vector<const autofill::PasswordForm*>* federated_matches) { |
| 144 if (target_state_ == password_manager::ui::MANAGE_STATE) { | 204 CheckIfTargetStateIsObserved(password_manager::ui::MANAGE_STATE); |
| 205 return ManagePasswordsUIController::OnPasswordAutofilled( | |
| 206 password_form_map, origin, federated_matches); | |
| 207 } | |
| 208 | |
| 209 void CustomManagePasswordsUIController::CheckIfTargetStateIsObserved( | |
| 210 password_manager::ui::State new_state) { | |
| 211 if (target_state_ == new_state) { | |
| 145 run_loop_->Quit(); | 212 run_loop_->Quit(); |
| 146 run_loop_ = nullptr; | 213 run_loop_ = nullptr; |
| 147 target_state_ = password_manager::ui::INACTIVE_STATE; | 214 target_state_ = password_manager::ui::INACTIVE_STATE; |
| 148 } | 215 } |
| 149 return ManagePasswordsUIController::OnPasswordAutofilled( | 216 } |
| 150 password_form_map, origin, federated_matches); | 217 |
| 218 void CustomManagePasswordsUIController::CheckThatThereIsNoAnotherWaitLoop() { | |
| 219 DCHECK(!run_loop_); | |
| 220 DCHECK(target_state_ == password_manager::ui::INACTIVE_STATE); | |
| 221 DCHECK(!wait_for_fallback_); | |
| 151 } | 222 } |
| 152 | 223 |
| 153 void AddHSTSHostImpl( | 224 void AddHSTSHostImpl( |
| 154 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 225 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 155 const std::string& host) { | 226 const std::string& host) { |
| 156 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 227 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 157 net::TransportSecurityState* transport_security_state = | 228 net::TransportSecurityState* transport_security_state = |
| 158 request_context->GetURLRequestContext()->transport_security_state(); | 229 request_context->GetURLRequestContext()->transport_security_state(); |
| 159 if (!transport_security_state) { | 230 if (!transport_security_state) { |
| 160 ADD_FAILURE(); | 231 ADD_FAILURE(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 } | 268 } |
| 198 | 269 |
| 199 void NavigationObserver::Wait() { | 270 void NavigationObserver::Wait() { |
| 200 run_loop_.Run(); | 271 run_loop_.Run(); |
| 201 } | 272 } |
| 202 | 273 |
| 203 BubbleObserver::BubbleObserver(content::WebContents* web_contents) | 274 BubbleObserver::BubbleObserver(content::WebContents* web_contents) |
| 204 : passwords_ui_controller_( | 275 : passwords_ui_controller_( |
| 205 ManagePasswordsUIController::FromWebContents(web_contents)) {} | 276 ManagePasswordsUIController::FromWebContents(web_contents)) {} |
| 206 | 277 |
| 207 bool BubbleObserver::IsShowingSavePrompt() const { | 278 bool BubbleObserver::IsSavePromptAvailable() const { |
| 208 return passwords_ui_controller_->GetState() == | 279 return passwords_ui_controller_->GetState() == |
| 209 password_manager::ui::PENDING_PASSWORD_STATE; | 280 password_manager::ui::PENDING_PASSWORD_STATE; |
| 210 } | 281 } |
| 211 | 282 |
| 212 bool BubbleObserver::IsShowingUpdatePrompt() const { | 283 bool BubbleObserver::IsUpdatePromptAvailable() const { |
| 213 return passwords_ui_controller_->GetState() == | 284 return passwords_ui_controller_->GetState() == |
| 214 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | 285 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; |
| 215 } | 286 } |
| 216 | 287 |
| 288 bool BubbleObserver::IsSavePromptShownAutomatically() const { | |
| 289 if (!IsSavePromptAvailable()) | |
| 290 return false; | |
| 291 return static_cast<CustomManagePasswordsUIController*>( | |
| 292 passwords_ui_controller_) | |
| 293 ->was_prompt_automatically_shown(); | |
| 294 } | |
| 295 | |
| 296 bool BubbleObserver::IsUpdatePromptShownAutomatically() const { | |
| 297 if (!IsUpdatePromptAvailable()) | |
| 298 return false; | |
| 299 return static_cast<CustomManagePasswordsUIController*>( | |
| 300 passwords_ui_controller_) | |
| 301 ->was_prompt_automatically_shown(); | |
| 302 } | |
| 303 | |
| 217 void BubbleObserver::Dismiss() const { | 304 void BubbleObserver::Dismiss() const { |
| 218 passwords_ui_controller_->OnBubbleHidden(); | 305 passwords_ui_controller_->OnBubbleHidden(); |
| 219 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, | 306 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, |
| 220 passwords_ui_controller_->GetState()); | 307 passwords_ui_controller_->GetState()); |
| 221 } | 308 } |
| 222 | 309 |
| 223 void BubbleObserver::AcceptSavePrompt() const { | 310 void BubbleObserver::AcceptSavePrompt(bool expected_automatic_prompt) const { |
| 224 ASSERT_TRUE(IsShowingSavePrompt()); | 311 ASSERT_TRUE(expected_automatic_prompt ? IsSavePromptShownAutomatically() |
|
vasilii
2017/08/07 17:13:24
This assertion is only needed so that the test cra
kolos1
2017/08/08 12:37:16
Fixed.
| |
| 312 : IsSavePromptAvailable()); | |
| 225 passwords_ui_controller_->SavePassword( | 313 passwords_ui_controller_->SavePassword( |
| 226 passwords_ui_controller_->GetPendingPassword().username_value); | 314 passwords_ui_controller_->GetPendingPassword().username_value); |
| 227 EXPECT_FALSE(IsShowingSavePrompt()); | 315 EXPECT_FALSE(IsSavePromptAvailable()); |
| 228 } | 316 } |
| 229 | 317 |
| 230 void BubbleObserver::AcceptUpdatePrompt( | 318 void BubbleObserver::AcceptUpdatePrompt( |
| 231 const autofill::PasswordForm& form) const { | 319 const autofill::PasswordForm& form) const { |
| 232 ASSERT_TRUE(IsShowingUpdatePrompt()); | 320 ASSERT_TRUE(IsUpdatePromptShownAutomatically()); |
| 233 passwords_ui_controller_->UpdatePassword(form); | 321 passwords_ui_controller_->UpdatePassword(form); |
| 234 EXPECT_FALSE(IsShowingUpdatePrompt()); | 322 EXPECT_FALSE(IsUpdatePromptAvailable()); |
| 235 } | 323 } |
| 236 | 324 |
| 237 void BubbleObserver::WaitForAccountChooser() const { | 325 void BubbleObserver::WaitForAccountChooser() const { |
| 238 if (passwords_ui_controller_->GetState() == | |
| 239 password_manager::ui::CREDENTIAL_REQUEST_STATE) | |
| 240 return; | |
| 241 CustomManagePasswordsUIController* controller = | 326 CustomManagePasswordsUIController* controller = |
| 242 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 327 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 243 controller->WaitForState(password_manager::ui::CREDENTIAL_REQUEST_STATE); | 328 controller->WaitForState(password_manager::ui::CREDENTIAL_REQUEST_STATE); |
| 244 } | 329 } |
| 245 | 330 |
| 246 void BubbleObserver::WaitForManagementState() const { | 331 void BubbleObserver::WaitForManagementState() const { |
| 247 if (passwords_ui_controller_->GetState() == | |
| 248 password_manager::ui::MANAGE_STATE) | |
| 249 return; | |
| 250 CustomManagePasswordsUIController* controller = | 332 CustomManagePasswordsUIController* controller = |
| 251 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 333 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 252 controller->WaitForState(password_manager::ui::MANAGE_STATE); | 334 controller->WaitForState(password_manager::ui::MANAGE_STATE); |
| 253 } | 335 } |
| 254 | 336 |
| 255 void BubbleObserver::WaitForSavePrompt() const { | 337 void BubbleObserver::WaitForAutomaticSavePrompt() const { |
| 256 if (passwords_ui_controller_->GetState() == | |
| 257 password_manager::ui::PENDING_PASSWORD_STATE) | |
| 258 return; | |
| 259 CustomManagePasswordsUIController* controller = | 338 CustomManagePasswordsUIController* controller = |
| 260 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 339 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 261 controller->WaitForState(password_manager::ui::PENDING_PASSWORD_STATE); | 340 controller->WaitForState(password_manager::ui::PENDING_PASSWORD_STATE); |
| 262 } | 341 } |
| 263 | 342 |
| 343 void BubbleObserver::WaitForFallbackForSaving() const { | |
| 344 CustomManagePasswordsUIController* controller = | |
| 345 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | |
| 346 controller->WaitForFallbackForSaving(); | |
| 347 } | |
| 348 | |
| 264 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() | 349 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() |
| 265 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS), | 350 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS), |
| 266 web_contents_(nullptr) {} | 351 web_contents_(nullptr) {} |
| 267 | 352 |
| 268 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default; | 353 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default; |
| 269 | 354 |
| 270 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { | 355 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { |
| 271 // Use TestPasswordStore to remove a possible race. Normally the | 356 // Use TestPasswordStore to remove a possible race. Normally the |
| 272 // PasswordStore does its database manipulation on the DB thread, which | 357 // PasswordStore does its database manipulation on the DB thread, which |
| 273 // creates a possible race during navigation. Specifically the | 358 // creates a possible race during navigation. Specifically the |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 451 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
| 367 EXPECT_TRUE(password_store->IsEmpty()); | 452 EXPECT_TRUE(password_store->IsEmpty()); |
| 368 | 453 |
| 369 NavigateToFile(filename); | 454 NavigateToFile(filename); |
| 370 | 455 |
| 371 NavigationObserver observer(WebContents()); | 456 NavigationObserver observer(WebContents()); |
| 372 ASSERT_TRUE(content::ExecuteScript(RenderFrameHost(), submission_script)); | 457 ASSERT_TRUE(content::ExecuteScript(RenderFrameHost(), submission_script)); |
| 373 observer.Wait(); | 458 observer.Wait(); |
| 374 WaitForPasswordStore(); | 459 WaitForPasswordStore(); |
| 375 | 460 |
| 376 BubbleObserver(WebContents()).AcceptSavePrompt(); | 461 BubbleObserver(WebContents()) |
| 462 .AcceptSavePrompt(true /* expected_automatic_prompt */); | |
| 377 | 463 |
| 378 // Spin the message loop to make sure the password store had a chance to save | 464 // Spin the message loop to make sure the password store had a chance to save |
| 379 // the password. | 465 // the password. |
| 380 WaitForPasswordStore(); | 466 WaitForPasswordStore(); |
| 381 ASSERT_FALSE(password_store->IsEmpty()); | 467 ASSERT_FALSE(password_store->IsEmpty()); |
| 382 | 468 |
| 383 NavigateToFile(filename); | 469 NavigateToFile(filename); |
| 384 | 470 |
| 385 // Let the user interact with the page, so that DOM gets modification events, | 471 // Let the user interact with the page, so that DOM gets modification events, |
| 386 // needed for autofilling fields. | 472 // needed for autofilling fields. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 579 |
| 494 content::BrowserThread::PostTaskAndReply( | 580 content::BrowserThread::PostTaskAndReply( |
| 495 content::BrowserThread::IO, FROM_HERE, | 581 content::BrowserThread::IO, FROM_HERE, |
| 496 base::BindOnce( | 582 base::BindOnce( |
| 497 &AddHSTSHostImpl, | 583 &AddHSTSHostImpl, |
| 498 make_scoped_refptr(browser()->profile()->GetRequestContext()), host), | 584 make_scoped_refptr(browser()->profile()->GetRequestContext()), host), |
| 499 run_loop.QuitClosure()); | 585 run_loop.QuitClosure()); |
| 500 | 586 |
| 501 run_loop.Run(); | 587 run_loop.Run(); |
| 502 } | 588 } |
| 589 | |
| 590 void PasswordManagerBrowserTestBase::CheckThatCredentialsStored( | |
| 591 const base::string16& username, | |
| 592 const base::string16& password) { | |
| 593 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
| 594 static_cast<password_manager::TestPasswordStore*>( | |
| 595 PasswordStoreFactory::GetForProfile( | |
| 596 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
| 597 .get()); | |
| 598 auto& passwords_map = password_store->stored_passwords(); | |
| 599 ASSERT_EQ(1u, passwords_map.size()); | |
| 600 auto& passwords_vector = passwords_map.begin()->second; | |
| 601 ASSERT_EQ(1u, passwords_vector.size()); | |
| 602 const autofill::PasswordForm& form = passwords_vector[0]; | |
| 603 EXPECT_EQ(username, form.username_value); | |
| 604 EXPECT_EQ(password, form.password_value); | |
| 605 } | |
| OLD | NEW |