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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 std::string fill_and_submit = | 1576 std::string fill_and_submit = |
1577 "document.getElementById('chg_not_username_field').value = 'temp';" | 1577 "document.getElementById('chg_not_username_field').value = 'temp';" |
1578 "document.getElementById('chg_password_field').value = 'random';" | 1578 "document.getElementById('chg_password_field').value = 'random';" |
1579 "document.getElementById('chg_new_password_1').value = 'random1';" | 1579 "document.getElementById('chg_new_password_1').value = 'random1';" |
1580 "document.getElementById('chg_new_password_2').value = 'random1';" | 1580 "document.getElementById('chg_new_password_2').value = 'random1';" |
1581 "document.getElementById('chg_submit_button').click()"; | 1581 "document.getElementById('chg_submit_button').click()"; |
1582 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1582 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1583 observer.Wait(); | 1583 observer.Wait(); |
1584 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1584 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
1585 } | 1585 } |
| 1586 |
| 1587 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptOnBack) { |
| 1588 // Go to a successful landing page through submitting first, so that it is |
| 1589 // reachable through going back, and the remembered page transition is form |
| 1590 // submit. There is no need to submit non-empty strings. |
| 1591 NavigateToFile("/password/password_form.html"); |
| 1592 |
| 1593 NavigationObserver dummy_submit_observer(WebContents()); |
| 1594 std::string just_submit = |
| 1595 "document.getElementById('input_submit_button').click()"; |
| 1596 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), just_submit)); |
| 1597 dummy_submit_observer.Wait(); |
| 1598 |
| 1599 // Now go to a page with a form again, fill the form, and go back instead of |
| 1600 // submitting it. |
| 1601 NavigateToFile("/password/dummy_submit.html"); |
| 1602 |
| 1603 NavigationObserver observer(WebContents()); |
| 1604 scoped_ptr<PromptObserver> prompt_observer( |
| 1605 PromptObserver::Create(WebContents())); |
| 1606 // The (dummy) submit is necessary to provisionally save the typed password. A |
| 1607 // user typing in the password field would not need to submit to provisionally |
| 1608 // save it, but the script cannot trigger that just by assigning to the |
| 1609 // field's value. |
| 1610 std::string fill_and_back = |
| 1611 "document.getElementById('password_field').value = 'random';" |
| 1612 "document.getElementById('input_submit_button').click();" |
| 1613 "window.history.back();"; |
| 1614 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back)); |
| 1615 observer.Wait(); |
| 1616 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1617 } |
OLD | NEW |