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 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2732 | 2732 |
2733 std::string get_password = | 2733 std::string get_password = |
2734 "window.domAutomationController.send(" | 2734 "window.domAutomationController.send(" |
2735 " document.getElementById('hidden_password_form').elements[2].value);"; | 2735 " document.getElementById('hidden_password_form').elements[2].value);"; |
2736 std::string actual_password; | 2736 std::string actual_password; |
2737 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2737 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2738 RenderViewHost(), get_password, &actual_password)); | 2738 RenderViewHost(), get_password, &actual_password)); |
2739 EXPECT_EQ("mypassword", actual_password); | 2739 EXPECT_EQ("mypassword", actual_password); |
2740 } | 2740 } |
2741 | 2741 |
2742 // Check that the internals page contains logs both from the renderer and the | 2742 // Check that the internals page contains logs from the renderer. |
2743 // browser. | 2743 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Renderer) { |
2744 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage) { | 2744 // Open the internals page. |
2745 ui_test_utils::NavigateToURLWithDisposition( | |
2746 browser(), GURL("chrome://password-manager-internals"), | |
2747 WindowOpenDisposition::CURRENT_TAB, | |
2748 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
2749 content::WebContents* internals_web_contents = WebContents(); | |
2750 | |
2751 // Open some page with a HTML form. | |
2752 ui_test_utils::NavigateToURLWithDisposition( | |
2753 browser(), embedded_test_server()->GetURL("/password/password_form.html"), | |
2754 WindowOpenDisposition::NEW_FOREGROUND_TAB, | |
2755 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
2756 content::WebContents* forms_web_contents = WebContents(); | |
2757 | |
2758 // The renderer queries the availability of logging on start-up. However, it | |
2759 // can take too long to propagate that message from the browser back to the | |
2760 // renderer. The renderer might have attempted logging in the meantime. | |
2761 // Therefore the page with the form is reloaded to increase the likelihood | |
2762 // that the availability query was answered before the logging during page | |
2763 // load. | |
2764 NavigationObserver observer(forms_web_contents); | |
2765 forms_web_contents->ReloadFocusedFrame(false); | |
vabr (Chromium)
2016/09/05 12:36:43
This does not recreate the PasswordAutofillAgent (
| |
2766 observer.Wait(); | |
2767 | |
2768 std::string find_logs = | |
2769 "var text = document.getElementById('log-entries').innerText;" | |
2770 "var logs_found = /PasswordAutofillAgent::/.test(text);" | |
2771 "window.domAutomationController.send(logs_found);"; | |
2772 bool logs_found = false; | |
2773 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2774 internals_web_contents->GetRenderViewHost(), find_logs, &logs_found)); | |
2775 EXPECT_TRUE(logs_found); | |
2776 } | |
2777 | |
2778 // Check that the internals page contains logs from the browser. | |
2779 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Browser) { | |
2745 ui_test_utils::NavigateToURLWithDisposition( | 2780 ui_test_utils::NavigateToURLWithDisposition( |
2746 browser(), GURL("chrome://password-manager-internals"), | 2781 browser(), GURL("chrome://password-manager-internals"), |
2747 WindowOpenDisposition::CURRENT_TAB, | 2782 WindowOpenDisposition::CURRENT_TAB, |
2748 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2783 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
2749 content::WebContents* internals_web_contents = WebContents(); | 2784 content::WebContents* internals_web_contents = WebContents(); |
2750 | 2785 |
2751 ui_test_utils::NavigateToURLWithDisposition( | 2786 ui_test_utils::NavigateToURLWithDisposition( |
2752 browser(), embedded_test_server()->GetURL("/password/password_form.html"), | 2787 browser(), embedded_test_server()->GetURL("/password/password_form.html"), |
2753 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 2788 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
2754 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2789 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
2755 | 2790 |
2756 std::string find_renderer_logs = | 2791 std::string find_logs = |
2757 "var text = document.getElementById('log-entries').innerText;" | |
2758 "var logs_found = /PasswordAutofillAgent::/.test(text);" | |
2759 "window.domAutomationController.send(logs_found);"; | |
2760 bool renderer_logs_found; | |
2761 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2762 internals_web_contents->GetRenderViewHost(), find_renderer_logs, | |
2763 &renderer_logs_found)); | |
2764 EXPECT_TRUE(renderer_logs_found); | |
2765 | |
2766 std::string find_browser_logs = | |
2767 "var text = document.getElementById('log-entries').innerText;" | 2792 "var text = document.getElementById('log-entries').innerText;" |
2768 "var logs_found = /PasswordManager::/.test(text);" | 2793 "var logs_found = /PasswordManager::/.test(text);" |
2769 "window.domAutomationController.send(logs_found);"; | 2794 "window.domAutomationController.send(logs_found);"; |
2770 bool browser_logs_found; | 2795 bool logs_found = false; |
2771 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 2796 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
2772 internals_web_contents->GetRenderViewHost(), find_browser_logs, | 2797 internals_web_contents->GetRenderViewHost(), find_logs, &logs_found)); |
2773 &browser_logs_found)); | 2798 EXPECT_TRUE(logs_found); |
2774 EXPECT_TRUE(browser_logs_found); | |
2775 } | 2799 } |
2776 | 2800 |
2777 // Tests that submitted credentials are saved on a password form without | 2801 // Tests that submitted credentials are saved on a password form without |
2778 // username element when there are no stored credentials. | 2802 // username element when there are no stored credentials. |
2779 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2803 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2780 PasswordRetryFormSaveNoUsernameCredentials) { | 2804 PasswordRetryFormSaveNoUsernameCredentials) { |
2781 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2805 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2782 static_cast<password_manager::TestPasswordStore*>( | 2806 static_cast<password_manager::TestPasswordStore*>( |
2783 PasswordStoreFactory::GetForProfile( | 2807 PasswordStoreFactory::GetForProfile( |
2784 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2808 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3045 // about all frames, not just the main one. The factories should receive | 3069 // about all frames, not just the main one. The factories should receive |
3046 // messages for non-main frames, in particular | 3070 // messages for non-main frames, in particular |
3047 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the | 3071 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the |
3048 // factories hear about such frames, this would crash. | 3072 // factories hear about such frames, this would crash. |
3049 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, | 3073 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, |
3050 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 3074 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
3051 TabStripModel::ADD_ACTIVE); | 3075 TabStripModel::ADD_ACTIVE); |
3052 } | 3076 } |
3053 | 3077 |
3054 } // namespace password_manager | 3078 } // namespace password_manager |
OLD | NEW |