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> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 prompt_observer->Accept(); | 1426 prompt_observer->Accept(); |
1427 | 1427 |
1428 // Spin the message loop to make sure the password store had a chance to save | 1428 // Spin the message loop to make sure the password store had a chance to save |
1429 // the password. | 1429 // the password. |
1430 base::RunLoop run_loop; | 1430 base::RunLoop run_loop; |
1431 run_loop.RunUntilIdle(); | 1431 run_loop.RunUntilIdle(); |
1432 EXPECT_FALSE(password_store->IsEmpty()); | 1432 EXPECT_FALSE(password_store->IsEmpty()); |
1433 } | 1433 } |
1434 | 1434 |
1435 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1435 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1436 AutofillSuggetionsForPasswordFormWithoutUsernameField) { | 1436 AutofillSuggestionsForPasswordFormWithoutUsernameField) { |
1437 std::string submit = | 1437 std::string submit = |
1438 "document.getElementById('password').value = 'mypassword';" | 1438 "document.getElementById('password').value = 'mypassword';" |
1439 "document.getElementById('submit-button').click();"; | 1439 "document.getElementById('submit-button').click();"; |
1440 VerifyPasswordIsSavedAndFilled("/password/form_with_only_password_field.html", | 1440 VerifyPasswordIsSavedAndFilled("/password/form_with_only_password_field.html", |
1441 submit, "password", "mypassword"); | 1441 submit, "password", "mypassword"); |
1442 } | 1442 } |
1443 | 1443 |
1444 // Test that if a form gets autofilled, then it gets autofilled on re-creation | 1444 // Test that if a form gets autofilled, then it gets autofilled on re-creation |
1445 // as well. | 1445 // as well. |
1446 // TODO(vabr): This is flaky everywhere. http://crbug.com/442704 | 1446 // TODO(vabr): This is flaky everywhere. http://crbug.com/442704 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 if (message == "\"SUBMISSION_FINISHED\"") | 1788 if (message == "\"SUBMISSION_FINISHED\"") |
1789 break; | 1789 break; |
1790 } | 1790 } |
1791 | 1791 |
1792 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1792 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
1793 } | 1793 } |
1794 | 1794 |
1795 // Tests that if a site embeds the login and signup forms into one <form>, the | 1795 // Tests that if a site embeds the login and signup forms into one <form>, the |
1796 // login form still gets autofilled. | 1796 // login form still gets autofilled. |
1797 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1797 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1798 AutofillSuggetionsForLoginSignupForm) { | 1798 AutofillSuggestionsForLoginSignupForm) { |
1799 std::string submit = | 1799 std::string submit = |
1800 "document.getElementById('username').value = 'myusername';" | 1800 "document.getElementById('username').value = 'myusername';" |
1801 "document.getElementById('password').value = 'mypassword';" | 1801 "document.getElementById('password').value = 'mypassword';" |
1802 "document.getElementById('submit').click();"; | 1802 "document.getElementById('submit').click();"; |
1803 VerifyPasswordIsSavedAndFilled("/password/login_signup_form.html", | 1803 VerifyPasswordIsSavedAndFilled("/password/login_signup_form.html", |
1804 submit, "password", "mypassword"); | 1804 submit, "password", "mypassword"); |
1805 } | 1805 } |
1806 | 1806 |
1807 // Check that we can fill in cases where <base href> is set and the action of | 1807 // Check that we can fill in cases where <base href> is set and the action of |
1808 // the form is not set. Regression test for https://crbug.com/360230. | 1808 // the form is not set. Regression test for https://crbug.com/360230. |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 run_loop.RunUntilIdle(); | 2254 run_loop.RunUntilIdle(); |
2255 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2255 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
2256 base::ASCIIToUTF16("new_pw")); | 2256 base::ASCIIToUTF16("new_pw")); |
2257 } | 2257 } |
2258 #endif | 2258 #endif |
2259 | 2259 |
2260 // Test whether the password form with the username and password fields having | 2260 // Test whether the password form with the username and password fields having |
2261 // ambiguity in id attribute gets autofilled correctly. | 2261 // ambiguity in id attribute gets autofilled correctly. |
2262 IN_PROC_BROWSER_TEST_F( | 2262 IN_PROC_BROWSER_TEST_F( |
2263 PasswordManagerBrowserTestBase, | 2263 PasswordManagerBrowserTestBase, |
2264 AutofillSuggetionsForPasswordFormWithAmbiguousIdAttribute) { | 2264 AutofillSuggestionsForPasswordFormWithAmbiguousIdAttribute) { |
2265 // At first let us save credentials to the PasswordManager. | 2265 // At first let us save credentials to the PasswordManager. |
2266 scoped_refptr<password_manager::PasswordStore> password_store = | 2266 scoped_refptr<password_manager::PasswordStore> password_store = |
2267 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2267 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2268 ServiceAccessType::IMPLICIT_ACCESS); | 2268 ServiceAccessType::IMPLICIT_ACCESS); |
2269 autofill::PasswordForm login_form; | 2269 autofill::PasswordForm login_form; |
2270 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2270 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2271 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2271 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2272 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2272 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2273 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2273 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2274 password_store->AddLogin(login_form); | 2274 password_store->AddLogin(login_form); |
(...skipping 27 matching lines...) Expand all Loading... |
2302 std::string actual_password; | 2302 std::string actual_password; |
2303 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2303 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2304 RenderViewHost(), get_password, &actual_password)); | 2304 RenderViewHost(), get_password, &actual_password)); |
2305 EXPECT_EQ("mypassword", actual_password); | 2305 EXPECT_EQ("mypassword", actual_password); |
2306 } | 2306 } |
2307 | 2307 |
2308 // Test whether the password form having username and password fields without | 2308 // Test whether the password form having username and password fields without |
2309 // name and id attribute gets autofilled correctly. | 2309 // name and id attribute gets autofilled correctly. |
2310 IN_PROC_BROWSER_TEST_F( | 2310 IN_PROC_BROWSER_TEST_F( |
2311 PasswordManagerBrowserTestBase, | 2311 PasswordManagerBrowserTestBase, |
2312 AutofillSuggetionsForPasswordFormWithoutNameOrIdAttribute) { | 2312 AutofillSuggestionsForPasswordFormWithoutNameOrIdAttribute) { |
2313 // At first let us save credentials to the PasswordManager. | 2313 // At first let us save credentials to the PasswordManager. |
2314 scoped_refptr<password_manager::PasswordStore> password_store = | 2314 scoped_refptr<password_manager::PasswordStore> password_store = |
2315 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2315 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2316 ServiceAccessType::IMPLICIT_ACCESS); | 2316 ServiceAccessType::IMPLICIT_ACCESS); |
2317 autofill::PasswordForm login_form; | 2317 autofill::PasswordForm login_form; |
2318 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2318 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2319 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2319 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2320 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2320 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2321 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2321 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2322 password_store->AddLogin(login_form); | 2322 password_store->AddLogin(login_form); |
(...skipping 26 matching lines...) Expand all Loading... |
2349 " document.getElementById('no_name_id_form').elements[1].value);"; | 2349 " document.getElementById('no_name_id_form').elements[1].value);"; |
2350 std::string actual_password; | 2350 std::string actual_password; |
2351 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2351 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2352 RenderViewHost(), get_password, &actual_password)); | 2352 RenderViewHost(), get_password, &actual_password)); |
2353 EXPECT_EQ("mypassword", actual_password); | 2353 EXPECT_EQ("mypassword", actual_password); |
2354 } | 2354 } |
2355 | 2355 |
2356 // Test whether the change password form having username and password fields | 2356 // Test whether the change password form having username and password fields |
2357 // without name and id attribute gets autofilled correctly. | 2357 // without name and id attribute gets autofilled correctly. |
2358 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2358 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2359 AutofillSuggetionsForChangePwdWithEmptyNames) { | 2359 AutofillSuggestionsForChangePwdWithEmptyNames) { |
2360 // At first let us save credentials to the PasswordManager. | 2360 // At first let us save credentials to the PasswordManager. |
2361 scoped_refptr<password_manager::PasswordStore> password_store = | 2361 scoped_refptr<password_manager::PasswordStore> password_store = |
2362 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2362 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2363 ServiceAccessType::IMPLICIT_ACCESS); | 2363 ServiceAccessType::IMPLICIT_ACCESS); |
2364 autofill::PasswordForm login_form; | 2364 autofill::PasswordForm login_form; |
2365 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2365 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2366 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2366 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2367 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2367 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2368 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2368 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2369 password_store->AddLogin(login_form); | 2369 password_store->AddLogin(login_form); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2409 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2410 RenderViewHost(), get_new_password, &new_password)); | 2410 RenderViewHost(), get_new_password, &new_password)); |
2411 EXPECT_EQ("", new_password); | 2411 EXPECT_EQ("", new_password); |
2412 } | 2412 } |
2413 | 2413 |
2414 // Test whether the change password form having username and password fields | 2414 // Test whether the change password form having username and password fields |
2415 // with empty names but having |autocomplete='current-password'| gets autofilled | 2415 // with empty names but having |autocomplete='current-password'| gets autofilled |
2416 // correctly. | 2416 // correctly. |
2417 IN_PROC_BROWSER_TEST_F( | 2417 IN_PROC_BROWSER_TEST_F( |
2418 PasswordManagerBrowserTestBase, | 2418 PasswordManagerBrowserTestBase, |
2419 AutofillSuggetionsForChangePwdWithEmptyNamesAndAutocomplete) { | 2419 AutofillSuggestionsForChangePwdWithEmptyNamesAndAutocomplete) { |
2420 // At first let us save credentials to the PasswordManager. | 2420 // At first let us save credentials to the PasswordManager. |
2421 scoped_refptr<password_manager::PasswordStore> password_store = | 2421 scoped_refptr<password_manager::PasswordStore> password_store = |
2422 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2422 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2423 ServiceAccessType::IMPLICIT_ACCESS); | 2423 ServiceAccessType::IMPLICIT_ACCESS); |
2424 autofill::PasswordForm login_form; | 2424 autofill::PasswordForm login_form; |
2425 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2425 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2426 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2426 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2427 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2427 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2428 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2428 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2429 password_store->AddLogin(login_form); | 2429 password_store->AddLogin(login_form); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2466 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2467 RenderViewHost(), get_new_password, &new_password)); | 2467 RenderViewHost(), get_new_password, &new_password)); |
2468 EXPECT_EQ("", new_password); | 2468 EXPECT_EQ("", new_password); |
2469 } | 2469 } |
2470 | 2470 |
2471 // Test whether the change password form having username and password fields | 2471 // Test whether the change password form having username and password fields |
2472 // with empty names but having only new password fields having | 2472 // with empty names but having only new password fields having |
2473 // |autocomplete='new-password'| atrribute do not get autofilled. | 2473 // |autocomplete='new-password'| atrribute do not get autofilled. |
2474 IN_PROC_BROWSER_TEST_F( | 2474 IN_PROC_BROWSER_TEST_F( |
2475 PasswordManagerBrowserTestBase, | 2475 PasswordManagerBrowserTestBase, |
2476 AutofillSuggetionsForChangePwdWithEmptyNamesButOnlyNewPwdField) { | 2476 AutofillSuggestionsForChangePwdWithEmptyNamesButOnlyNewPwdField) { |
2477 // At first let us save credentials to the PasswordManager. | 2477 // At first let us save credentials to the PasswordManager. |
2478 scoped_refptr<password_manager::PasswordStore> password_store = | 2478 scoped_refptr<password_manager::PasswordStore> password_store = |
2479 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2479 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2480 ServiceAccessType::IMPLICIT_ACCESS); | 2480 ServiceAccessType::IMPLICIT_ACCESS); |
2481 autofill::PasswordForm login_form; | 2481 autofill::PasswordForm login_form; |
2482 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2482 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2483 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2483 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2484 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2484 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2485 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2485 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2486 password_store->AddLogin(login_form); | 2486 password_store->AddLogin(login_form); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 // processed. | 2581 // processed. |
2582 base::RunLoop run_loop2; | 2582 base::RunLoop run_loop2; |
2583 run_loop2.RunUntilIdle(); | 2583 run_loop2.RunUntilIdle(); |
2584 | 2584 |
2585 password_manager->RemoveObserver(&mock_login_model_observer); | 2585 password_manager->RemoveObserver(&mock_login_model_observer); |
2586 } | 2586 } |
2587 | 2587 |
2588 // Test whether the password form which is loaded as hidden is autofilled | 2588 // Test whether the password form which is loaded as hidden is autofilled |
2589 // correctly. This happens very often in situations when in order to sign-in the | 2589 // correctly. This happens very often in situations when in order to sign-in the |
2590 // user clicks a sign-in button and a hidden passsword form becomes visible. | 2590 // user clicks a sign-in button and a hidden passsword form becomes visible. |
2591 // This test differs from AutofillSuggetionsForProblematicPasswordForm in that | 2591 // This test differs from AutofillSuggestionsForProblematicPasswordForm in that |
2592 // the form is hidden and in that test only some fields are hidden. | 2592 // the form is hidden and in that test only some fields are hidden. |
2593 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2593 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2594 AutofillSuggetionsHiddenPasswordForm) { | 2594 AutofillSuggestionsHiddenPasswordForm) { |
2595 // At first let us save credentials to the PasswordManager. | 2595 // At first let us save credentials to the PasswordManager. |
2596 scoped_refptr<password_manager::PasswordStore> password_store = | 2596 scoped_refptr<password_manager::PasswordStore> password_store = |
2597 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2597 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2598 ServiceAccessType::IMPLICIT_ACCESS); | 2598 ServiceAccessType::IMPLICIT_ACCESS); |
2599 autofill::PasswordForm login_form; | 2599 autofill::PasswordForm login_form; |
2600 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2600 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2601 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2601 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2602 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2602 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2603 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2603 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2604 password_store->AddLogin(login_form); | 2604 password_store->AddLogin(login_form); |
(...skipping 26 matching lines...) Expand all Loading... |
2631 " document.getElementById('hidden_password_form_password').value);"; | 2631 " document.getElementById('hidden_password_form_password').value);"; |
2632 std::string actual_password; | 2632 std::string actual_password; |
2633 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2633 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2634 RenderViewHost(), get_password, &actual_password)); | 2634 RenderViewHost(), get_password, &actual_password)); |
2635 EXPECT_EQ("mypassword", actual_password); | 2635 EXPECT_EQ("mypassword", actual_password); |
2636 } | 2636 } |
2637 | 2637 |
2638 // Test whether the password form with the problematic invisible password field | 2638 // Test whether the password form with the problematic invisible password field |
2639 // gets autofilled correctly. | 2639 // gets autofilled correctly. |
2640 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2640 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2641 AutofillSuggetionsForProblematicPasswordForm) { | 2641 AutofillSuggestionsForProblematicPasswordForm) { |
2642 // At first let us save credentials to the PasswordManager. | 2642 // At first let us save credentials to the PasswordManager. |
2643 scoped_refptr<password_manager::PasswordStore> password_store = | 2643 scoped_refptr<password_manager::PasswordStore> password_store = |
2644 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2644 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2645 ServiceAccessType::IMPLICIT_ACCESS); | 2645 ServiceAccessType::IMPLICIT_ACCESS); |
2646 autofill::PasswordForm login_form; | 2646 autofill::PasswordForm login_form; |
2647 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2647 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2648 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2648 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2649 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2649 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2650 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2650 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2651 password_store->AddLogin(login_form); | 2651 password_store->AddLogin(login_form); |
(...skipping 26 matching lines...) Expand all Loading... |
2678 " document.getElementById('form_with_hidden_password_password').value);"; | 2678 " document.getElementById('form_with_hidden_password_password').value);"; |
2679 std::string actual_password; | 2679 std::string actual_password; |
2680 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2680 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2681 RenderViewHost(), get_password, &actual_password)); | 2681 RenderViewHost(), get_password, &actual_password)); |
2682 EXPECT_EQ("mypassword", actual_password); | 2682 EXPECT_EQ("mypassword", actual_password); |
2683 } | 2683 } |
2684 | 2684 |
2685 // Test whether the password form with the problematic invisible password field | 2685 // Test whether the password form with the problematic invisible password field |
2686 // in ambiguous password form gets autofilled correctly. | 2686 // in ambiguous password form gets autofilled correctly. |
2687 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2687 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2688 AutofillSuggetionsForProblematicAmbiguousPasswordForm) { | 2688 AutofillSuggestionsForProblematicAmbiguousPasswordForm) { |
2689 // At first let us save credentials to the PasswordManager. | 2689 // At first let us save credentials to the PasswordManager. |
2690 scoped_refptr<password_manager::PasswordStore> password_store = | 2690 scoped_refptr<password_manager::PasswordStore> password_store = |
2691 PasswordStoreFactory::GetForProfile(browser()->profile(), | 2691 PasswordStoreFactory::GetForProfile(browser()->profile(), |
2692 ServiceAccessType::IMPLICIT_ACCESS); | 2692 ServiceAccessType::IMPLICIT_ACCESS); |
2693 autofill::PasswordForm login_form; | 2693 autofill::PasswordForm login_form; |
2694 login_form.signon_realm = embedded_test_server()->base_url().spec(); | 2694 login_form.signon_realm = embedded_test_server()->base_url().spec(); |
2695 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | 2695 login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
2696 login_form.username_value = base::ASCIIToUTF16("myusername"); | 2696 login_form.username_value = base::ASCIIToUTF16("myusername"); |
2697 login_form.password_value = base::ASCIIToUTF16("mypassword"); | 2697 login_form.password_value = base::ASCIIToUTF16("mypassword"); |
2698 password_store->AddLogin(login_form); | 2698 password_store->AddLogin(login_form); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 prompt_observer->AcceptUpdatePrompt(stored_form); | 2864 prompt_observer->AcceptUpdatePrompt(stored_form); |
2865 // Spin the message loop to make sure the password store had a chance to | 2865 // Spin the message loop to make sure the password store had a chance to |
2866 // update the password. | 2866 // update the password. |
2867 base::RunLoop run_loop; | 2867 base::RunLoop run_loop; |
2868 run_loop.RunUntilIdle(); | 2868 run_loop.RunUntilIdle(); |
2869 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2869 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
2870 base::ASCIIToUTF16("new_pw")); | 2870 base::ASCIIToUTF16("new_pw")); |
2871 } | 2871 } |
2872 #endif | 2872 #endif |
2873 | 2873 |
| 2874 // Tests that the prompt to save the password is still shown if the fields have |
| 2875 // the "autocomplete" attribute set off. |
| 2876 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 2877 PromptForSubmitWithAutocompleteOff) { |
| 2878 NavigateToFile("/password/password_autocomplete_off_test.html"); |
| 2879 |
| 2880 NavigationObserver observer(WebContents()); |
| 2881 scoped_ptr<PromptObserver> prompt_observer( |
| 2882 PromptObserver::Create(WebContents())); |
| 2883 std::string fill_and_submit = |
| 2884 "document.getElementById('username').value = 'temp';" |
| 2885 "document.getElementById('password').value = 'random';" |
| 2886 "document.getElementById('submit').click()"; |
| 2887 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2888 observer.Wait(); |
| 2889 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 2890 } |
| 2891 |
| 2892 // Tests that password suggestions still work if the fields have the |
| 2893 // "autocomplete" attribute set to off. |
| 2894 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 2895 AutofillSuggestionsForPasswordFormWithAutocompleteOff) { |
| 2896 std::string submit = |
| 2897 "document.getElementById('username').value = 'temp';" |
| 2898 "document.getElementById('password').value = 'mypassword';" |
| 2899 "document.getElementById('submit').click();"; |
| 2900 VerifyPasswordIsSavedAndFilled( |
| 2901 "/password/password_autocomplete_off_test.html", submit, "password", |
| 2902 "mypassword"); |
| 2903 } |
| 2904 |
2874 } // namespace password_manager | 2905 } // namespace password_manager |
OLD | NEW |