| OLD | NEW |
| 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 "components/autofill/content/renderer/password_autofill_agent.h" | 5 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 expect_signature_for_field); | 2509 expect_signature_for_field); |
| 2510 if (expect_signature_for_field) { | 2510 if (expect_signature_for_field) { |
| 2511 EXPECT_EQ(field_element.getAttribute(field_signature_attribute), | 2511 EXPECT_EQ(field_element.getAttribute(field_signature_attribute), |
| 2512 blink::WebString::fromUTF8(base::Uint64ToString( | 2512 blink::WebString::fromUTF8(base::Uint64ToString( |
| 2513 CalculateFieldSignatureForField(form_data.fields[i])))); | 2513 CalculateFieldSignatureForField(form_data.fields[i])))); |
| 2514 } | 2514 } |
| 2515 } | 2515 } |
| 2516 } | 2516 } |
| 2517 } | 2517 } |
| 2518 | 2518 |
| 2519 // Tests that a suggestion dropdown is shown even if JavaScripts updated field |
| 2520 // names. |
| 2521 TEST_F(PasswordAutofillAgentTest, SuggestWhenJavaScriptUpdatesFieldNames) { |
| 2522 // Simulate that JavaScript updated field names. |
| 2523 auto fill_data = fill_data_; |
| 2524 fill_data.username_field.name += ASCIIToUTF16("1"); |
| 2525 fill_data.password_field.name += ASCIIToUTF16("1"); |
| 2526 // Simulate the browser sending back the login info. |
| 2527 SimulateOnFillPasswordForm(fill_data); |
| 2528 |
| 2529 // Call SimulateElementClick() to produce a user gesture on the page so |
| 2530 // autofill will actually fill. |
| 2531 SimulateElementClick(kUsernameName); |
| 2532 |
| 2533 // Simulate a user clicking on the password element. This should produce a |
| 2534 // dropdown with suggestion of all available usernames. |
| 2535 static_cast<PageClickListener*>(autofill_agent_) |
| 2536 ->FormControlElementClicked(password_element_, false); |
| 2537 CheckSuggestions("", false); |
| 2538 } |
| 2539 |
| 2519 } // namespace autofill | 2540 } // namespace autofill |
| OLD | NEW |