Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 1014683006: [Password manager] Recognise squashed login+sign-up forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failing PasswordManagerTest Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 "document.getElementById('username_field').value = 'username';" 1653 "document.getElementById('username_field').value = 'username';"
1654 "document.getElementById('password_field').value = 'mypass';" 1654 "document.getElementById('password_field').value = 'mypass';"
1655 "document.getElementById('confirm_field').value = 'mypass';" 1655 "document.getElementById('confirm_field').value = 'mypass';"
1656 "document.getElementById('security_answer').value = 'hometown';" 1656 "document.getElementById('security_answer').value = 'hometown';"
1657 "document.getElementById('SSN').value = '1234';" 1657 "document.getElementById('SSN').value = '1234';"
1658 "document.getElementById('testform').submit();"; 1658 "document.getElementById('testform').submit();";
1659 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 1659 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
1660 observer.Wait(); 1660 observer.Wait();
1661 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1661 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1662 } 1662 }
1663
1664 // Tests that if a site embeds the login and signup forms into one <form>, the
1665 // login form still gets autofilled.
1666 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
1667 AutofillSuggetionsForLoginSignupForm) {
1668 password_manager::TestPasswordStore* password_store =
1669 static_cast<password_manager::TestPasswordStore*>(
1670 PasswordStoreFactory::GetForProfile(
1671 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1672
1673 EXPECT_TRUE(password_store->IsEmpty());
1674
1675 // Password form without username-field.
Garrett Casto 2015/03/17 22:49:37 I think this is leftover from copy and paste.
vabr (Chromium) 2015/03/18 16:51:03 Done.
1676 NavigateToFile("/password/login_signup_form.html");
1677
1678 NavigationObserver observer(WebContents());
1679 scoped_ptr<PromptObserver> prompt_observer(
1680 PromptObserver::Create(WebContents()));
1681 std::string submit =
1682 "document.getElementById('username').value = 'myusername';"
1683 "document.getElementById('password').value = 'mypassword';"
1684 "document.getElementById('submit').click();";
1685 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1686 observer.Wait();
1687
1688 prompt_observer->Accept();
1689
1690 // Spin the message loop to make sure the password store had a chance to save
1691 // the password.
1692 base::RunLoop run_loop;
1693 run_loop.RunUntilIdle();
1694 EXPECT_FALSE(password_store->IsEmpty());
1695
1696 // Now, navigate to the same html password form and verify whether password is
1697 // autofilled.
1698 NavigateToFile("/password/login_signup_form.html");
1699
1700 // Let the user interact with the page, so that DOM gets modification events,
1701 // needed for autofilling fields.
1702 content::SimulateMouseClickAt(
1703 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1));
1704
1705 // Wait until that interaction causes the password value to be revealed.
1706 WaitForElementValue("password", "mypassword");
1707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698