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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/test/base/chrome_render_view_test.h" | 13 #include "chrome/test/base/chrome_render_view_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "components/autofill/content/common/autofill_messages.h" | 15 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" |
16 #include "components/autofill/content/renderer/autofill_agent.h" | 16 #include "components/autofill/content/renderer/autofill_agent.h" |
17 #include "components/autofill/core/common/form_data.h" | 17 #include "components/autofill/core/common/form_data.h" |
18 #include "components/autofill/core/common/form_field_data.h" | 18 #include "components/autofill/core/common/form_field_data.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
20 #include "content/public/renderer/render_frame.h" | 20 #include "content/public/renderer/render_frame.h" |
21 #include "content/public/renderer/render_view.h" | |
22 #include "mojo/public/cpp/bindings/binding_set.h" | |
23 #include "services/shell/public/cpp/interface_provider.h" | |
21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
23 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 26 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
24 #include "third_party/WebKit/public/platform/WebVector.h" | 27 #include "third_party/WebKit/public/platform/WebVector.h" |
25 #include "third_party/WebKit/public/web/WebDocument.h" | 28 #include "third_party/WebKit/public/web/WebDocument.h" |
26 #include "third_party/WebKit/public/web/WebFormElement.h" | 29 #include "third_party/WebKit/public/web/WebFormElement.h" |
27 #include "third_party/WebKit/public/web/WebInputElement.h" | 30 #include "third_party/WebKit/public/web/WebInputElement.h" |
28 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 31 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
29 #include "third_party/WebKit/public/web/WebView.h" | 32 #include "third_party/WebKit/public/web/WebView.h" |
30 | 33 |
31 using base::ASCIIToUTF16; | 34 using base::ASCIIToUTF16; |
32 using blink::WebDocument; | 35 using blink::WebDocument; |
33 using blink::WebElement; | 36 using blink::WebElement; |
34 using blink::WebFormElement; | 37 using blink::WebFormElement; |
35 using blink::WebFrame; | 38 using blink::WebFrame; |
36 using blink::WebLocalFrame; | 39 using blink::WebLocalFrame; |
37 using blink::WebInputElement; | 40 using blink::WebInputElement; |
38 using blink::WebString; | 41 using blink::WebString; |
39 using blink::WebURLRequest; | 42 using blink::WebURLRequest; |
40 using blink::WebVector; | 43 using blink::WebVector; |
41 | 44 |
42 namespace autofill { | 45 namespace autofill { |
43 | 46 |
47 namespace { | |
48 | |
49 class FakeContentAutofillDriver : public mojom::AutofillDriver { | |
50 public: | |
51 FakeContentAutofillDriver() : called_fieldchange_(false) {} | |
52 ~FakeContentAutofillDriver() override {} | |
53 | |
54 void BindRequest(mojom::AutofillDriverRequest request) { | |
55 bindings_.AddBinding(this, std::move(request)); | |
56 } | |
57 | |
58 // Records whether TextFieldDidChange() get called. | |
59 bool called_fieldchange_; | |
yzshen1
2016/06/29 22:25:44
nit: Please use setter/getter instead of making th
leonhsl(Using Gerrit)
2016/07/01 13:04:59
Done for all files in this CL.
| |
60 // Records data received via FormSeen() call. | |
61 std::unique_ptr<std::vector<FormData>> forms_; | |
62 | |
63 private: | |
64 // mojom::AutofillDriver: | |
65 void FirstUserGestureObserved() override {} | |
66 | |
67 void FormsSeen(mojo::Array<FormData> forms, | |
68 const base::TimeTicks& timestamp) override { | |
69 // FormsSeen() could be called multiple times and sometimes even with empty | |
70 // forms array for main frame, but we're interested in only the first time | |
71 // call. | |
72 if (!forms_) | |
73 forms_.reset(new std::vector<FormData>(forms.PassStorage())); | |
74 } | |
75 | |
76 void WillSubmitForm(const FormData& form, | |
77 const base::TimeTicks& timestamp) override {} | |
78 | |
79 void FormSubmitted(const FormData& form) override {} | |
80 | |
81 void TextFieldDidChange(const FormData& form, | |
82 const FormFieldData& field, | |
83 const base::TimeTicks& timestamp) override { | |
84 called_fieldchange_ = true; | |
85 } | |
86 | |
87 void QueryFormFieldAutofill(int32_t id, | |
88 const FormData& form, | |
89 const FormFieldData& field, | |
90 const gfx::RectF& bounding_box) override {} | |
91 | |
92 void HidePopup() override {} | |
93 | |
94 void PingAck() override {} | |
95 | |
96 void FocusNoLongerOnForm() override {} | |
97 | |
98 void DidFillAutofillFormData(const FormData& form, | |
99 const base::TimeTicks& timestamp) override {} | |
100 | |
101 void DidPreviewAutofillFormData() override {} | |
102 | |
103 void DidEndTextFieldEditing() override {} | |
104 | |
105 void SetDataList(mojo::Array<mojo::String> values, | |
106 mojo::Array<mojo::String> labels) override {} | |
107 | |
108 mojo::BindingSet<mojom::AutofillDriver> bindings_; | |
109 }; | |
110 | |
111 } // namespace | |
112 | |
44 using AutofillQueryParam = | 113 using AutofillQueryParam = |
45 std::tuple<int, autofill::FormData, autofill::FormFieldData, gfx::RectF>; | 114 std::tuple<int, autofill::FormData, autofill::FormFieldData, gfx::RectF>; |
46 | 115 |
47 class AutofillRendererTest : public ChromeRenderViewTest { | 116 class AutofillRendererTest : public ChromeRenderViewTest { |
48 public: | 117 public: |
49 AutofillRendererTest() {} | 118 AutofillRendererTest() {} |
119 | |
50 ~AutofillRendererTest() override {} | 120 ~AutofillRendererTest() override {} |
51 | 121 |
52 protected: | 122 protected: |
53 void SetUp() override { | 123 void SetUp() override { |
54 ChromeRenderViewTest::SetUp(); | 124 ChromeRenderViewTest::SetUp(); |
125 | |
126 // We only use the fake driver for main frame | |
127 // because our test cases only involve the main frame. | |
128 shell::InterfaceProvider* remote_interfaces = | |
129 view_->GetMainRenderFrame()->GetRemoteInterfaces(); | |
130 shell::InterfaceProvider::TestApi test_api(remote_interfaces); | |
131 test_api.SetBinderForName( | |
132 mojom::AutofillDriver::Name_, | |
133 base::Bind(&AutofillRendererTest::BindAutofillDriver, | |
134 base::Unretained(this))); | |
55 } | 135 } |
56 | 136 |
137 void BindAutofillDriver(mojo::ScopedMessagePipeHandle handle) { | |
138 fake_driver_.BindRequest( | |
139 mojo::MakeRequest<mojom::AutofillDriver>(std::move(handle))); | |
140 } | |
141 | |
142 FakeContentAutofillDriver fake_driver_; | |
143 | |
57 private: | 144 private: |
58 DISALLOW_COPY_AND_ASSIGN(AutofillRendererTest); | 145 DISALLOW_COPY_AND_ASSIGN(AutofillRendererTest); |
59 }; | 146 }; |
60 | 147 |
61 TEST_F(AutofillRendererTest, SendForms) { | 148 TEST_F(AutofillRendererTest, SendForms) { |
62 LoadHTML("<form method='POST'>" | 149 LoadHTML("<form method='POST'>" |
63 " <input type='text' id='firstname'/>" | 150 " <input type='text' id='firstname'/>" |
64 " <input type='text' id='middlename'/>" | 151 " <input type='text' id='middlename'/>" |
65 " <input type='text' id='lastname' autoComplete='off'/>" | 152 " <input type='text' id='lastname' autoComplete='off'/>" |
66 " <input type='hidden' id='email'/>" | 153 " <input type='hidden' id='email'/>" |
67 " <select id='state'/>" | 154 " <select id='state'/>" |
68 " <option>?</option>" | 155 " <option>?</option>" |
69 " <option>California</option>" | 156 " <option>California</option>" |
70 " <option>Texas</option>" | 157 " <option>Texas</option>" |
71 " </select>" | 158 " </select>" |
72 "</form>"); | 159 "</form>"); |
73 | 160 |
161 base::RunLoop run_loop; | |
162 run_loop.RunUntilIdle(); | |
yzshen1
2016/06/29 22:25:44
Please note that we don't guarantee that the messa
| |
74 // Verify that "FormsSeen" sends the expected number of fields. | 163 // Verify that "FormsSeen" sends the expected number of fields. |
75 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( | 164 ASSERT_TRUE(fake_driver_.forms_); |
76 AutofillHostMsg_FormsSeen::ID); | 165 std::vector<FormData> forms = *(fake_driver_.forms_.get()); |
77 ASSERT_NE(nullptr, message); | |
78 AutofillHostMsg_FormsSeen::Param params; | |
79 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | |
80 std::vector<FormData> forms = std::get<0>(params); | |
81 ASSERT_EQ(1UL, forms.size()); | 166 ASSERT_EQ(1UL, forms.size()); |
82 ASSERT_EQ(4UL, forms[0].fields.size()); | 167 ASSERT_EQ(4UL, forms[0].fields.size()); |
83 | 168 |
84 FormFieldData expected; | 169 FormFieldData expected; |
85 | 170 |
86 expected.name = ASCIIToUTF16("firstname"); | 171 expected.name = ASCIIToUTF16("firstname"); |
87 expected.value = base::string16(); | 172 expected.value = base::string16(); |
88 expected.form_control_type = "text"; | 173 expected.form_control_type = "text"; |
89 expected.max_length = WebInputElement::defaultMaxLength(); | 174 expected.max_length = WebInputElement::defaultMaxLength(); |
90 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); | 175 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); |
(...skipping 11 matching lines...) Expand all Loading... | |
102 expected.max_length = WebInputElement::defaultMaxLength(); | 187 expected.max_length = WebInputElement::defaultMaxLength(); |
103 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); | 188 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); |
104 expected.autocomplete_attribute = std::string(); // reset | 189 expected.autocomplete_attribute = std::string(); // reset |
105 | 190 |
106 expected.name = ASCIIToUTF16("state"); | 191 expected.name = ASCIIToUTF16("state"); |
107 expected.value = ASCIIToUTF16("?"); | 192 expected.value = ASCIIToUTF16("?"); |
108 expected.form_control_type = "select-one"; | 193 expected.form_control_type = "select-one"; |
109 expected.max_length = 0; | 194 expected.max_length = 0; |
110 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]); | 195 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]); |
111 | 196 |
112 render_thread_->sink().ClearMessages(); | 197 fake_driver_.forms_.reset(); |
113 | 198 |
114 // Dynamically create a new form. A new message should be sent for it, but | 199 // Dynamically create a new form. A new message should be sent for it, but |
115 // not for the previous form. | 200 // not for the previous form. |
116 ExecuteJavaScriptForTests( | 201 ExecuteJavaScriptForTests( |
117 "var newForm=document.createElement('form');" | 202 "var newForm=document.createElement('form');" |
118 "newForm.id='new_testform';" | 203 "newForm.id='new_testform';" |
119 "newForm.action='http://google.com';" | 204 "newForm.action='http://google.com';" |
120 "newForm.method='post';" | 205 "newForm.method='post';" |
121 "var newFirstname=document.createElement('input');" | 206 "var newFirstname=document.createElement('input');" |
122 "newFirstname.setAttribute('type', 'text');" | 207 "newFirstname.setAttribute('type', 'text');" |
123 "newFirstname.setAttribute('id', 'second_firstname');" | 208 "newFirstname.setAttribute('id', 'second_firstname');" |
124 "newFirstname.value = 'Bob';" | 209 "newFirstname.value = 'Bob';" |
125 "var newLastname=document.createElement('input');" | 210 "var newLastname=document.createElement('input');" |
126 "newLastname.setAttribute('type', 'text');" | 211 "newLastname.setAttribute('type', 'text');" |
127 "newLastname.setAttribute('id', 'second_lastname');" | 212 "newLastname.setAttribute('id', 'second_lastname');" |
128 "newLastname.value = 'Hope';" | 213 "newLastname.value = 'Hope';" |
129 "var newEmail=document.createElement('input');" | 214 "var newEmail=document.createElement('input');" |
130 "newEmail.setAttribute('type', 'text');" | 215 "newEmail.setAttribute('type', 'text');" |
131 "newEmail.setAttribute('id', 'second_email');" | 216 "newEmail.setAttribute('id', 'second_email');" |
132 "newEmail.value = 'bobhope@example.com';" | 217 "newEmail.value = 'bobhope@example.com';" |
133 "newForm.appendChild(newFirstname);" | 218 "newForm.appendChild(newFirstname);" |
134 "newForm.appendChild(newLastname);" | 219 "newForm.appendChild(newLastname);" |
135 "newForm.appendChild(newEmail);" | 220 "newForm.appendChild(newEmail);" |
136 "document.body.appendChild(newForm);"); | 221 "document.body.appendChild(newForm);"); |
137 base::RunLoop().RunUntilIdle(); | 222 base::RunLoop().RunUntilIdle(); |
138 | 223 |
139 message = render_thread_->sink().GetFirstMessageMatching( | 224 ASSERT_TRUE(fake_driver_.forms_); |
140 AutofillHostMsg_FormsSeen::ID); | 225 forms = *(fake_driver_.forms_.get()); |
141 ASSERT_NE(nullptr, message); | |
142 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | |
143 forms = std::get<0>(params); | |
144 ASSERT_EQ(1UL, forms.size()); | 226 ASSERT_EQ(1UL, forms.size()); |
145 ASSERT_EQ(3UL, forms[0].fields.size()); | 227 ASSERT_EQ(3UL, forms[0].fields.size()); |
146 | 228 |
147 expected.form_control_type = "text"; | 229 expected.form_control_type = "text"; |
148 expected.max_length = WebInputElement::defaultMaxLength(); | 230 expected.max_length = WebInputElement::defaultMaxLength(); |
149 | 231 |
150 expected.name = ASCIIToUTF16("second_firstname"); | 232 expected.name = ASCIIToUTF16("second_firstname"); |
151 expected.value = ASCIIToUTF16("Bob"); | 233 expected.value = ASCIIToUTF16("Bob"); |
152 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); | 234 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); |
153 | 235 |
154 expected.name = ASCIIToUTF16("second_lastname"); | 236 expected.name = ASCIIToUTF16("second_lastname"); |
155 expected.value = ASCIIToUTF16("Hope"); | 237 expected.value = ASCIIToUTF16("Hope"); |
156 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); | 238 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); |
157 | 239 |
158 expected.name = ASCIIToUTF16("second_email"); | 240 expected.name = ASCIIToUTF16("second_email"); |
159 expected.value = ASCIIToUTF16("bobhope@example.com"); | 241 expected.value = ASCIIToUTF16("bobhope@example.com"); |
160 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); | 242 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); |
161 } | 243 } |
162 | 244 |
163 TEST_F(AutofillRendererTest, EnsureNoFormSeenIfTooFewFields) { | 245 TEST_F(AutofillRendererTest, EnsureNoFormSeenIfTooFewFields) { |
164 LoadHTML("<form method='POST'>" | 246 LoadHTML("<form method='POST'>" |
165 " <input type='text' id='firstname'/>" | 247 " <input type='text' id='firstname'/>" |
166 " <input type='text' id='middlename'/>" | 248 " <input type='text' id='middlename'/>" |
167 "</form>"); | 249 "</form>"); |
168 | 250 |
251 base::RunLoop run_loop; | |
252 run_loop.RunUntilIdle(); | |
169 // Verify that "FormsSeen" isn't sent, as there are too few fields. | 253 // Verify that "FormsSeen" isn't sent, as there are too few fields. |
170 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( | 254 ASSERT_TRUE(fake_driver_.forms_); |
171 AutofillHostMsg_FormsSeen::ID); | 255 const std::vector<FormData>& forms = *(fake_driver_.forms_.get()); |
172 ASSERT_NE(nullptr, message); | |
173 AutofillHostMsg_FormsSeen::Param params; | |
174 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | |
175 const std::vector<FormData>& forms = std::get<0>(params); | |
176 ASSERT_EQ(0UL, forms.size()); | 256 ASSERT_EQ(0UL, forms.size()); |
177 } | 257 } |
178 | 258 |
179 // Regression test for [ http://crbug.com/346010 ]. | 259 // Regression test for [ http://crbug.com/346010 ]. |
180 TEST_F(AutofillRendererTest, DontCrashWhileAssociatingForms) { | 260 TEST_F(AutofillRendererTest, DontCrashWhileAssociatingForms) { |
181 LoadHTML("<form id='form'>" | 261 LoadHTML("<form id='form'>" |
182 "<foo id='foo'>" | 262 "<foo id='foo'>" |
183 "<script id='script'>" | 263 "<script id='script'>" |
184 "document.documentElement.appendChild(foo);" | 264 "document.documentElement.appendChild(foo);" |
185 "newDoc = document.implementation.createDocument(" | 265 "newDoc = document.implementation.createDocument(" |
186 " 'http://www.w3.org/1999/xhtml', 'html');" | 266 " 'http://www.w3.org/1999/xhtml', 'html');" |
187 "foo.insertBefore(form, script);" | 267 "foo.insertBefore(form, script);" |
188 "newDoc.adoptNode(foo);" | 268 "newDoc.adoptNode(foo);" |
189 "</script>"); | 269 "</script>"); |
190 | 270 |
191 // Shouldn't crash. | 271 // Shouldn't crash. |
192 } | 272 } |
193 | 273 |
194 TEST_F(AutofillRendererTest, DynamicallyAddedUnownedFormElements) { | 274 TEST_F(AutofillRendererTest, DynamicallyAddedUnownedFormElements) { |
195 std::string html_data; | 275 std::string html_data; |
196 base::FilePath test_path = ui_test_utils::GetTestFilePath( | 276 base::FilePath test_path = ui_test_utils::GetTestFilePath( |
197 base::FilePath(FILE_PATH_LITERAL("autofill")), | 277 base::FilePath(FILE_PATH_LITERAL("autofill")), |
198 base::FilePath(FILE_PATH_LITERAL("autofill_noform_dynamic.html"))); | 278 base::FilePath(FILE_PATH_LITERAL("autofill_noform_dynamic.html"))); |
199 ASSERT_TRUE(base::ReadFileToString(test_path, &html_data)); | 279 ASSERT_TRUE(base::ReadFileToString(test_path, &html_data)); |
200 LoadHTML(html_data.c_str()); | 280 LoadHTML(html_data.c_str()); |
201 | 281 |
282 base::RunLoop run_loop; | |
283 run_loop.RunUntilIdle(); | |
202 // Verify that "FormsSeen" sends the expected number of fields. | 284 // Verify that "FormsSeen" sends the expected number of fields. |
203 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( | 285 ASSERT_TRUE(fake_driver_.forms_); |
204 AutofillHostMsg_FormsSeen::ID); | 286 std::vector<FormData> forms = *(fake_driver_.forms_.get()); |
205 ASSERT_NE(nullptr, message); | |
206 AutofillHostMsg_FormsSeen::Param params; | |
207 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | |
208 std::vector<FormData> forms = std::get<0>(params); | |
209 ASSERT_EQ(1UL, forms.size()); | 287 ASSERT_EQ(1UL, forms.size()); |
210 ASSERT_EQ(7UL, forms[0].fields.size()); | 288 ASSERT_EQ(7UL, forms[0].fields.size()); |
211 | 289 |
212 render_thread_->sink().ClearMessages(); | 290 fake_driver_.forms_.reset(); |
213 | 291 |
214 ExecuteJavaScriptForTests("AddFields()"); | 292 ExecuteJavaScriptForTests("AddFields()"); |
215 base::RunLoop().RunUntilIdle(); | 293 base::RunLoop().RunUntilIdle(); |
216 | 294 |
217 message = render_thread_->sink().GetFirstMessageMatching( | 295 ASSERT_TRUE(fake_driver_.forms_); |
218 AutofillHostMsg_FormsSeen::ID); | 296 forms = *(fake_driver_.forms_.get()); |
219 ASSERT_NE(nullptr, message); | |
220 AutofillHostMsg_FormsSeen::Read(message, ¶ms); | |
221 forms = std::get<0>(params); | |
222 ASSERT_EQ(1UL, forms.size()); | 297 ASSERT_EQ(1UL, forms.size()); |
223 ASSERT_EQ(9UL, forms[0].fields.size()); | 298 ASSERT_EQ(9UL, forms[0].fields.size()); |
224 | 299 |
225 FormFieldData expected; | 300 FormFieldData expected; |
226 | 301 |
227 expected.name = ASCIIToUTF16("EMAIL_ADDRESS"); | 302 expected.name = ASCIIToUTF16("EMAIL_ADDRESS"); |
228 expected.value.clear(); | 303 expected.value.clear(); |
229 expected.form_control_type = "text"; | 304 expected.form_control_type = "text"; |
230 expected.max_length = WebInputElement::defaultMaxLength(); | 305 expected.max_length = WebInputElement::defaultMaxLength(); |
231 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[7]); | 306 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[7]); |
(...skipping 11 matching lines...) Expand all Loading... | |
243 "</form>"); | 318 "</form>"); |
244 | 319 |
245 blink::WebInputElement full_name = | 320 blink::WebInputElement full_name = |
246 GetMainFrame()->document().getElementById("full_name") | 321 GetMainFrame()->document().getElementById("full_name") |
247 .to<blink::WebInputElement>(); | 322 .to<blink::WebInputElement>(); |
248 while (!full_name.focused()) | 323 while (!full_name.focused()) |
249 GetMainFrame()->view()->advanceFocus(false); | 324 GetMainFrame()->view()->advanceFocus(false); |
250 | 325 |
251 // Not a user gesture, so no IPC message to browser. | 326 // Not a user gesture, so no IPC message to browser. |
252 DisableUserGestureSimulationForAutofill(); | 327 DisableUserGestureSimulationForAutofill(); |
328 ASSERT_FALSE(fake_driver_.called_fieldchange_); | |
253 full_name.setValue("Alice", true); | 329 full_name.setValue("Alice", true); |
254 GetMainFrame()->autofillClient()->textFieldDidChange(full_name); | 330 GetMainFrame()->autofillClient()->textFieldDidChange(full_name); |
255 base::RunLoop().RunUntilIdle(); | 331 base::RunLoop().RunUntilIdle(); |
256 ASSERT_EQ(nullptr, render_thread_->sink().GetFirstMessageMatching( | 332 ASSERT_FALSE(fake_driver_.called_fieldchange_); |
257 AutofillHostMsg_TextFieldDidChange::ID)); | |
258 | 333 |
259 // A user gesture will send a message to the browser. | 334 // A user gesture will send a message to the browser. |
260 EnableUserGestureSimulationForAutofill(); | 335 EnableUserGestureSimulationForAutofill(); |
261 SimulateUserInputChangeForElement(&full_name, "Alice"); | 336 SimulateUserInputChangeForElement(&full_name, "Alice"); |
262 ASSERT_NE(nullptr, render_thread_->sink().GetFirstMessageMatching( | 337 ASSERT_TRUE(fake_driver_.called_fieldchange_); |
263 AutofillHostMsg_TextFieldDidChange::ID)); | |
264 } | 338 } |
265 | 339 |
266 } // namespace autofill | 340 } // namespace autofill |
OLD | NEW |