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 | |
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 int internals_index = browser->tab_strip_model()->active_index(); | |
179 | |
180 ui_test_utils::NavigateToURLWithDisposition( | |
181 browser, form_page, NEW_FOREGROUND_TAB, | |
182 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
183 | |
184 browser->tab_strip_model()->ActivateTabAt(internals_index, true); | |
185 | |
186 std::string find_renderer_logs = | |
187 "function logChecker() {" | |
188 " var text = document.getElementById('log-entries').innerText;" | |
189 " var logs_found = /" + | |
190 str + | |
191 "/.test(text);" | |
192 " if (logs_found) {" | |
193 " location = 'done.html';" | |
194 " } else {" | |
195 " window.setTimeout(logChecker, 500);" | |
196 " }" | |
197 "}" | |
198 "window.setTimeout(logChecker, 0);"; | |
199 NavigationObserver observer( | |
200 browser->tab_strip_model()->GetActiveWebContents()); | |
201 ASSERT_TRUE(content::ExecuteScript( | |
202 browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), | |
203 find_renderer_logs)); | |
204 observer.Wait(); | |
205 } | |
206 | |
166 } // namespace | 207 } // namespace |
167 | 208 |
168 namespace password_manager { | 209 namespace password_manager { |
169 | 210 |
170 // Actual tests --------------------------------------------------------------- | 211 // Actual tests --------------------------------------------------------------- |
171 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { | 212 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { |
172 NavigateToFile("/password/password_form.html"); | 213 NavigateToFile("/password/password_form.html"); |
173 | 214 |
174 // Fill a form and submit through a <input type="submit"> button. Nothing | 215 // Fill a form and submit through a <input type="submit"> button. Nothing |
175 // special. | 216 // special. |
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2735 | 2776 |
2736 std::string get_password = | 2777 std::string get_password = |
2737 "window.domAutomationController.send(" | 2778 "window.domAutomationController.send(" |
2738 " document.getElementById('hidden_password_form').elements[2].value);"; | 2779 " document.getElementById('hidden_password_form').elements[2].value);"; |
2739 std::string actual_password; | 2780 std::string actual_password; |
2740 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2781 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2741 RenderViewHost(), get_password, &actual_password)); | 2782 RenderViewHost(), get_password, &actual_password)); |
2742 EXPECT_EQ("mypassword", actual_password); | 2783 EXPECT_EQ("mypassword", actual_password); |
2743 } | 2784 } |
2744 | 2785 |
2745 // Check that the internals page contains logs both from the renderer and the | 2786 // Check that the internals page contains logs from the renderer. |
2746 // browser. | 2787 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Renderer) { |
2747 // TODO(crbug.com/640737) Flaky on Mac. | 2788 WaitForStringInInternals( |
2748 #if defined(OS_MACOSX) | 2789 "PasswordAutofillAgent::", |
2749 #define MAYBE_InternalsPage DISABLED_InternalsPage | 2790 embedded_test_server()->GetURL("/password/password_form.html"), |
2750 #else | 2791 browser()); |
2751 #define MAYBE_InternalsPage InternalsPage | 2792 } |
2752 #endif | |
2753 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, MAYBE_InternalsPage) { | |
2754 ui_test_utils::NavigateToURLWithDisposition( | |
2755 browser(), GURL("chrome://password-manager-internals"), CURRENT_TAB, | |
2756 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
2757 content::WebContents* internals_web_contents = WebContents(); | |
2758 | 2793 |
2759 ui_test_utils::NavigateToURLWithDisposition( | 2794 // Check that the internals page contains logs both from the browser. |
vasilii
2016/08/29 13:56:07
logs from the browser.
vabr (Chromium)
2016/08/29 15:40:36
Done.
| |
2760 browser(), embedded_test_server()->GetURL("/password/password_form.html"), | 2795 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Browser) { |
2761 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2796 WaitForStringInInternals( |
2762 | 2797 "PasswordManager::", |
2763 std::string find_renderer_logs = | 2798 embedded_test_server()->GetURL("/password/password_form.html"), |
2764 "var text = document.getElementById('log-entries').innerText;" | 2799 browser()); |
2765 "var logs_found = /PasswordAutofillAgent::/.test(text);" | |
2766 "window.domAutomationController.send(logs_found);"; | |
2767 bool renderer_logs_found; | |
2768 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2769 internals_web_contents->GetRenderViewHost(), find_renderer_logs, | |
2770 &renderer_logs_found)); | |
2771 EXPECT_TRUE(renderer_logs_found); | |
2772 | |
2773 std::string find_browser_logs = | |
2774 "var text = document.getElementById('log-entries').innerText;" | |
2775 "var logs_found = /PasswordManager::/.test(text);" | |
2776 "window.domAutomationController.send(logs_found);"; | |
2777 bool browser_logs_found; | |
2778 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2779 internals_web_contents->GetRenderViewHost(), find_browser_logs, | |
2780 &browser_logs_found)); | |
2781 EXPECT_TRUE(browser_logs_found); | |
2782 } | 2800 } |
2783 | 2801 |
2784 // Tests that submitted credentials are saved on a password form without | 2802 // Tests that submitted credentials are saved on a password form without |
2785 // username element when there are no stored credentials. | 2803 // username element when there are no stored credentials. |
2786 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2804 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2787 PasswordRetryFormSaveNoUsernameCredentials) { | 2805 PasswordRetryFormSaveNoUsernameCredentials) { |
2788 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2806 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2789 static_cast<password_manager::TestPasswordStore*>( | 2807 static_cast<password_manager::TestPasswordStore*>( |
2790 PasswordStoreFactory::GetForProfile( | 2808 PasswordStoreFactory::GetForProfile( |
2791 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2809 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3052 // about all frames, not just the main one. The factories should receive | 3070 // about all frames, not just the main one. The factories should receive |
3053 // messages for non-main frames, in particular | 3071 // messages for non-main frames, in particular |
3054 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the | 3072 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the |
3055 // factories hear about such frames, this would crash. | 3073 // factories hear about such frames, this would crash. |
3056 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, | 3074 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, |
3057 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 3075 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
3058 TabStripModel::ADD_ACTIVE); | 3076 TabStripModel::ADD_ACTIVE); |
3059 } | 3077 } |
3060 | 3078 |
3061 } // namespace password_manager | 3079 } // namespace password_manager |
OLD | NEW |