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/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 PromptObserver::Create(WebContents())); | 244 PromptObserver::Create(WebContents())); |
| 245 std::string fill_and_submit = | 245 std::string fill_and_submit = |
| 246 "document.getElementById('username_field').value = 'temp';" | 246 "document.getElementById('username_field').value = 'temp';" |
| 247 "document.getElementById('password_field').value = 'random';" | 247 "document.getElementById('password_field').value = 'random';" |
| 248 "document.getElementById('submit_button').click()"; | 248 "document.getElementById('submit_button').click()"; |
| 249 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 249 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 250 observer.Wait(); | 250 observer.Wait(); |
| 251 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 251 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Flaky: crbug.com/301547, observed on win and mac. Probably happens on all | 254 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForDynamicForm) { |
| 255 // platforms. | |
| 256 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
| 257 DISABLED_PromptForDynamicForm) { | |
| 258 NavigateToFile("/password/dynamic_password_form.html"); | 255 NavigateToFile("/password/dynamic_password_form.html"); |
| 259 | 256 |
| 257 std::string create_form = | |
| 258 "document.getElementById('create_form_button').click();"; | |
| 259 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form)); | |
| 260 | |
|
vabr (Chromium)
2015/08/07 07:47:58
Would inserting
base::RunLoop run_loop;
run_lo
| |
| 261 // Issue an artificial PasswordStore::GetLogins() request and wait until the | |
| 262 // store returns a response. Hopefully, at that point, the PasswordFormManager | |
| 263 // created for the new form above will have received and processed the store's | |
| 264 // response as well. | |
| 265 scoped_refptr<password_manager::PasswordStore> password_store = | |
| 266 PasswordStoreFactory::GetForProfile( | |
| 267 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get(); | |
| 268 DummyStoreConsumer store_consumer; | |
| 269 store_consumer.RequestLoginsAndWait(password_store); | |
| 270 | |
| 260 // Fill the dynamic password form and submit. | 271 // Fill the dynamic password form and submit. |
| 261 NavigationObserver observer(WebContents()); | 272 NavigationObserver observer(WebContents()); |
| 262 scoped_ptr<PromptObserver> prompt_observer( | 273 scoped_ptr<PromptObserver> prompt_observer( |
| 263 PromptObserver::Create(WebContents())); | 274 PromptObserver::Create(WebContents())); |
| 264 std::string fill_and_submit = | 275 std::string fill_and_submit = |
| 265 "document.getElementById('create_form_button').click();" | |
| 266 "window.setTimeout(function() {" | 276 "window.setTimeout(function() {" |
| 267 " document.dynamic_form.username.value = 'tempro';" | 277 " document.dynamic_form.username.value = 'tempro';" |
| 268 " document.dynamic_form.password.value = 'random';" | 278 " document.dynamic_form.password.value = 'random';" |
| 269 " document.dynamic_form.submit();" | 279 " document.dynamic_form.submit();" |
| 270 "}, 0)"; | 280 "}, 0)"; |
| 271 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 281 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 272 observer.Wait(); | 282 observer.Wait(); |
| 273 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 283 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 274 } | 284 } |
| 275 | 285 |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1405 // needed for autofilling fields. | 1415 // needed for autofilling fields. |
| 1406 content::SimulateMouseClickAt( | 1416 content::SimulateMouseClickAt( |
| 1407 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | 1417 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); |
| 1408 | 1418 |
| 1409 // Wait until that interaction causes the password value to be revealed. | 1419 // Wait until that interaction causes the password value to be revealed. |
| 1410 WaitForElementValue("password", "mypassword"); | 1420 WaitForElementValue("password", "mypassword"); |
| 1411 } | 1421 } |
| 1412 | 1422 |
| 1413 // Test that if a form gets autofilled, then it gets autofilled on re-creation | 1423 // Test that if a form gets autofilled, then it gets autofilled on re-creation |
| 1414 // as well. | 1424 // as well. |
| 1415 // TODO(vabr): This is flaky everywhere. http://crbug.com/442704 | |
| 1416 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1425 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1417 DISABLED_ReCreatedFormsGetFilled) { | 1426 ReCreatedFormsGetFilled) { |
| 1418 NavigateToFile("/password/dynamic_password_form.html"); | 1427 NavigateToFile("/password/dynamic_password_form.html"); |
| 1419 | 1428 |
| 1429 std::string create_form = | |
| 1430 "document.getElementById('create_form_button').click();"; | |
| 1431 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form)); | |
| 1432 | |
| 1433 // Issue an artificial PasswordStore::GetLogins() request and wait until the | |
| 1434 // store returns a response. Hopefully, at that point, the PasswordFormManager | |
| 1435 // created for the new form above will have received and processed the store's | |
| 1436 // response as well. | |
| 1437 scoped_refptr<password_manager::PasswordStore> password_store = | |
| 1438 PasswordStoreFactory::GetForProfile( | |
| 1439 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get(); | |
| 1440 DummyStoreConsumer store_consumer; | |
| 1441 store_consumer.RequestLoginsAndWait(password_store); | |
| 1442 | |
| 1420 // Fill in the credentials, and make sure they are saved. | 1443 // Fill in the credentials, and make sure they are saved. |
| 1421 NavigationObserver form_submit_observer(WebContents()); | 1444 NavigationObserver form_submit_observer(WebContents()); |
| 1422 scoped_ptr<PromptObserver> prompt_observer( | 1445 scoped_ptr<PromptObserver> prompt_observer( |
| 1423 PromptObserver::Create(WebContents())); | 1446 PromptObserver::Create(WebContents())); |
| 1424 std::string create_fill_and_submit = | 1447 std::string fill_and_submit = |
| 1425 "document.getElementById('create_form_button').click();" | |
| 1426 "window.setTimeout(function() {" | 1448 "window.setTimeout(function() {" |
| 1427 " var form = document.getElementById('dynamic_form_id');" | 1449 " var form = document.getElementById('dynamic_form_id');" |
| 1428 " form.username.value = 'temp';" | 1450 " form.username.value = 'temp';" |
| 1429 " form.password.value = 'random';" | 1451 " form.password.value = 'random';" |
| 1430 " form.submit();" | 1452 " form.submit();" |
| 1431 "}, 0)"; | 1453 "}, 0)"; |
| 1432 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_fill_and_submit)); | 1454 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1433 form_submit_observer.Wait(); | 1455 form_submit_observer.Wait(); |
| 1434 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1456 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1435 prompt_observer->Accept(); | 1457 prompt_observer->Accept(); |
| 1436 | 1458 |
| 1437 // Reload the original page to have the saved credentials autofilled. | 1459 // Reload the original page to have the saved credentials autofilled. |
| 1438 NavigationObserver reload_observer(WebContents()); | 1460 NavigationObserver reload_observer(WebContents()); |
| 1439 NavigateToFile("/password/dynamic_password_form.html"); | 1461 NavigateToFile("/password/dynamic_password_form.html"); |
| 1440 reload_observer.Wait(); | 1462 reload_observer.Wait(); |
| 1441 std::string create_form = | |
| 1442 "document.getElementById('create_form_button').click();"; | |
| 1443 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form)); | 1463 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form)); |
| 1444 // Wait until the username is filled, to make sure autofill kicked in. | 1464 // Wait until the username is filled, to make sure autofill kicked in. |
| 1445 WaitForElementValue("username_id", "temp"); | 1465 WaitForElementValue("username_id", "temp"); |
| 1446 | 1466 |
| 1447 // Now the form gets deleted and created again. It should get autofilled | 1467 // Now the form gets deleted and created again. It should get autofilled |
| 1448 // again. | 1468 // again. |
| 1449 std::string delete_form = | 1469 std::string delete_form = |
| 1450 "var form = document.getElementById('dynamic_form_id');" | 1470 "var form = document.getElementById('dynamic_form_id');" |
| 1451 "form.parentNode.removeChild(form);"; | 1471 "form.parentNode.removeChild(form);"; |
| 1452 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), delete_form)); | 1472 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), delete_form)); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2120 // Spin the message loop to make sure the password store had a chance to | 2140 // Spin the message loop to make sure the password store had a chance to |
| 2121 // update the password. | 2141 // update the password. |
| 2122 base::RunLoop run_loop; | 2142 base::RunLoop run_loop; |
| 2123 run_loop.RunUntilIdle(); | 2143 run_loop.RunUntilIdle(); |
| 2124 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2144 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
| 2125 base::ASCIIToUTF16("new_pw")); | 2145 base::ASCIIToUTF16("new_pw")); |
| 2126 } | 2146 } |
| 2127 #endif | 2147 #endif |
| 2128 | 2148 |
| 2129 } // namespace password_manager | 2149 } // namespace password_manager |
| OLD | NEW |