| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // InProcessBrowserTest: | 274 // InProcessBrowserTest: |
| 275 void SetUpOnMainThread() override { | 275 void SetUpOnMainThread() override { |
| 276 // Use TestPasswordStore to remove a possible race. Normally the | 276 // Use TestPasswordStore to remove a possible race. Normally the |
| 277 // PasswordStore does its database manipulation on the DB thread, which | 277 // PasswordStore does its database manipulation on the DB thread, which |
| 278 // creates a possible race during navigation. Specifically the | 278 // creates a possible race during navigation. Specifically the |
| 279 // PasswordManager will ignore any forms in a page if the load from the | 279 // PasswordManager will ignore any forms in a page if the load from the |
| 280 // PasswordStore has not completed. | 280 // PasswordStore has not completed. |
| 281 PasswordStoreFactory::GetInstance()->SetTestingFactory( | 281 PasswordStoreFactory::GetInstance()->SetTestingFactory( |
| 282 browser()->profile(), TestPasswordStoreService::Build); | 282 browser()->profile(), TestPasswordStoreService::Build); |
| 283 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 283 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 284 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( | 284 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 285 password_manager::switches::kEnableAutomaticPasswordSaving)); | 285 password_manager::switches::kEnableAutomaticPasswordSaving)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void TearDownOnMainThread() override { | 288 void TearDownOnMainThread() override { |
| 289 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 289 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 protected: | 292 protected: |
| 293 content::WebContents* WebContents() { | 293 content::WebContents* WebContents() { |
| 294 return browser()->tab_strip_model()->GetActiveWebContents(); | 294 return browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 "window.parent.location.href = 'multi_frames.html';"; | 631 "window.parent.location.href = 'multi_frames.html';"; |
| 632 | 632 |
| 633 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 633 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 634 observer.Wait(); | 634 observer.Wait(); |
| 635 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 635 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 636 } | 636 } |
| 637 | 637 |
| 638 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, PromptForXHRSubmit) { | 638 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, PromptForXHRSubmit) { |
| 639 #if defined(OS_WIN) && defined(USE_ASH) | 639 #if defined(OS_WIN) && defined(USE_ASH) |
| 640 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 640 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 641 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 641 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 642 switches::kAshBrowserTests)) |
| 642 return; | 643 return; |
| 643 #endif | 644 #endif |
| 644 NavigateToFile("/password/password_xhr_submit.html"); | 645 NavigateToFile("/password/password_xhr_submit.html"); |
| 645 | 646 |
| 646 // Verify that we show the save password prompt if a form returns false | 647 // Verify that we show the save password prompt if a form returns false |
| 647 // in its onsubmit handler but instead logs in/navigates via XHR. | 648 // in its onsubmit handler but instead logs in/navigates via XHR. |
| 648 // Note that calling 'submit()' on a form with javascript doesn't call | 649 // Note that calling 'submit()' on a form with javascript doesn't call |
| 649 // the onsubmit handler, so we click the submit button instead. | 650 // the onsubmit handler, so we click the submit button instead. |
| 650 NavigationObserver observer(WebContents()); | 651 NavigationObserver observer(WebContents()); |
| 651 scoped_ptr<PromptObserver> prompt_observer( | 652 scoped_ptr<PromptObserver> prompt_observer( |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 password_manager::TestPasswordStore* password_store = | 1045 password_manager::TestPasswordStore* password_store = |
| 1045 static_cast<password_manager::TestPasswordStore*>( | 1046 static_cast<password_manager::TestPasswordStore*>( |
| 1046 PasswordStoreFactory::GetForProfile(browser()->profile(), | 1047 PasswordStoreFactory::GetForProfile(browser()->profile(), |
| 1047 Profile::IMPLICIT_ACCESS).get()); | 1048 Profile::IMPLICIT_ACCESS).get()); |
| 1048 | 1049 |
| 1049 EXPECT_TRUE(password_store->IsEmpty()); | 1050 EXPECT_TRUE(password_store->IsEmpty()); |
| 1050 | 1051 |
| 1051 NavigateToFile("/password/password_form.html"); | 1052 NavigateToFile("/password/password_form.html"); |
| 1052 | 1053 |
| 1053 // Add the enable-automatic-password-saving switch. | 1054 // Add the enable-automatic-password-saving switch. |
| 1054 CommandLine::ForCurrentProcess()->AppendSwitch( | 1055 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1055 password_manager::switches::kEnableAutomaticPasswordSaving); | 1056 password_manager::switches::kEnableAutomaticPasswordSaving); |
| 1056 | 1057 |
| 1057 // Fill a form and submit through a <input type="submit"> button. | 1058 // Fill a form and submit through a <input type="submit"> button. |
| 1058 NavigationObserver observer(WebContents()); | 1059 NavigationObserver observer(WebContents()); |
| 1059 scoped_ptr<PromptObserver> prompt_observer( | 1060 scoped_ptr<PromptObserver> prompt_observer( |
| 1060 PromptObserver::Create(WebContents())); | 1061 PromptObserver::Create(WebContents())); |
| 1061 // Make sure that the only passwords saved are the auto-saved ones. | 1062 // Make sure that the only passwords saved are the auto-saved ones. |
| 1062 std::string fill_and_submit = | 1063 std::string fill_and_submit = |
| 1063 "document.getElementById('username_field').value = 'temp';" | 1064 "document.getElementById('username_field').value = 'temp';" |
| 1064 "document.getElementById('password_field').value = 'random';" | 1065 "document.getElementById('password_field').value = 'random';" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 | 1218 |
| 1218 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1219 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
| 1219 observer.Wait(); | 1220 observer.Wait(); |
| 1220 | 1221 |
| 1221 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1222 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1222 } | 1223 } |
| 1223 | 1224 |
| 1224 IN_PROC_BROWSER_TEST_F( | 1225 IN_PROC_BROWSER_TEST_F( |
| 1225 PasswordManagerBrowserTest, | 1226 PasswordManagerBrowserTest, |
| 1226 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { | 1227 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { |
| 1227 CommandLine::ForCurrentProcess()->AppendSwitch( | 1228 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1228 switches::kAllowRunningInsecureContent); | 1229 switches::kAllowRunningInsecureContent); |
| 1229 CommandLine::ForCurrentProcess()->AppendSwitch( | 1230 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1230 switches::kIgnoreCertificateErrors); | 1231 switches::kIgnoreCertificateErrors); |
| 1231 const base::FilePath::CharType kDocRoot[] = | 1232 const base::FilePath::CharType kDocRoot[] = |
| 1232 FILE_PATH_LITERAL("chrome/test/data"); | 1233 FILE_PATH_LITERAL("chrome/test/data"); |
| 1233 net::SpawnedTestServer https_test_server( | 1234 net::SpawnedTestServer https_test_server( |
| 1234 net::SpawnedTestServer::TYPE_HTTPS, | 1235 net::SpawnedTestServer::TYPE_HTTPS, |
| 1235 net::SpawnedTestServer::SSLOptions( | 1236 net::SpawnedTestServer::SSLOptions( |
| 1236 net::SpawnedTestServer::SSLOptions::CERT_OK), | 1237 net::SpawnedTestServer::SSLOptions::CERT_OK), |
| 1237 base::FilePath(kDocRoot)); | 1238 base::FilePath(kDocRoot)); |
| 1238 ASSERT_TRUE(https_test_server.Start()); | 1239 ASSERT_TRUE(https_test_server.Start()); |
| 1239 | 1240 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 scoped_ptr<PromptObserver> prompt_observer( | 1386 scoped_ptr<PromptObserver> prompt_observer( |
| 1386 PromptObserver::Create(WebContents())); | 1387 PromptObserver::Create(WebContents())); |
| 1387 std::string fill_and_submit = | 1388 std::string fill_and_submit = |
| 1388 "document.getElementById('username_field').value = 'temp';" | 1389 "document.getElementById('username_field').value = 'temp';" |
| 1389 "document.getElementById('password_field').value = 'random';" | 1390 "document.getElementById('password_field').value = 'random';" |
| 1390 "document.getElementById('submit_button').click()"; | 1391 "document.getElementById('submit_button').click()"; |
| 1391 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1392 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1392 observer.Wait(); | 1393 observer.Wait(); |
| 1393 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1394 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1394 } | 1395 } |
| OLD | NEW |