Chromium Code Reviews| 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 "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1172 NavigationObserver observer(WebContents()); | 1172 NavigationObserver observer(WebContents()); |
| 1173 scoped_ptr<PromptObserver> prompt_observer( | 1173 scoped_ptr<PromptObserver> prompt_observer( |
| 1174 PromptObserver::Create(WebContents())); | 1174 PromptObserver::Create(WebContents())); |
| 1175 ui_test_utils::NavigateToURL(browser(), https_url); | 1175 ui_test_utils::NavigateToURL(browser(), https_url); |
| 1176 | 1176 |
| 1177 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1177 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
| 1178 observer.Wait(); | 1178 observer.Wait(); |
| 1179 | 1179 |
| 1180 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1180 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1181 } | 1181 } |
| 1182 | |
| 1183 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, | |
| 1184 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { | |
| 1185 password_manager::TestPasswordStore* password_store = | |
| 1186 static_cast<password_manager::TestPasswordStore*>( | |
| 1187 PasswordStoreFactory::GetForProfile(browser()->profile(), | |
| 1188 Profile::IMPLICIT_ACCESS).get()); | |
| 1189 | |
| 1190 EXPECT_TRUE(password_store->IsEmpty()); | |
| 1191 | |
| 1192 NavigateToFile("/password/form_with_only_password_field.html"); | |
| 1193 | |
| 1194 NavigationObserver observer(WebContents()); | |
| 1195 scoped_ptr<PromptObserver> prompt_observer( | |
| 1196 PromptObserver::Create(WebContents())); | |
| 1197 std::string submit = | |
| 1198 "document.getElementById('password').value = 'password';" | |
| 1199 "document.getElementById('submit-button').click();"; | |
| 1200 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | |
| 1201 observer.Wait(); | |
| 1202 | |
| 1203 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | |
| 1204 prompt_observer->Accept(); | |
| 1205 | |
| 1206 // Spin the message loop to make sure the password store had a chance to save | |
| 1207 // the password. | |
| 1208 base::RunLoop run_loop; | |
| 1209 run_loop.RunUntilIdle(); | |
| 1210 EXPECT_FALSE(password_store->IsEmpty()); | |
| 1211 } | |
| 1212 | |
| 1213 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, | |
| 1214 AutofillSuggetionsForPasswordFormWithoutUsernameField) { | |
| 1215 password_manager::TestPasswordStore* password_store = | |
| 1216 static_cast<password_manager::TestPasswordStore*>( | |
| 1217 PasswordStoreFactory::GetForProfile(browser()->profile(), | |
| 1218 Profile::IMPLICIT_ACCESS).get()); | |
| 1219 | |
| 1220 EXPECT_TRUE(password_store->IsEmpty()); | |
| 1221 | |
| 1222 // Password form without username-field. | |
| 1223 NavigateToFile("/password/form_with_only_password_field.html"); | |
| 1224 | |
| 1225 NavigationObserver observer(WebContents()); | |
| 1226 scoped_ptr<PromptObserver> prompt_observer( | |
| 1227 PromptObserver::Create(WebContents())); | |
| 1228 std::string submit = | |
| 1229 "document.getElementById('password').value = 'mypassword';" | |
| 1230 "document.getElementById('submit-button').click();"; | |
| 1231 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | |
| 1232 observer.Wait(); | |
| 1233 | |
| 1234 prompt_observer->Accept(); | |
| 1235 | |
| 1236 // Spin the message loop to make sure the password store had a chance to save | |
| 1237 // the password. | |
| 1238 base::RunLoop run_loop; | |
| 1239 run_loop.RunUntilIdle(); | |
| 1240 EXPECT_FALSE(password_store->IsEmpty()); | |
| 1241 | |
| 1242 // The redirection page now redirects via Javascript. | |
|
vabr (Chromium)
2014/09/24 09:47:43
It is not clear what is "the redirection page", an
Pritam Nikam
2014/09/24 12:57:55
Done.
Added just for confirmation. Removed now as
| |
| 1243 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | |
| 1244 "window.location.href = 'done.html';")); | |
| 1245 observer.Wait(); | |
| 1246 | |
| 1247 // Now, navigate to same html password form and verify whether password is | |
| 1248 // autofilled. | |
| 1249 NavigateToFile("/password/form_with_only_password_field.html"); | |
| 1250 | |
| 1251 // Let the user interact with the page, so that DOM gets modification events, | |
| 1252 // needed for autofilling fields. | |
| 1253 content::SimulateMouseClickAt( | |
| 1254 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | |
| 1255 | |
| 1256 // Wait until that interaction causes the password value to be revealed. | |
| 1257 WaitForElementValue("password", "mypassword"); | |
| 1258 } | |
| OLD | NEW |