Chromium Code Reviews| 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 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2119 prompt_observer->AcceptUpdatePrompt(stored_form); | 2119 prompt_observer->AcceptUpdatePrompt(stored_form); |
| 2120 // Spin the message loop to make sure the password store had a chance to | 2120 // Spin the message loop to make sure the password store had a chance to |
| 2121 // update the password. | 2121 // update the password. |
| 2122 base::RunLoop run_loop; | 2122 base::RunLoop run_loop; |
| 2123 run_loop.RunUntilIdle(); | 2123 run_loop.RunUntilIdle(); |
| 2124 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2124 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
| 2125 base::ASCIIToUTF16("new_pw")); | 2125 base::ASCIIToUTF16("new_pw")); |
| 2126 } | 2126 } |
| 2127 #endif | 2127 #endif |
| 2128 | 2128 |
| 2129 // TODO(dvadym): Turn on this test when Change password UI will be implemented | |
| 2130 // for Mac. http://crbug.com/359315 | |
| 2131 #ifndef OS_MACOSX | |
|
vasilii
2015/08/18 10:01:44
#if !defined(OS_MACOSX)
dvadym
2015/08/18 11:55:33
Done.
| |
| 2132 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
| 2133 PasswordOverridenUpdateBubbleShown) { | |
| 2134 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); | |
| 2135 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 2136 password_manager::switches::kEnablePasswordChangeSupport); | |
| 2137 // At first let us save credentials to the PasswordManager. | |
| 2138 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
| 2139 static_cast<password_manager::TestPasswordStore*>( | |
| 2140 PasswordStoreFactory::GetForProfile( | |
| 2141 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
| 2142 .get()); | |
| 2143 autofill::PasswordForm signin_form; | |
| 2144 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | |
| 2145 signin_form.username_value = base::ASCIIToUTF16("temp"); | |
| 2146 signin_form.password_value = base::ASCIIToUTF16("pw"); | |
| 2147 password_store->AddLogin(signin_form); | |
| 2148 | |
| 2149 // Check that password update bubble is shown. | |
| 2150 NavigateToFile("/password/password_form.html"); | |
| 2151 NavigationObserver observer(WebContents()); | |
| 2152 scoped_ptr<PromptObserver> prompt_observer( | |
| 2153 PromptObserver::Create(WebContents())); | |
| 2154 std::string fill_and_submit = | |
| 2155 "document.getElementById('username_field').value = 'temp';" | |
| 2156 "document.getElementById('password_field').value = 'new_pw';" | |
| 2157 "document.getElementById('input_submit_button').click()"; | |
| 2158 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | |
| 2159 observer.Wait(); | |
| 2160 // The stored password "pw" was overriden with "new_pw", so update prompt is | |
| 2161 // expected. | |
| 2162 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | |
| 2163 | |
| 2164 const autofill::PasswordForm& stored_form = | |
|
vasilii
2015/08/18 10:01:44
Create a copy of the form.
dvadym
2015/08/18 11:55:33
Done.
| |
| 2165 password_store->stored_passwords().begin()->second[0]; | |
| 2166 prompt_observer->AcceptUpdatePrompt(stored_form); | |
| 2167 // Spin the message loop to make sure the password store had a chance to | |
| 2168 // update the password. | |
| 2169 base::RunLoop run_loop; | |
| 2170 run_loop.RunUntilIdle(); | |
| 2171 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | |
| 2172 base::ASCIIToUTF16("new_pw")); | |
| 2173 } | |
| 2174 #endif | |
| 2175 | |
| 2176 // TODO(dvadym): Turn on this test when Change password UI will be implemented | |
| 2177 // for Mac. http://crbug.com/359315 | |
| 2178 #ifndef OS_MACOSX | |
|
vasilii
2015/08/18 10:01:44
#if !defined(OS_MACOSX)
dvadym
2015/08/18 11:55:33
Done.
| |
| 2179 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | |
| 2180 PasswordNotOverridenUpdateBubbleNotShown) { | |
| 2181 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); | |
| 2182 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 2183 password_manager::switches::kEnablePasswordChangeSupport); | |
| 2184 // At first let us save credentials to the PasswordManager. | |
| 2185 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
| 2186 static_cast<password_manager::TestPasswordStore*>( | |
| 2187 PasswordStoreFactory::GetForProfile( | |
| 2188 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
| 2189 .get()); | |
| 2190 autofill::PasswordForm signin_form; | |
| 2191 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | |
| 2192 signin_form.username_value = base::ASCIIToUTF16("temp"); | |
| 2193 signin_form.password_value = base::ASCIIToUTF16("pw"); | |
| 2194 password_store->AddLogin(signin_form); | |
| 2195 | |
| 2196 // Check that password update bubble is shown. | |
| 2197 NavigateToFile("/password/password_form.html"); | |
| 2198 NavigationObserver observer(WebContents()); | |
| 2199 scoped_ptr<PromptObserver> prompt_observer( | |
| 2200 PromptObserver::Create(WebContents())); | |
| 2201 std::string fill_and_submit = | |
| 2202 "document.getElementById('username_field').value = 'temp';" | |
| 2203 "document.getElementById('password_field').value = 'pw';" | |
| 2204 "document.getElementById('input_submit_button').click()"; | |
| 2205 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | |
| 2206 observer.Wait(); | |
| 2207 // The stored password "pw" was not overriden, so update prompt is not | |
| 2208 // expected. | |
| 2209 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); | |
| 2210 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | |
| 2211 base::ASCIIToUTF16("pw")); | |
| 2212 } | |
| 2213 #endif | |
| 2214 | |
| 2129 } // namespace password_manager | 2215 } // namespace password_manager |
| OLD | NEW |