Chromium Code Reviews| Index: chrome/browser/password_manager/password_manager_browsertest.cc |
| diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc |
| index 79aacd5ba1bcdec70db6b217f5e0dfb8e2906ad9..828642b5756dc7c4f006392267d8f2883c71c17a 100644 |
| --- a/chrome/browser/password_manager/password_manager_browsertest.cc |
| +++ b/chrome/browser/password_manager/password_manager_browsertest.cc |
| @@ -21,6 +21,7 @@ |
| #include "components/infobars/core/infobar.h" |
| #include "components/infobars/core/infobar_manager.h" |
| #include "components/password_manager/core/browser/test_password_store.h" |
| +#include "components/password_manager/core/common/password_manager_switches.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_observer.h" |
| @@ -162,6 +163,9 @@ class PasswordManagerBrowserTest : public InProcessBrowserTest { |
| if (!embedded_test_server()->Started()) |
| ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| + // Checkes that enable-automatic-password-saving is not enabled |
|
vabr (Chromium)
2014/04/29 09:08:26
nit: This comment is not really necessary, please
rchtara
2014/04/29 12:20:08
Done.
|
| + ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( |
| + password_manager::switches::kEnableAutomaticPasswordSaving)); |
| NavigationObserver observer(WebContents()); |
| GURL url = embedded_test_server()->GetURL(path); |
| ui_test_utils::NavigateToURL(browser(), url); |
| @@ -647,3 +651,40 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| observer.Wait(); |
| EXPECT_FALSE(observer.infobar_shown()); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| + PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { |
| + NavigateToFile("/password/password_form.html"); |
| + |
| + // Fill a form and submit through a <input type="submit"> button. Nothing |
|
vabr (Chromium)
2014/04/29 09:08:26
nit: "Nothing special" is just clutter, please rem
rchtara
2014/04/29 12:20:08
Done.
|
| + // special. |
| + NavigationObserver observer(WebContents()); |
| + std::string fill_and_submit = |
| + "document.getElementById('username_field').value = 'temp';" |
| + "document.getElementById('password_field').value = 'random';" |
| + "document.getElementById('input_submit_button').click()"; |
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| + observer.Wait(); |
| + EXPECT_TRUE(observer.infobar_shown()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F( |
| + PasswordManagerBrowserTest, |
| + DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { |
| + NavigateToFile("/password/password_form.html"); |
| + |
| + // Enable the enable-automatic-password-saving switch |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + password_manager::switches::kEnableAutomaticPasswordSaving); |
| + |
| + // Fill a form and submit through a <input type="submit"> button. Nothing |
| + // special. |
| + NavigationObserver observer(WebContents()); |
| + std::string fill_and_submit = |
| + "document.getElementById('username_field').value = 'temp';" |
| + "document.getElementById('password_field').value = 'random';" |
| + "document.getElementById('input_submit_button').click()"; |
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| + observer.Wait(); |
| + EXPECT_FALSE(observer.infobar_shown()); |
|
vabr (Chromium)
2014/04/29 09:08:26
Please also check that the password indeed got sav
|
| +} |