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" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 16 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
17 #include "chrome/browser/password_manager/password_manager_test_base.h" | 17 #include "chrome/browser/password_manager/password_manager_test_base.h" |
18 #include "chrome/browser/password_manager/password_store_factory.h" | 18 #include "chrome/browser/password_manager/password_store_factory.h" |
19 #include "chrome/browser/password_manager/test_password_store_service.h" | 19 #include "chrome/browser/password_manager/test_password_store_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/login/login_prompt.h" | 22 #include "chrome/browser/ui/login/login_prompt.h" |
23 #include "chrome/browser/ui/login/login_prompt_test_utils.h" | 23 #include "chrome/browser/ui/login/login_prompt_test_utils.h" |
24 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
28 #include "chrome/test/base/test_switches.h" | 29 #include "chrome/test/base/test_switches.h" |
29 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
30 #include "components/autofill/content/common/autofill_messages.h" | 31 #include "components/autofill/content/common/autofill_messages.h" |
31 #include "components/autofill/core/browser/autofill_test_utils.h" | 32 #include "components/autofill/core/browser/autofill_test_utils.h" |
32 #include "components/autofill/core/browser/test_autofill_client.h" | 33 #include "components/autofill/core/browser/test_autofill_client.h" |
33 #include "components/autofill/core/common/password_form.h" | 34 #include "components/autofill/core/common/password_form.h" |
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 content::RenderProcessHostWatcher iframe_killed( | 2014 content::RenderProcessHostWatcher iframe_killed( |
2014 iframe->GetProcess(), | 2015 iframe->GetProcess(), |
2015 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 2016 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
2016 | 2017 |
2017 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 2018 IPC::IpcSecurityTestUtil::PwnMessageReceived( |
2018 iframe->GetProcess()->GetChannel(), illegal_forms_parsed); | 2019 iframe->GetProcess()->GetChannel(), illegal_forms_parsed); |
2019 | 2020 |
2020 iframe_killed.Wait(); | 2021 iframe_killed.Wait(); |
2021 } | 2022 } |
2022 | 2023 |
2024 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
2025 ChangePwdNoAccountStored) { | |
2026 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); | |
2027 NavigateToFile("/password/password_form.html"); | |
2028 | |
2029 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
2030 password_manager::switches::kEnablePasswordChangeSupport); | |
2031 | |
2032 // Fill a form and submit through a <input type="submit"> button. | |
2033 NavigationObserver observer(WebContents()); | |
2034 scoped_ptr<PromptObserver> prompt_observer( | |
2035 PromptObserver::Create(WebContents())); | |
2036 ManagePasswordsUIController* ui_controller = | |
2037 ManagePasswordsUIController::FromWebContents(WebContents()); | |
2038 | |
2039 std::string fill_and_submit = | |
2040 "document.getElementById('chg_password_wo_username_field').value = " | |
2041 "'old_pw';" | |
2042 "document.getElementById('chg_new_password_wo_username_1').value = " | |
2043 "'new_pw';" | |
2044 "document.getElementById('chg_new_password_wo_username_2').value = " | |
2045 "'new_pw';" | |
2046 "document.getElementById('chg_submit_wo_username_button').click()"; | |
2047 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | |
2048 observer.Wait(); | |
2049 // No credentials stored, so save bubble is shown. | |
2050 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, | |
2051 ui_controller->state()); | |
vasilii
2015/07/31 14:38:53
Shouldn't the test work with the infobar as well?
dvadym
2015/08/03 15:44:08
I think it should be test only for testing change
| |
2052 } | |
2053 | |
2054 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
2055 ChangePwd1AccountStored) { | |
2056 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); | |
vasilii
2015/07/31 14:38:53
How is this enforced on Mac?
dvadym
2015/08/03 15:44:08
I'm in progress of figuring out how it should work
| |
2057 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
2058 password_manager::switches::kEnablePasswordChangeSupport); | |
2059 // At first let us save credentials to the PasswordManager. | |
2060 NavigateToFile("/password/password_form.html"); | |
2061 NavigationObserver observer1(WebContents()); | |
2062 scoped_ptr<PromptObserver> prompt_observer( | |
2063 PromptObserver::Create(WebContents())); | |
2064 ManagePasswordsUIController* ui_controller = | |
2065 ManagePasswordsUIController::FromWebContents(WebContents()); | |
2066 std::string fill_and_submit_signin = | |
2067 "document.getElementById('username_field').value = 'temp';" | |
2068 "document.getElementById('password_field').value = 'random';" | |
2069 "document.getElementById('input_submit_button').click()"; | |
2070 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit_signin)); | |
2071 observer1.Wait(); | |
2072 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, | |
2073 ui_controller->state()); | |
2074 prompt_observer->Accept(); | |
2075 // Check that credentials are stored. | |
2076 password_manager::TestPasswordStore* password_store = | |
2077 static_cast<password_manager::TestPasswordStore*>( | |
2078 PasswordStoreFactory::GetForProfile( | |
2079 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
2080 .get()); | |
vasilii
2015/07/31 14:38:53
What about pushing the password to the store direc
dvadym
2015/08/03 15:44:08
Done
| |
2081 // Spin the message loop to make sure the password store had a chance to save | |
2082 // the password. | |
2083 base::RunLoop run_loop; | |
2084 run_loop.RunUntilIdle(); | |
2085 EXPECT_FALSE(password_store->IsEmpty()); | |
2086 | |
2087 // Check that password update bubble is shown. | |
2088 NavigateToFile("/password/password_form.html"); | |
2089 NavigationObserver observer2(WebContents()); | |
2090 std::string fill_and_submit_change_password = | |
2091 "document.getElementById('chg_password_wo_username_field').value = " | |
2092 "'random';" | |
2093 "document.getElementById('chg_new_password_wo_username_1').value = " | |
2094 "'new_pw';" | |
2095 "document.getElementById('chg_new_password_wo_username_2').value = " | |
2096 "'new_pw';" | |
2097 "document.getElementById('chg_submit_wo_username_button').click()"; | |
2098 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | |
2099 fill_and_submit_change_password)); | |
2100 observer2.Wait(); | |
2101 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, | |
2102 ui_controller->state()); | |
2103 } | |
2104 | |
2023 } // namespace password_manager | 2105 } // namespace password_manager |
2024 | 2106 |
OLD | NEW |