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

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: LazyInstance + commented regexp 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 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1794
1795 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 1795 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
1796 std::string message; 1796 std::string message;
1797 while (message_queue.WaitForMessage(&message)) { 1797 while (message_queue.WaitForMessage(&message)) {
1798 if (message == "\"SUBMISSION_FINISHED\"") 1798 if (message == "\"SUBMISSION_FINISHED\"")
1799 break; 1799 break;
1800 } 1800 }
1801 1801
1802 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1802 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1803 } 1803 }
1804
1805 // Tests that if a site embeds the login and signup forms into one <form>, the
1806 // login form still gets autofilled.
1807 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
1808 AutofillSuggetionsForLoginSignupForm) {
1809 password_manager::TestPasswordStore* password_store =
1810 static_cast<password_manager::TestPasswordStore*>(
1811 PasswordStoreFactory::GetForProfile(
1812 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1813
1814 EXPECT_TRUE(password_store->IsEmpty());
1815
1816 NavigateToFile("/password/login_signup_form.html");
1817
1818 NavigationObserver observer(WebContents());
1819 scoped_ptr<PromptObserver> prompt_observer(
1820 PromptObserver::Create(WebContents()));
1821 std::string submit =
1822 "document.getElementById('username').value = 'myusername';"
1823 "document.getElementById('password').value = 'mypassword';"
1824 "document.getElementById('submit').click();";
1825 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1826 observer.Wait();
1827
1828 prompt_observer->Accept();
1829
1830 // Spin the message loop to make sure the password store had a chance to save
1831 // the password.
1832 base::RunLoop run_loop;
1833 run_loop.RunUntilIdle();
1834 EXPECT_FALSE(password_store->IsEmpty());
1835
1836 // Now, navigate to the same html password form and verify whether password is
1837 // autofilled.
1838 NavigateToFile("/password/login_signup_form.html");
1839
1840 // Let the user interact with the page, so that DOM gets modification events,
1841 // needed for autofilling fields.
1842 content::SimulateMouseClickAt(
1843 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1));
1844
1845 // Wait until that interaction causes the password value to be revealed.
1846 WaitForElementValue("password", "mypassword");
1847 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698