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

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

Issue 1968443002: Kill the autofill password manager in case 'store()' was called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/password_manager/password_manager_test_base.h" 7 #include "chrome/browser/password_manager/password_manager_test_base.h"
8 #include "chrome/browser/password_manager/password_store_factory.h" 8 #include "chrome/browser/password_manager/password_store_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 prompt_observer->Dismiss(); 140 prompt_observer->Dismiss();
141 141
142 NavigationObserver form_submit_observer(WebContents()); 142 NavigationObserver form_submit_observer(WebContents());
143 ASSERT_TRUE(content::ExecuteScript( 143 ASSERT_TRUE(content::ExecuteScript(
144 RenderViewHost(), 144 RenderViewHost(),
145 "document.getElementById('input_submit_button').click();")); 145 "document.getElementById('input_submit_button').click();"));
146 form_submit_observer.Wait(); 146 form_submit_observer.Wait();
147 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 147 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
148 } 148 }
149 149
150 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, UpdateViaAPIAndAutofill) {
151 // Save credentials with 'skip_zero_click' false.
152 scoped_refptr<password_manager::TestPasswordStore> password_store =
153 static_cast<password_manager::TestPasswordStore*>(
154 PasswordStoreFactory::GetForProfile(
155 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
156 .get());
157 autofill::PasswordForm signin_form;
158 signin_form.signon_realm = embedded_test_server()->base_url().spec();
159 signin_form.password_value = base::ASCIIToUTF16("12345");
160 signin_form.username_value = base::ASCIIToUTF16("user");
161 signin_form.origin = embedded_test_server()->base_url();
162 signin_form.skip_zero_click = true;
163 signin_form.preferred = true;
164 password_store->AddLogin(signin_form);
165
166 NavigateToFile("/password/password_form.html");
167 std::string fill_password =
168 "document.getElementById('username_field').value = 'user';"
169 "document.getElementById('password_field').value = '12345';";
170 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password));
171
172 // Call the API to update the form.
173 ASSERT_TRUE(content::ExecuteScript(
174 RenderViewHost(),
175 "var c = new PasswordCredential({ id: 'user', password: '12345' });"
176 "navigator.credentials.store(c);"));
177 std::unique_ptr<PromptObserver> prompt_observer(
178 PromptObserver::Create(WebContents()));
179 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
180 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
181 signin_form.skip_zero_click = false;
182 signin_form.times_used = 1;
183 password_manager::TestPasswordStore::PasswordMap stored =
184 password_store->stored_passwords();
185 ASSERT_EQ(1u, stored.size());
186 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]);
187
188 // Verify that the autofill password manager was suppressed and didn't touch
189 // the store. It would definitely update the '*_element' fields.
190 NavigationObserver form_submit_observer(WebContents());
191 ASSERT_TRUE(content::ExecuteScript(
192 RenderViewHost(),
193 "document.getElementById('input_submit_button').click();"));
194 form_submit_observer.Wait();
195 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
196 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
197 stored = password_store->stored_passwords();
198 ASSERT_EQ(1u, stored.size());
199 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]);
200 }
201
150 } // namespace 202 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698