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 "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 NavigationObserver observer(WebContents()); | 147 NavigationObserver observer(WebContents()); |
148 std::string fill_and_submit = | 148 std::string fill_and_submit = |
149 "document.getElementById('username_field').value = 'temp';" | 149 "document.getElementById('username_field').value = 'temp';" |
150 "document.getElementById('password_field').value = 'random';" | 150 "document.getElementById('password_field').value = 'random';" |
151 "document.getElementById('submit_button').click()"; | 151 "document.getElementById('submit_button').click()"; |
152 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 152 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
153 observer.Wait(); | 153 observer.Wait(); |
154 EXPECT_TRUE(observer.infobar_shown()); | 154 EXPECT_TRUE(observer.infobar_shown()); |
155 } | 155 } |
156 | 156 |
| 157 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 158 PromptForDynamicForm) { |
| 159 ASSERT_TRUE(test_server()->Start()); |
| 160 |
| 161 GURL url = test_server()->GetURL("files/password/dynamic_password_form.html"); |
| 162 ui_test_utils::NavigateToURL(browser(), url); |
| 163 |
| 164 // Fill the dynamic password form and submit. |
| 165 NavigationObserver observer(WebContents()); |
| 166 std::string fill_and_submit = |
| 167 "document.dynamic_form.username.value = 'temp';" |
| 168 "document.dynamic_form.password.value = 'random';" |
| 169 "document.dynamic_form.submit()"; |
| 170 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 171 observer.Wait(); |
| 172 EXPECT_TRUE(observer.infobar_shown()); |
| 173 } |
| 174 |
157 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { | 175 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { |
158 ASSERT_TRUE(test_server()->Start()); | 176 ASSERT_TRUE(test_server()->Start()); |
159 | 177 |
160 GURL url = test_server()->GetURL("files/password/password_form.html"); | 178 GURL url = test_server()->GetURL("files/password/password_form.html"); |
161 ui_test_utils::NavigateToURL(browser(), url); | 179 ui_test_utils::NavigateToURL(browser(), url); |
162 | 180 |
163 // Don't fill the password form, just navigate away. Shouldn't prompt. | 181 // Don't fill the password form, just navigate away. Shouldn't prompt. |
164 NavigationObserver observer(WebContents()); | 182 NavigationObserver observer(WebContents()); |
165 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 183 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
166 "window.location.href = 'done.html';")); | 184 "window.location.href = 'done.html';")); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // cases where the element that users click on isn't a submit button. | 279 // cases where the element that users click on isn't a submit button. |
262 NavigationObserver observer(WebContents()); | 280 NavigationObserver observer(WebContents()); |
263 std::string fill_and_navigate = | 281 std::string fill_and_navigate = |
264 "document.getElementById('username_field').value = 'temp';" | 282 "document.getElementById('username_field').value = 'temp';" |
265 "document.getElementById('password_field').value = 'random';" | 283 "document.getElementById('password_field').value = 'random';" |
266 "send_xhr()"; | 284 "send_xhr()"; |
267 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 285 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
268 observer.Wait(); | 286 observer.Wait(); |
269 EXPECT_FALSE(observer.infobar_shown()); | 287 EXPECT_FALSE(observer.infobar_shown()); |
270 } | 288 } |
OLD | NEW |