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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 17341006: [Password Autofill] Don't fill fields with autocomplete="off". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/test/base/chrome_render_view_test.h" 7 #include "chrome/test/base/chrome_render_view_test.h"
8 #include "components/autofill/content/renderer/autofill_agent.h" 8 #include "components/autofill/content/renderer/autofill_agent.h"
9 #include "components/autofill/content/renderer/password_autofill_agent.h" 9 #include "components/autofill/content/renderer/password_autofill_agent.h"
10 #include "components/autofill/core/common/autofill_messages.h" 10 #include "components/autofill/core/common/autofill_messages.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 username_element_.setValue(WebString::fromUTF8("bogus")); 274 username_element_.setValue(WebString::fromUTF8("bogus"));
275 275
276 // Simulate the browser sending back the login info, it triggers the 276 // Simulate the browser sending back the login info, it triggers the
277 // autocomplete. 277 // autocomplete.
278 SimulateOnFillPasswordForm(fill_data_); 278 SimulateOnFillPasswordForm(fill_data_);
279 279
280 // Neither field should be autocompleted. 280 // Neither field should be autocompleted.
281 CheckTextFieldsState("bogus", false, std::string(), false); 281 CheckTextFieldsState("bogus", false, std::string(), false);
282 } 282 }
283 283
284 // Tests that changing the username does not fill a field specifying
285 // autocomplete="off".
286 TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForAutocompleteOff) {
287 password_element_.setAttribute(WebString::fromUTF8("autocomplete"),
288 WebString::fromUTF8("off"));
289
290 // Simulate the browser sending back the login info, it triggers the
291 // autocomplete.
292 SimulateOnFillPasswordForm(fill_data_);
293
294 // Only the username should have been autocompleted.
295 // TODO(jcivelli): may be we should not event fill the username?
296 CheckTextFieldsState(kAliceUsername, true, std::string(), false);
297 }
298
284 TEST_F(PasswordAutofillAgentTest, NoAutocompleteForTextFieldPasswords) { 299 TEST_F(PasswordAutofillAgentTest, NoAutocompleteForTextFieldPasswords) {
285 const char kTextFieldPasswordFormHTML[] = 300 const char kTextFieldPasswordFormHTML[] =
286 "<FORM name='LoginTestForm' action='http://www.bidule.com'>" 301 "<FORM name='LoginTestForm' action='http://www.bidule.com'>"
287 " <INPUT type='text' id='username'/>" 302 " <INPUT type='text' id='username'/>"
288 " <INPUT type='text' id='password'/>" 303 " <INPUT type='text' id='password'/>"
289 " <INPUT type='submit' value='Login'/>" 304 " <INPUT type='submit' value='Login'/>"
290 "</FORM>"; 305 "</FORM>";
291 LoadHTML(kTextFieldPasswordFormHTML); 306 LoadHTML(kTextFieldPasswordFormHTML);
292 307
293 // Retrieve the input elements so the test can access them. 308 // Retrieve the input elements so the test can access them.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // didSelectAutofillSuggestion on the renderer. 511 // didSelectAutofillSuggestion on the renderer.
497 autofill_agent_->didSelectAutofillSuggestion(username_element_, 512 autofill_agent_->didSelectAutofillSuggestion(username_element_,
498 ASCIIToUTF16(kAliceUsername), 513 ASCIIToUTF16(kAliceUsername),
499 WebKit::WebString(), 514 WebKit::WebString(),
500 0); 515 0);
501 // Autocomplete should not have kicked in. 516 // Autocomplete should not have kicked in.
502 CheckTextFieldsState(std::string(), false, std::string(), false); 517 CheckTextFieldsState(std::string(), false, std::string(), false);
503 } 518 }
504 519
505 } // namespace autofill 520 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698