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 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2577 // password fields and verify whether username and password is autofilled. | 2577 // password fields and verify whether username and password is autofilled. |
2578 NavigateToFile("/password/password_form.html"); | 2578 NavigateToFile("/password/password_form.html"); |
2579 | 2579 |
2580 // Let the user interact with the page, so that DOM gets modification events, | 2580 // Let the user interact with the page, so that DOM gets modification events, |
2581 // needed for autofilling fields. | 2581 // needed for autofilling fields. |
2582 content::SimulateMouseClickAt( | 2582 content::SimulateMouseClickAt( |
2583 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | 2583 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); |
2584 | 2584 |
2585 std::string get_username = | 2585 std::string get_username = |
2586 "window.domAutomationController.send(" | 2586 "window.domAutomationController.send(" |
2587 " document.getElementById('username').value);"; | 2587 " document.getElementById('form_with_hidden_password_username').value);"; |
2588 std::string actual_username; | 2588 std::string actual_username; |
2589 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2589 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2590 RenderViewHost(), get_username, &actual_username)); | 2590 RenderViewHost(), get_username, &actual_username)); |
2591 EXPECT_EQ("myusername", actual_username); | 2591 EXPECT_EQ("myusername", actual_username); |
2592 | 2592 |
2593 std::string get_password = | 2593 std::string get_password = |
2594 "window.domAutomationController.send(" | 2594 "window.domAutomationController.send(" |
2595 " document.getElementById('password').value);"; | 2595 " document.getElementById('form_with_hidden_password_password').value);"; |
2596 std::string actual_password; | 2596 std::string actual_password; |
2597 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2597 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2598 RenderViewHost(), get_password, &actual_password)); | 2598 RenderViewHost(), get_password, &actual_password)); |
2599 EXPECT_EQ("mypassword", actual_password); | 2599 EXPECT_EQ("mypassword", actual_password); |
2600 } | 2600 } |
2601 | 2601 |
2602 // Test whether the password form with the problematic invisible password field | 2602 // Test whether the password form with the problematic invisible password field |
2603 // in ambiguous password form gets autofilled correctly. | 2603 // in ambiguous password form gets autofilled correctly. |
2604 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2604 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2605 AutofillSuggetionsForProblematicAmbiguousPasswordForm) { | 2605 AutofillSuggetionsForProblematicAmbiguousPasswordForm) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2639 | 2639 |
2640 std::string get_password = | 2640 std::string get_password = |
2641 "window.domAutomationController.send(" | 2641 "window.domAutomationController.send(" |
2642 " document.getElementById('hidden_password_form').elements[2].value);"; | 2642 " document.getElementById('hidden_password_form').elements[2].value);"; |
2643 std::string actual_password; | 2643 std::string actual_password; |
2644 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2644 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2645 RenderViewHost(), get_password, &actual_password)); | 2645 RenderViewHost(), get_password, &actual_password)); |
2646 EXPECT_EQ("mypassword", actual_password); | 2646 EXPECT_EQ("mypassword", actual_password); |
2647 } | 2647 } |
2648 | 2648 |
2649 // Test whether the password form which is loaded as hidden is autofilled | |
vabr (Chromium)
2015/11/05 15:20:24
Please mention the difference against AutofillSugg
dvadym
2015/11/05 16:18:25
Done.
| |
2650 // correctly. This shows very often situation when in order to sign-in the user | |
vabr (Chromium)
2015/11/05 15:20:24
nit: shows -> happens; situation -> in situations
dvadym
2015/11/05 16:18:26
Done.
| |
2651 // clicks sign-in and a hidden passsword form becomes visible. | |
vabr (Chromium)
2015/11/05 15:20:24
nit: "sign-in" -> "a sign-in button"
dvadym
2015/11/05 16:18:25
Done.
| |
2652 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
2653 AutofillSuggetionsHiddenPasswordForm) { | |
2654 // At first let us save credentials to the PasswordManager. | |
2655 scoped_refptr<password_manager::PasswordStore> password_store = | |
2656 PasswordStoreFactory::GetForProfile(browser()->profile(), | |
2657 ServiceAccessType::IMPLICIT_ACCESS); | |
2658 autofill::PasswordForm login_form; | |
2659 login_form.signon_realm = embedded_test_server()->base_url().spec(); | |
2660 login_form.action = embedded_test_server()->GetURL("/password/done.html"); | |
2661 login_form.username_value = base::ASCIIToUTF16("myusername"); | |
2662 login_form.password_value = base::ASCIIToUTF16("mypassword"); | |
2663 password_store->AddLogin(login_form); | |
2664 | |
2665 // Logins are added asynchronously to the password store. Spin the message | |
2666 // loop to make sure the |password_store| had a chance to store the | |
2667 // |login_form|. | |
2668 base::RunLoop run_loop; | |
2669 run_loop.RunUntilIdle(); | |
2670 | |
2671 // Now, navigate to the password form having ambiguous Ids for username and | |
vabr (Chromium)
2015/11/05 15:20:24
Are the IDs ambiguous? I thought there were hidden
dvadym
2015/11/05 16:18:25
Thanks, no, it was copy paste of copy paste :). I'
| |
2672 // password fields and verify whether username and password is autofilled. | |
2673 NavigateToFile("/password/password_form.html"); | |
2674 | |
2675 // Let the user interact with the page, so that DOM gets modification events, | |
2676 // needed for autofilling fields. | |
2677 content::SimulateMouseClickAt( | |
2678 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | |
2679 | |
2680 std::string get_username = | |
2681 "window.domAutomationController.send(" | |
2682 " document.getElementById('hidden_password_form_username').value);"; | |
2683 std::string actual_username; | |
2684 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
2685 RenderViewHost(), get_username, &actual_username)); | |
2686 EXPECT_EQ("myusername", actual_username); | |
2687 | |
2688 std::string get_password = | |
2689 "window.domAutomationController.send(" | |
2690 " document.getElementById('hidden_password_form_password').value);"; | |
2691 std::string actual_password; | |
2692 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
2693 RenderViewHost(), get_password, &actual_password)); | |
2694 EXPECT_EQ("mypassword", actual_password); | |
2695 } | |
2696 | |
2649 } // namespace password_manager | 2697 } // namespace password_manager |
OLD | NEW |