| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 NavigationObserver observer(WebContents()); | 169 NavigationObserver observer(WebContents()); |
| 170 std::string fill_and_submit = | 170 std::string fill_and_submit = |
| 171 "document.getElementById('username_field').value = 'temp';" | 171 "document.getElementById('username_field').value = 'temp';" |
| 172 "document.getElementById('password_field').value = 'random';" | 172 "document.getElementById('password_field').value = 'random';" |
| 173 "document.getElementById('submit_button').click()"; | 173 "document.getElementById('submit_button').click()"; |
| 174 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 174 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 175 observer.Wait(); | 175 observer.Wait(); |
| 176 EXPECT_TRUE(observer.infobar_shown()); | 176 EXPECT_TRUE(observer.infobar_shown()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 180 PromptForDynamicForm) { |
| 181 NavigateToFile("/password/dynamic_password_form.html"); |
| 182 |
| 183 // Fill the dynamic password form and submit. |
| 184 NavigationObserver observer(WebContents()); |
| 185 std::string fill_and_submit = |
| 186 "document.getElementById('create_form_button').click();" |
| 187 "window.setTimeout(function() {" |
| 188 " document.dynamic_form.username.value = 'tempro';" |
| 189 " document.dynamic_form.password.value = 'random';" |
| 190 " document.dynamic_form.submit();" |
| 191 "}, 0)"; |
| 192 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 193 observer.Wait(); |
| 194 EXPECT_TRUE(observer.infobar_shown()); |
| 195 } |
| 196 |
| 179 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { | 197 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForNavigation) { |
| 180 NavigateToFile("/password/password_form.html"); | 198 NavigateToFile("/password/password_form.html"); |
| 181 | 199 |
| 182 // Don't fill the password form, just navigate away. Shouldn't prompt. | 200 // Don't fill the password form, just navigate away. Shouldn't prompt. |
| 183 NavigationObserver observer(WebContents()); | 201 NavigationObserver observer(WebContents()); |
| 184 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 202 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| 185 "window.location.href = 'done.html';")); | 203 "window.location.href = 'done.html';")); |
| 186 observer.Wait(); | 204 observer.Wait(); |
| 187 EXPECT_FALSE(observer.infobar_shown()); | 205 EXPECT_FALSE(observer.infobar_shown()); |
| 188 } | 206 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // cases where the element that users click on isn't a submit button. | 285 // cases where the element that users click on isn't a submit button. |
| 268 NavigationObserver observer(WebContents()); | 286 NavigationObserver observer(WebContents()); |
| 269 std::string fill_and_navigate = | 287 std::string fill_and_navigate = |
| 270 "document.getElementById('username_field').value = 'temp';" | 288 "document.getElementById('username_field').value = 'temp';" |
| 271 "document.getElementById('password_field').value = 'random';" | 289 "document.getElementById('password_field').value = 'random';" |
| 272 "send_xhr()"; | 290 "send_xhr()"; |
| 273 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 291 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 274 observer.Wait(); | 292 observer.Wait(); |
| 275 EXPECT_FALSE(observer.infobar_shown()); | 293 EXPECT_FALSE(observer.infobar_shown()); |
| 276 } | 294 } |
| OLD | NEW |