Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 1297963002: Implemented showing update bubble pop-up on password overriding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments were addressed Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/manage_passwords_bubble_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 // the password. 2071 // the password.
2072 base::RunLoop run_loop; 2072 base::RunLoop run_loop;
2073 run_loop.RunUntilIdle(); 2073 run_loop.RunUntilIdle();
2074 EXPECT_FALSE(password_store->IsEmpty()); 2074 EXPECT_FALSE(password_store->IsEmpty());
2075 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""), 2075 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""),
2076 base::ASCIIToUTF16("new_pw")); 2076 base::ASCIIToUTF16("new_pw"));
2077 } 2077 }
2078 2078
2079 // TODO(dvadym): Turn on this test when Change password UI will be implemented 2079 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2080 // for Mac. http://crbug.com/359315 2080 // for Mac. http://crbug.com/359315
2081 #ifndef OS_MACOSX 2081 #if !defined(OS_MACOSX)
2082 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2082 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2083 ChangePwd1AccountStored) { 2083 ChangePwd1AccountStored) {
2084 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2084 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2085 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2085 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2086 password_manager::switches::kEnablePasswordChangeSupport); 2086 password_manager::switches::kEnablePasswordChangeSupport);
2087 // At first let us save credentials to the PasswordManager. 2087 // At first let us save credentials to the PasswordManager.
2088 scoped_refptr<password_manager::TestPasswordStore> password_store = 2088 scoped_refptr<password_manager::TestPasswordStore> password_store =
2089 static_cast<password_manager::TestPasswordStore*>( 2089 static_cast<password_manager::TestPasswordStore*>(
2090 PasswordStoreFactory::GetForProfile( 2090 PasswordStoreFactory::GetForProfile(
2091 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2091 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
(...skipping 15 matching lines...) Expand all
2107 "document.getElementById('chg_new_password_wo_username_1').value = " 2107 "document.getElementById('chg_new_password_wo_username_1').value = "
2108 "'new_pw';" 2108 "'new_pw';"
2109 "document.getElementById('chg_new_password_wo_username_2').value = " 2109 "document.getElementById('chg_new_password_wo_username_2').value = "
2110 "'new_pw';" 2110 "'new_pw';"
2111 "document.getElementById('chg_submit_wo_username_button').click()"; 2111 "document.getElementById('chg_submit_wo_username_button').click()";
2112 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), 2112 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
2113 fill_and_submit_change_password)); 2113 fill_and_submit_change_password));
2114 observer.Wait(); 2114 observer.Wait();
2115 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); 2115 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt());
2116 2116
2117 const autofill::PasswordForm& stored_form = 2117 const autofill::PasswordForm stored_form =
2118 password_store->stored_passwords().begin()->second[0]; 2118 password_store->stored_passwords().begin()->second[0];
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 #if !defined(OS_MACOSX)
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 =
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 #if !defined(OS_MACOSX)
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/manage_passwords_bubble_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698