| 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 <tuple> | 5 #include <tuple> |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/renderer/autofill/password_generation_test_utils.h" | 11 #include "chrome/renderer/autofill/password_generation_test_utils.h" |
| 12 #include "chrome/test/base/chrome_render_view_test.h" | 12 #include "chrome/test/base/chrome_render_view_test.h" |
| 13 #include "components/autofill/content/common/autofill_messages.h" | 13 #include "components/autofill/content/common/autofill_messages.h" |
| 14 #include "components/autofill/content/renderer/autofill_agent.h" | 14 #include "components/autofill/content/renderer/autofill_agent.h" |
| 15 #include "components/autofill/content/renderer/form_autofill_util.h" | 15 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 16 #include "components/autofill/content/renderer/password_autofill_agent.h" | 16 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 17 #include "components/autofill/content/renderer/test_password_autofill_agent.h" | 17 #include "components/autofill/content/renderer/test_password_autofill_agent.h" |
| 18 #include "components/autofill/content/renderer/test_password_generation_agent.h" | 18 #include "components/autofill/content/renderer/test_password_generation_agent.h" |
| 19 #include "components/autofill/core/common/autofill_constants.h" | 19 #include "components/autofill/core/common/autofill_constants.h" |
| 20 #include "components/autofill/core/common/form_data.h" | 20 #include "components/autofill/core/common/form_data.h" |
| 21 #include "components/autofill/core/common/form_field_data.h" | 21 #include "components/autofill/core/common/form_field_data.h" |
| 22 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 22 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
| 23 #include "components/password_manager/core/common/password_manager_features.h" | 23 #include "components/password_manager/core/common/password_manager_features.h" |
| 24 #include "content/public/renderer/render_frame.h" | 24 #include "content/public/renderer/render_frame.h" |
| 25 #include "mojo/common/common_type_converters.h" | |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "third_party/WebKit/public/platform/WebString.h" | 26 #include "third_party/WebKit/public/platform/WebString.h" |
| 28 #include "third_party/WebKit/public/platform/WebVector.h" | 27 #include "third_party/WebKit/public/platform/WebVector.h" |
| 29 #include "third_party/WebKit/public/web/WebDocument.h" | 28 #include "third_party/WebKit/public/web/WebDocument.h" |
| 30 #include "third_party/WebKit/public/web/WebElement.h" | 29 #include "third_party/WebKit/public/web/WebElement.h" |
| 31 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 30 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 32 #include "third_party/WebKit/public/web/WebFormElement.h" | 31 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 33 #include "third_party/WebKit/public/web/WebInputElement.h" | 32 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 34 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 33 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 35 #include "third_party/WebKit/public/web/WebNode.h" | 34 #include "third_party/WebKit/public/web/WebNode.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 void SimulateSuggestionChoiceOfUsernameAndPassword( | 377 void SimulateSuggestionChoiceOfUsernameAndPassword( |
| 379 WebInputElement& input, | 378 WebInputElement& input, |
| 380 const base::string16& username, | 379 const base::string16& username, |
| 381 const base::string16& password) { | 380 const base::string16& password) { |
| 382 // This call is necessary to setup the autofill agent appropriate for the | 381 // This call is necessary to setup the autofill agent appropriate for the |
| 383 // user selection; simulates the menu actually popping up. | 382 // user selection; simulates the menu actually popping up. |
| 384 render_thread_->sink().ClearMessages(); | 383 render_thread_->sink().ClearMessages(); |
| 385 static_cast<autofill::PageClickListener*>(autofill_agent_) | 384 static_cast<autofill::PageClickListener*>(autofill_agent_) |
| 386 ->FormControlElementClicked(input, false); | 385 ->FormControlElementClicked(input, false); |
| 387 | 386 |
| 388 autofill_agent_->FillPasswordSuggestion(mojo::String::From(username), | 387 autofill_agent_->FillPasswordSuggestion(username, password); |
| 389 mojo::String::From(password)); | |
| 390 } | 388 } |
| 391 | 389 |
| 392 void SimulateUsernameChange(const std::string& username) { | 390 void SimulateUsernameChange(const std::string& username) { |
| 393 SimulateUserInputChangeForElement(&username_element_, username); | 391 SimulateUserInputChangeForElement(&username_element_, username); |
| 394 } | 392 } |
| 395 | 393 |
| 396 void SimulatePasswordChange(const std::string& password) { | 394 void SimulatePasswordChange(const std::string& password) { |
| 397 SimulateUserInputChangeForElement(&password_element_, password); | 395 SimulateUserInputChangeForElement(&password_element_, password); |
| 398 } | 396 } |
| 399 | 397 |
| (...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 2369 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 2372 AutofillHostMsg_ShowPasswordSuggestions::ID)); | 2370 AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| 2373 | 2371 |
| 2374 // But when the user clicks on the autofilled password field again it should | 2372 // But when the user clicks on the autofilled password field again it should |
| 2375 // still produce a suggestion dropdown. | 2373 // still produce a suggestion dropdown. |
| 2376 SimulateElementClick("password"); | 2374 SimulateElementClick("password"); |
| 2377 CheckSuggestions("", false); | 2375 CheckSuggestions("", false); |
| 2378 } | 2376 } |
| 2379 | 2377 |
| 2380 } // namespace autofill | 2378 } // namespace autofill |
| OLD | NEW |