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 3598b357dac321f4dedaca92508ab9cb630e1f3c..3c24bae0f364663b03f53271dd36bb144cb8e016 100644 |
| --- a/chrome/browser/password_manager/password_manager_browsertest.cc |
| +++ b/chrome/browser/password_manager/password_manager_browsertest.cc |
| @@ -1381,11 +1381,6 @@ IN_PROC_BROWSER_TEST_F( |
| IN_PROC_BROWSER_TEST_F( |
| PasswordManagerBrowserTestBase, |
| NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - ::switches::kAllowRunningInsecureContent); |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - ::switches::kIgnoreCertificateErrors); |
| - |
| // This test case cannot inject the scripts via content::ExecuteScript() in |
| // files served through HTTPS. Therefore the scripts are made part of the HTML |
| // site and executed on load. |
| @@ -1410,11 +1405,6 @@ IN_PROC_BROWSER_TEST_F( |
| IN_PROC_BROWSER_TEST_F( |
| PasswordManagerBrowserTestBase, |
| NoPromptForSeperateLoginFormWhenSwitchingFromHttpsToHttp) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - ::switches::kAllowRunningInsecureContent); |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - ::switches::kIgnoreCertificateErrors); |
| - |
| std::string path = "/password/password_form.html"; |
| GURL https_url(https_test_server().GetURL(path)); |
| ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); |
| @@ -1511,6 +1501,48 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| CheckElementValue("password_field", "12345"); |
| } |
| +// Tests that obsolete HTTP credentials are moved when a site migrated to HTTPS |
| +// and has HSTS enabled. |
| +IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| + ObsoleteHttpCredentialMovedOnMigrationToHstsSite) { |
| + // Add an http credential to the password store. |
| + GURL https_origin = https_test_server().base_url(); |
| + ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme)); |
| + GURL::Replacements rep; |
| + rep.SetSchemeStr(url::kHttpScheme); |
| + GURL http_origin = https_origin.ReplaceComponents(rep); |
| + autofill::PasswordForm http_form; |
| + http_form.signon_realm = http_origin.spec(); |
| + http_form.origin = http_origin; |
| + // Assume that the previous action was already HTTPS one matching the current |
| + // page. |
| + http_form.action = https_origin; |
|
vasilii
2017/03/10 15:37:43
Needed?
jdoerrie
2017/03/13 17:26:21
Nope.
|
| + http_form.username_value = base::ASCIIToUTF16("user"); |
| + http_form.password_value = base::ASCIIToUTF16("12345"); |
| + scoped_refptr<password_manager::TestPasswordStore> password_store = |
| + static_cast<password_manager::TestPasswordStore*>( |
| + PasswordStoreFactory::GetForProfile( |
| + browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
| + .get()); |
| + password_store->AddLogin(http_form); |
| + |
| + // Treat the host of the HTTPS test server as HSTS. |
| + AddHSTSHost(https_test_server().host_port_pair().host()); |
| + |
| + // Navigate to HTTPS page and trigger the migration. |
| + NavigationObserver form_observer(WebContents()); |
| + ui_test_utils::NavigateToURL( |
| + browser(), https_test_server().GetURL("/password/password_form.html")); |
| + form_observer.Wait(); |
| + WaitForPasswordStore(); |
|
vasilii
2017/03/10 15:37:43
Why don't we wait here twice?
jdoerrie
2017/03/13 17:26:21
Testing locally the test passed without the second
|
| + |
| + // Only HTTPS passwords should be present. |
| + EXPECT_TRUE( |
| + password_store->stored_passwords().at(http_origin.spec()).empty()); |
| + EXPECT_FALSE( |
| + password_store->stored_passwords().at(https_origin.spec()).empty()); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { |
| scoped_refptr<password_manager::TestPasswordStore> password_store = |