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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 std::string fill_and_submit = | 156 std::string fill_and_submit = |
157 "document.getElementById('username_failed').value = 'temp';" | 157 "document.getElementById('username_failed').value = 'temp';" |
158 "document.getElementById('password_failed').value = 'random';" | 158 "document.getElementById('password_failed').value = 'random';" |
159 "document.getElementById('failed_form').submit()"; | 159 "document.getElementById('failed_form').submit()"; |
160 | 160 |
161 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); | 161 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); |
162 observer.Wait(); | 162 observer.Wait(); |
163 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 163 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); |
164 } | 164 } |
165 | 165 |
166 // Opens the internals page, then some page with a HTML form. Then it activates | |
167 // back the internals page and waits until it contains the string segment |str|. | |
168 // The check is done by a repeatedly called JavaScript function, which navigates | |
vasilii
2016/08/30 14:09:48
obsolete
vabr (Chromium)
2016/09/02 16:29:22
Thanks for spotting. I inlined the helper method,
| |
169 // away from the internals page as soon as it finds |str|. Thus, the waiting for | |
170 // |str| is reduced to waiting for a navigation. |browser| needs to represent | |
171 // the current test Chrome window. | |
172 void WaitForStringInInternals(const std::string& str, | |
173 const GURL& form_page, | |
174 Browser* browser) { | |
175 ui_test_utils::NavigateToURLWithDisposition( | |
176 browser, GURL("chrome://password-manager-internals"), CURRENT_TAB, | |
177 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
178 content::WebContents* internals_web_contents = | |
179 browser->tab_strip_model()->GetActiveWebContents(); | |
180 | |
181 ui_test_utils::NavigateToURLWithDisposition( | |
182 browser, form_page, NEW_FOREGROUND_TAB, | |
183 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
184 content::WebContents* forms_web_contents = | |
185 browser->tab_strip_model()->GetActiveWebContents(); | |
186 | |
187 // Reload the frame with the forms to ensure that the activation of logging | |
188 // was propagated to the renderer before it could emit the first log. | |
189 NavigationObserver observer(forms_web_contents); | |
190 forms_web_contents->ReloadFocusedFrame(false); | |
191 observer.Wait(); | |
192 | |
193 std::string find_logs = | |
194 "var text = document.getElementById('log-entries').innerText;" | |
195 "var logs_found = /" + | |
196 str + | |
197 "/.test(text);" | |
198 "window.domAutomationController.send(logs_found);"; | |
199 bool logs_found = false; | |
200 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
201 internals_web_contents->GetRenderViewHost(), find_logs, &logs_found)); | |
202 EXPECT_TRUE(logs_found); | |
203 } | |
204 | |
166 } // namespace | 205 } // namespace |
167 | 206 |
168 namespace password_manager { | 207 namespace password_manager { |
169 | 208 |
170 // Actual tests --------------------------------------------------------------- | 209 // Actual tests --------------------------------------------------------------- |
171 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { | 210 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { |
172 NavigateToFile("/password/password_form.html"); | 211 NavigateToFile("/password/password_form.html"); |
173 | 212 |
174 // Fill a form and submit through a <input type="submit"> button. Nothing | 213 // Fill a form and submit through a <input type="submit"> button. Nothing |
175 // special. | 214 // special. |
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2735 | 2774 |
2736 std::string get_password = | 2775 std::string get_password = |
2737 "window.domAutomationController.send(" | 2776 "window.domAutomationController.send(" |
2738 " document.getElementById('hidden_password_form').elements[2].value);"; | 2777 " document.getElementById('hidden_password_form').elements[2].value);"; |
2739 std::string actual_password; | 2778 std::string actual_password; |
2740 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2779 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2741 RenderViewHost(), get_password, &actual_password)); | 2780 RenderViewHost(), get_password, &actual_password)); |
2742 EXPECT_EQ("mypassword", actual_password); | 2781 EXPECT_EQ("mypassword", actual_password); |
2743 } | 2782 } |
2744 | 2783 |
2745 // Check that the internals page contains logs both from the renderer and the | 2784 // Check that the internals page contains logs from the renderer. |
2746 // browser. | 2785 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Renderer) { |
2747 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage) { | 2786 WaitForStringInInternals( |
2748 ui_test_utils::NavigateToURLWithDisposition( | 2787 "PasswordAutofillAgent::", |
2749 browser(), GURL("chrome://password-manager-internals"), CURRENT_TAB, | 2788 embedded_test_server()->GetURL("/password/password_form.html"), |
2750 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2789 browser()); |
2751 content::WebContents* internals_web_contents = WebContents(); | 2790 } |
2752 | 2791 |
2753 ui_test_utils::NavigateToURLWithDisposition( | 2792 // Check that the internals page contains logs from the browser. |
2754 browser(), embedded_test_server()->GetURL("/password/password_form.html"), | 2793 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Browser) { |
2755 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2794 WaitForStringInInternals( |
2756 | 2795 "PasswordManager::", |
2757 std::string find_renderer_logs = | 2796 embedded_test_server()->GetURL("/password/password_form.html"), |
2758 "var text = document.getElementById('log-entries').innerText;" | 2797 browser()); |
2759 "var logs_found = /PasswordAutofillAgent::/.test(text);" | |
2760 "window.domAutomationController.send(logs_found);"; | |
2761 bool renderer_logs_found; | |
2762 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2763 internals_web_contents->GetRenderViewHost(), find_renderer_logs, | |
2764 &renderer_logs_found)); | |
2765 EXPECT_TRUE(renderer_logs_found); | |
2766 | |
2767 std::string find_browser_logs = | |
2768 "var text = document.getElementById('log-entries').innerText;" | |
2769 "var logs_found = /PasswordManager::/.test(text);" | |
2770 "window.domAutomationController.send(logs_found);"; | |
2771 bool browser_logs_found; | |
2772 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2773 internals_web_contents->GetRenderViewHost(), find_browser_logs, | |
2774 &browser_logs_found)); | |
2775 EXPECT_TRUE(browser_logs_found); | |
2776 } | 2798 } |
2777 | 2799 |
2778 // Tests that submitted credentials are saved on a password form without | 2800 // Tests that submitted credentials are saved on a password form without |
2779 // username element when there are no stored credentials. | 2801 // username element when there are no stored credentials. |
2780 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2802 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2781 PasswordRetryFormSaveNoUsernameCredentials) { | 2803 PasswordRetryFormSaveNoUsernameCredentials) { |
2782 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2804 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2783 static_cast<password_manager::TestPasswordStore*>( | 2805 static_cast<password_manager::TestPasswordStore*>( |
2784 PasswordStoreFactory::GetForProfile( | 2806 PasswordStoreFactory::GetForProfile( |
2785 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2807 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3046 // about all frames, not just the main one. The factories should receive | 3068 // about all frames, not just the main one. The factories should receive |
3047 // messages for non-main frames, in particular | 3069 // messages for non-main frames, in particular |
3048 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the | 3070 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the |
3049 // factories hear about such frames, this would crash. | 3071 // factories hear about such frames, this would crash. |
3050 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, | 3072 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, |
3051 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 3073 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
3052 TabStripModel::ADD_ACTIVE); | 3074 TabStripModel::ADD_ACTIVE); |
3053 } | 3075 } |
3054 | 3076 |
3055 } // namespace password_manager | 3077 } // namespace password_manager |
OLD | NEW |