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 "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/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
9 #include "components/autofill/content/renderer/autofill_agent.h" | 9 #include "components/autofill/content/renderer/autofill_agent.h" |
10 #include "components/autofill/content/renderer/form_autofill_util.h" | 10 #include "components/autofill/content/renderer/form_autofill_util.h" |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 SimulateInputChangeForElement("temp", true, GetMainFrame(), username_element_, | 1903 SimulateInputChangeForElement("temp", true, GetMainFrame(), username_element_, |
1904 true); | 1904 true); |
1905 SimulateInputChangeForElement("temp@google.com", true, GetMainFrame(), | 1905 SimulateInputChangeForElement("temp@google.com", true, GetMainFrame(), |
1906 email_element, true); | 1906 email_element, true); |
1907 SimulateInputChangeForElement("random", true, GetMainFrame(), | 1907 SimulateInputChangeForElement("random", true, GetMainFrame(), |
1908 password_element_, true); | 1908 password_element_, true); |
1909 | 1909 |
1910 // Find FormData for visible password form. | 1910 // Find FormData for visible password form. |
1911 blink::WebFormElement form_element = username_element_.form(); | 1911 blink::WebFormElement form_element = username_element_.form(); |
1912 FormData form_data; | 1912 FormData form_data; |
1913 ASSERT_TRUE(WebFormElementToFormData( | 1913 ASSERT_TRUE(WebFormElementToFormData(form_element, |
1914 form_element, blink::WebFormControlElement(), REQUIRE_NONE, EXTRACT_NONE, | 1914 blink::WebFormControlElement(), |
1915 &form_data, nullptr)); | 1915 EXTRACT_NONE, &form_data, nullptr)); |
1916 // Simulate Autofill predictions: the first field is username. | 1916 // Simulate Autofill predictions: the first field is username. |
1917 std::map<autofill::FormData, autofill::FormFieldData> predictions; | 1917 std::map<autofill::FormData, autofill::FormFieldData> predictions; |
1918 predictions[form_data] = form_data.fields[0]; | 1918 predictions[form_data] = form_data.fields[0]; |
1919 AutofillMsg_AutofillUsernameDataReceived msg(0, predictions); | 1919 AutofillMsg_AutofillUsernameDataReceived msg(0, predictions); |
1920 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) | 1920 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) |
1921 ->OnMessageReceived(msg); | 1921 ->OnMessageReceived(msg); |
1922 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) | 1922 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) |
1923 ->WillSendSubmitEvent(username_element_.form()); | 1923 ->WillSendSubmitEvent(username_element_.form()); |
1924 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) | 1924 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) |
1925 ->WillSubmitForm(username_element_.form()); | 1925 ->WillSubmitForm(username_element_.form()); |
1926 | 1926 |
1927 // Observe that the PasswordAutofillAgent identifies the first field as | 1927 // Observe that the PasswordAutofillAgent identifies the first field as |
1928 // username. | 1928 // username. |
1929 ExpectFormSubmittedWithUsernameAndPasswords("temp", "random", ""); | 1929 ExpectFormSubmittedWithUsernameAndPasswords("temp", "random", ""); |
1930 } | 1930 } |
1931 | 1931 |
1932 } // namespace autofill | 1932 } // namespace autofill |
OLD | NEW |