| 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 "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 NavigationObserver observer(WebContents()); | 377 NavigationObserver observer(WebContents()); |
| 378 std::string fill_and_submit = | 378 std::string fill_and_submit = |
| 379 "document.getElementById('username_field').value = 'temp';" | 379 "document.getElementById('username_field').value = 'temp';" |
| 380 "document.getElementById('password_field').value = 'random';" | 380 "document.getElementById('password_field').value = 'random';" |
| 381 "document.getElementById('submit_button').click()"; | 381 "document.getElementById('submit_button').click()"; |
| 382 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 382 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 383 observer.Wait(); | 383 observer.Wait(); |
| 384 EXPECT_TRUE(observer.infobar_shown()); | 384 EXPECT_TRUE(observer.infobar_shown()); |
| 385 } | 385 } |
| 386 | 386 |
| 387 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForOtherXHR) { | 387 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 388 PromptForXHRWithoutOnSubmit) { |
| 388 NavigateToFile("/password/password_xhr_submit.html"); | 389 NavigateToFile("/password/password_xhr_submit.html"); |
| 389 | 390 |
| 390 // Verify that if random XHR navigation occurs, we don't try and save the | 391 // Verify that if XHR navigation occurs and the form is properly filled out, |
| 391 // password. | 392 // we try and save the password even though onsubmit hasn't been called. |
| 392 // | |
| 393 // We may want to change this functionality in the future to account for | |
| 394 // cases where the element that users click on isn't a submit button. | |
| 395 NavigationObserver observer(WebContents()); | 393 NavigationObserver observer(WebContents()); |
| 396 std::string fill_and_navigate = | 394 std::string fill_and_navigate = |
| 397 "document.getElementById('username_field').value = 'temp';" | 395 "document.getElementById('username_field').value = 'temp';" |
| 398 "document.getElementById('password_field').value = 'random';" | 396 "document.getElementById('password_field').value = 'random';" |
| 399 "send_xhr()"; | 397 "send_xhr()"; |
| 400 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 398 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 401 observer.Wait(); | 399 observer.Wait(); |
| 400 EXPECT_TRUE(observer.infobar_shown()); |
| 401 } |
| 402 |
| 403 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 404 NoPromptIfLinkClicked) { |
| 405 NavigateToFile("/password/password_form.html"); |
| 406 |
| 407 // Verify that if the user takes a direct action to leave the page, we don't |
| 408 // prompt to save the password even if the form is already filled out. |
| 409 NavigationObserver observer(WebContents()); |
| 410 std::string fill_and_click_link = |
| 411 "document.getElementById('username_field').value = 'temp';" |
| 412 "document.getElementById('password_field').value = 'random';" |
| 413 "document.getElementById('link').click();"; |
| 414 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); |
| 415 observer.Wait(); |
| 402 EXPECT_FALSE(observer.infobar_shown()); | 416 EXPECT_FALSE(observer.infobar_shown()); |
| 403 } | 417 } |
| 404 | 418 |
| 405 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, | 419 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 406 VerifyPasswordGenerationUpload) { | 420 VerifyPasswordGenerationUpload) { |
| 407 // Prevent Autofill requests from actually going over the wire. | 421 // Prevent Autofill requests from actually going over the wire. |
| 408 net::TestURLFetcherFactory factory; | 422 net::TestURLFetcherFactory factory; |
| 409 // Disable Autofill requesting access to AddressBook data. This causes | 423 // Disable Autofill requesting access to AddressBook data. This causes |
| 410 // the test to hang on Mac. | 424 // the test to hang on Mac. |
| 411 autofill::test::DisableSystemServices(browser()->profile()); | 425 autofill::test::DisableSystemServices(browser()->profile()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 "document.getElementById('username_field').value = 'temp';" | 567 "document.getElementById('username_field').value = 'temp';" |
| 554 "document.getElementById('password_field').value = 'random';" | 568 "document.getElementById('password_field').value = 'random';" |
| 555 "document.getElementById('input_submit_button').click();" | 569 "document.getElementById('input_submit_button').click();" |
| 556 "window.location.href = 'done.html';"; | 570 "window.location.href = 'done.html';"; |
| 557 | 571 |
| 558 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); | 572 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); |
| 559 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 573 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
| 560 observer.Wait(); | 574 observer.Wait(); |
| 561 // The only thing we check here is that there is no use-after-free reported. | 575 // The only thing we check here is that there is no use-after-free reported. |
| 562 } | 576 } |
| OLD | NEW |