| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 WebInputElement second_password_element = element.to<WebInputElement>(); | 325 WebInputElement second_password_element = element.to<WebInputElement>(); |
| 326 | 326 |
| 327 // Both password fields should be empty. | 327 // Both password fields should be empty. |
| 328 EXPECT_TRUE(first_password_element.value().isNull()); | 328 EXPECT_TRUE(first_password_element.value().isNull()); |
| 329 EXPECT_TRUE(second_password_element.value().isNull()); | 329 EXPECT_TRUE(second_password_element.value().isNull()); |
| 330 | 330 |
| 331 base::string16 password = base::ASCIIToUTF16("random_password"); | 331 base::string16 password = base::ASCIIToUTF16("random_password"); |
| 332 password_generation_->GeneratedPasswordAccepted(password); | 332 password_generation_->GeneratedPasswordAccepted(password); |
| 333 | 333 |
| 334 // Password fields are filled out and set as being autofilled. | 334 // Password fields are filled out and set as being autofilled. |
| 335 EXPECT_EQ(password, first_password_element.value()); | 335 EXPECT_EQ(password, first_password_element.value().utf16()); |
| 336 EXPECT_EQ(password, second_password_element.value()); | 336 EXPECT_EQ(password, second_password_element.value().utf16()); |
| 337 EXPECT_TRUE(first_password_element.isAutofilled()); | 337 EXPECT_TRUE(first_password_element.isAutofilled()); |
| 338 EXPECT_TRUE(second_password_element.isAutofilled()); | 338 EXPECT_TRUE(second_password_element.isAutofilled()); |
| 339 | 339 |
| 340 // Make sure onchange events are called. | 340 // Make sure onchange events are called. |
| 341 int first_onchange_called = -1; | 341 int first_onchange_called = -1; |
| 342 int second_onchange_called = -1; | 342 int second_onchange_called = -1; |
| 343 ASSERT_TRUE( | 343 ASSERT_TRUE( |
| 344 ExecuteJavaScriptAndReturnIntValue( | 344 ExecuteJavaScriptAndReturnIntValue( |
| 345 base::ASCIIToUTF16("firstOnChangeCalled ? 1 : 0"), | 345 base::ASCIIToUTF16("firstOnChangeCalled ? 1 : 0"), |
| 346 &first_onchange_called)); | 346 &first_onchange_called)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 371 ASSERT_FALSE(element.isNull()); | 371 ASSERT_FALSE(element.isNull()); |
| 372 WebInputElement first_password_element = element.to<WebInputElement>(); | 372 WebInputElement first_password_element = element.to<WebInputElement>(); |
| 373 element = document.getElementById(WebString::fromUTF8("second_password")); | 373 element = document.getElementById(WebString::fromUTF8("second_password")); |
| 374 ASSERT_FALSE(element.isNull()); | 374 ASSERT_FALSE(element.isNull()); |
| 375 WebInputElement second_password_element = element.to<WebInputElement>(); | 375 WebInputElement second_password_element = element.to<WebInputElement>(); |
| 376 | 376 |
| 377 base::string16 password = base::ASCIIToUTF16("random_password"); | 377 base::string16 password = base::ASCIIToUTF16("random_password"); |
| 378 password_generation_->GeneratedPasswordAccepted(password); | 378 password_generation_->GeneratedPasswordAccepted(password); |
| 379 | 379 |
| 380 // Passwords start out the same. | 380 // Passwords start out the same. |
| 381 EXPECT_EQ(password, first_password_element.value()); | 381 EXPECT_EQ(password, first_password_element.value().utf16()); |
| 382 EXPECT_EQ(password, second_password_element.value()); | 382 EXPECT_EQ(password, second_password_element.value().utf16()); |
| 383 | 383 |
| 384 // After editing the first field they are still the same. | 384 // After editing the first field they are still the same. |
| 385 std::string edited_password_ascii = "edited_password"; | 385 std::string edited_password_ascii = "edited_password"; |
| 386 SimulateUserInputChangeForElement(&first_password_element, | 386 SimulateUserInputChangeForElement(&first_password_element, |
| 387 edited_password_ascii); | 387 edited_password_ascii); |
| 388 base::string16 edited_password = base::ASCIIToUTF16(edited_password_ascii); | 388 base::string16 edited_password = base::ASCIIToUTF16(edited_password_ascii); |
| 389 EXPECT_EQ(edited_password, first_password_element.value()); | 389 EXPECT_EQ(edited_password, first_password_element.value().utf16()); |
| 390 EXPECT_EQ(edited_password, second_password_element.value()); | 390 EXPECT_EQ(edited_password, second_password_element.value().utf16()); |
| 391 | 391 |
| 392 fake_driver_.reset_called_password_no_longer_generated(); | 392 fake_driver_.reset_called_password_no_longer_generated(); |
| 393 | 393 |
| 394 // Verify that password mirroring works correctly even when the password | 394 // Verify that password mirroring works correctly even when the password |
| 395 // is deleted. | 395 // is deleted. |
| 396 SimulateUserInputChangeForElement(&first_password_element, std::string()); | 396 SimulateUserInputChangeForElement(&first_password_element, std::string()); |
| 397 EXPECT_EQ(base::string16(), first_password_element.value()); | 397 EXPECT_EQ(base::string16(), first_password_element.value().utf16()); |
| 398 EXPECT_EQ(base::string16(), second_password_element.value()); | 398 EXPECT_EQ(base::string16(), second_password_element.value().utf16()); |
| 399 | 399 |
| 400 // Should have notified the browser that the password is no longer generated | 400 // Should have notified the browser that the password is no longer generated |
| 401 // and trigger generation again. | 401 // and trigger generation again. |
| 402 base::RunLoop().RunUntilIdle(); | 402 base::RunLoop().RunUntilIdle(); |
| 403 EXPECT_TRUE(fake_driver_.called_password_no_longer_generated()); | 403 EXPECT_TRUE(fake_driver_.called_password_no_longer_generated()); |
| 404 EXPECT_TRUE(GetCalledShowPasswordGenerationPopup()); | 404 EXPECT_TRUE(GetCalledShowPasswordGenerationPopup()); |
| 405 } | 405 } |
| 406 | 406 |
| 407 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { | 407 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { |
| 408 // Did not receive not blacklisted message. Don't show password generation | 408 // Did not receive not blacklisted message. Don't show password generation |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 base::string16()); | 717 base::string16()); |
| 718 } | 718 } |
| 719 | 719 |
| 720 TEST_F(PasswordGenerationAgentTest, FormClassifierDisabled) { | 720 TEST_F(PasswordGenerationAgentTest, FormClassifierDisabled) { |
| 721 LoadHTMLWithUserGesture(kSigninFormHTML); | 721 LoadHTMLWithUserGesture(kSigninFormHTML); |
| 722 ExpectFormClassifierVoteReceived(false /* vote is not expected */, | 722 ExpectFormClassifierVoteReceived(false /* vote is not expected */, |
| 723 base::string16()); | 723 base::string16()); |
| 724 } | 724 } |
| 725 | 725 |
| 726 } // namespace autofill | 726 } // namespace autofill |
| OLD | NEW |