OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "chrome/test/base/chrome_render_view_test.h" | 10 #include "chrome/test/base/chrome_render_view_test.h" |
11 #include "components/autofill/content/common/autofill_messages.h" | 11 #include "components/autofill/content/common/autofill_messages.h" |
12 #include "components/autofill/content/renderer/autofill_agent.h" | 12 #include "components/autofill/content/renderer/autofill_agent.h" |
| 13 #include "components/autofill/content/renderer/form_autofill_util.h" |
13 #include "components/autofill/content/renderer/test_password_generation_agent.h" | 14 #include "components/autofill/content/renderer/test_password_generation_agent.h" |
14 #include "components/autofill/core/common/form_data.h" | 15 #include "components/autofill/core/common/form_data.h" |
15 #include "components/autofill/core/common/password_generation_util.h" | 16 #include "components/autofill/core/common/password_generation_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/web/WebDocument.h" | 19 #include "third_party/WebKit/public/web/WebDocument.h" |
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
20 #include "third_party/WebKit/public/web/WebWidget.h" | 21 #include "third_party/WebKit/public/web/WebWidget.h" |
21 | 22 |
22 using blink::WebDocument; | 23 using blink::WebDocument; |
(...skipping 14 matching lines...) Expand all Loading... |
37 } | 38 } |
38 | 39 |
39 void SetNotBlacklistedMessage(const char* form_str) { | 40 void SetNotBlacklistedMessage(const char* form_str) { |
40 autofill::PasswordForm form; | 41 autofill::PasswordForm form; |
41 form.origin = | 42 form.origin = |
42 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str)); | 43 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str)); |
43 AutofillMsg_FormNotBlacklisted msg(0, form); | 44 AutofillMsg_FormNotBlacklisted msg(0, form); |
44 password_generation_->OnMessageReceived(msg); | 45 password_generation_->OnMessageReceived(msg); |
45 } | 46 } |
46 | 47 |
47 void SetAccountCreationFormsDetectedMessage(const char* form_str) { | 48 // Sends a message that the |form_index| form on the page is valid for |
48 autofill::FormData form; | 49 // account creation. |
49 form.origin = | 50 void SetAccountCreationFormsDetectedMessage(int form_index) { |
50 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str)); | 51 WebDocument document = GetMainFrame()->document(); |
| 52 blink::WebVector<blink::WebFormElement> web_forms; |
| 53 document.forms(web_forms); |
| 54 |
| 55 autofill::FormData form_data; |
| 56 WebFormElementToFormData(web_forms[form_index], |
| 57 blink::WebFormControlElement(), |
| 58 REQUIRE_NONE, |
| 59 EXTRACT_NONE, |
| 60 &form_data, |
| 61 NULL /* FormFieldData */); |
| 62 |
51 std::vector<autofill::FormData> forms; | 63 std::vector<autofill::FormData> forms; |
52 forms.push_back(form); | 64 forms.push_back(form_data); |
53 AutofillMsg_AccountCreationFormsDetected msg(0, forms); | 65 AutofillMsg_AccountCreationFormsDetected msg(0, forms); |
54 password_generation_->OnMessageReceived(msg); | 66 password_generation_->OnMessageReceived(msg); |
55 } | 67 } |
56 | 68 |
57 void ExpectPasswordGenerationAvailable(const char* element_id, | 69 void ExpectPasswordGenerationAvailable(const char* element_id, |
58 bool available) { | 70 bool available) { |
59 WebDocument document = GetMainFrame()->document(); | 71 WebDocument document = GetMainFrame()->document(); |
60 WebElement element = | 72 WebElement element = |
61 document.getElementById(WebString::fromUTF8(element_id)); | 73 document.getElementById(WebString::fromUTF8(element_id)); |
62 ASSERT_FALSE(element.isNull()); | 74 ASSERT_FALSE(element.isNull()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 "</FORM>"; | 115 "</FORM>"; |
104 | 116 |
105 const char kInvalidActionAccountCreationFormHTML[] = | 117 const char kInvalidActionAccountCreationFormHTML[] = |
106 "<FORM name = 'blah' action = 'invalid'> " | 118 "<FORM name = 'blah' action = 'invalid'> " |
107 " <INPUT type = 'text' id = 'username'/> " | 119 " <INPUT type = 'text' id = 'username'/> " |
108 " <INPUT type = 'password' id = 'first_password'/> " | 120 " <INPUT type = 'password' id = 'first_password'/> " |
109 " <INPUT type = 'password' id = 'second_password'/> " | 121 " <INPUT type = 'password' id = 'second_password'/> " |
110 " <INPUT type = 'submit' value = 'LOGIN' />" | 122 " <INPUT type = 'submit' value = 'LOGIN' />" |
111 "</FORM>"; | 123 "</FORM>"; |
112 | 124 |
| 125 const char kMultipleAccountCreationFormHTML[] = |
| 126 "<FORM name = 'login' action = 'http://www.random.com/'> " |
| 127 " <INPUT type = 'text' id = 'random'/> " |
| 128 " <INPUT type = 'text' id = 'username'/> " |
| 129 " <INPUT type = 'password' id = 'password'/> " |
| 130 " <INPUT type = 'submit' value = 'LOGIN' />" |
| 131 "</FORM>" |
| 132 "<FORM name = 'signup' action = 'http://www.random.com/signup'> " |
| 133 " <INPUT type = 'text' id = 'username'/> " |
| 134 " <INPUT type = 'password' id = 'first_password' " |
| 135 " autocomplete = 'off' size = 5/>" |
| 136 " <INPUT type = 'password' id = 'second_password' size = 5/> " |
| 137 " <INPUT type = 'text' id = 'address'/> " |
| 138 " <INPUT type = 'submit' value = 'LOGIN' />" |
| 139 "</FORM>"; |
| 140 |
113 const char ChangeDetectionScript[] = | 141 const char ChangeDetectionScript[] = |
114 "<script>" | 142 "<script>" |
115 " firstOnChangeCalled = false;" | 143 " firstOnChangeCalled = false;" |
116 " secondOnChangeCalled = false;" | 144 " secondOnChangeCalled = false;" |
117 " document.getElementById('first_password').onchange = function() {" | 145 " document.getElementById('first_password').onchange = function() {" |
118 " firstOnChangeCalled = true;" | 146 " firstOnChangeCalled = true;" |
119 " };" | 147 " };" |
120 " document.getElementById('second_password').onchange = function() {" | 148 " document.getElementById('second_password').onchange = function() {" |
121 " secondOnChangeCalled = true;" | 149 " secondOnChangeCalled = true;" |
122 " };" | 150 " };" |
123 "</script>"; | 151 "</script>"; |
124 | 152 |
125 TEST_F(PasswordGenerationAgentTest, DetectionTest) { | 153 TEST_F(PasswordGenerationAgentTest, DetectionTest) { |
126 // Don't shown the icon for non account creation forms. | 154 // Don't shown the icon for non account creation forms. |
127 LoadHTML(kSigninFormHTML); | 155 LoadHTML(kSigninFormHTML); |
128 ExpectPasswordGenerationAvailable("password", false); | 156 ExpectPasswordGenerationAvailable("password", false); |
129 | 157 |
130 // We don't show the decoration yet because the feature isn't enabled. | 158 // We don't show the decoration yet because the feature isn't enabled. |
131 LoadHTML(kAccountCreationFormHTML); | 159 LoadHTML(kAccountCreationFormHTML); |
132 ExpectPasswordGenerationAvailable("first_password", false); | 160 ExpectPasswordGenerationAvailable("first_password", false); |
133 | 161 |
134 // Pretend like We have received message indicating site is not blacklisted, | 162 // Pretend like We have received message indicating site is not blacklisted, |
135 // and we have received message indicating the form is classified as | 163 // and we have received message indicating the form is classified as |
136 // ACCOUNT_CREATION_FORM form Autofill server. We should show the icon. | 164 // ACCOUNT_CREATION_FORM form Autofill server. We should show the icon. |
137 LoadHTML(kAccountCreationFormHTML); | 165 LoadHTML(kAccountCreationFormHTML); |
138 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 166 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
139 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 167 SetAccountCreationFormsDetectedMessage(0); |
140 ExpectPasswordGenerationAvailable("first_password", true); | 168 ExpectPasswordGenerationAvailable("first_password", true); |
141 | 169 |
142 // Hidden fields are not treated differently. | 170 // Hidden fields are not treated differently. |
143 LoadHTML(kHiddenPasswordAccountCreationFormHTML); | 171 LoadHTML(kHiddenPasswordAccountCreationFormHTML); |
144 SetNotBlacklistedMessage(kHiddenPasswordAccountCreationFormHTML); | 172 SetNotBlacklistedMessage(kHiddenPasswordAccountCreationFormHTML); |
145 SetAccountCreationFormsDetectedMessage( | 173 SetAccountCreationFormsDetectedMessage(0); |
146 kHiddenPasswordAccountCreationFormHTML); | |
147 ExpectPasswordGenerationAvailable("first_password", true); | 174 ExpectPasswordGenerationAvailable("first_password", true); |
148 | 175 |
149 // This doesn't trigger because the form action is invalid. | 176 // This doesn't trigger because the form action is invalid. |
150 LoadHTML(kInvalidActionAccountCreationFormHTML); | 177 LoadHTML(kInvalidActionAccountCreationFormHTML); |
151 SetNotBlacklistedMessage(kInvalidActionAccountCreationFormHTML); | 178 SetNotBlacklistedMessage(kInvalidActionAccountCreationFormHTML); |
152 SetAccountCreationFormsDetectedMessage(kInvalidActionAccountCreationFormHTML); | 179 SetAccountCreationFormsDetectedMessage(0); |
153 ExpectPasswordGenerationAvailable("first_password", false); | 180 ExpectPasswordGenerationAvailable("first_password", false); |
154 } | 181 } |
155 | 182 |
156 TEST_F(PasswordGenerationAgentTest, FillTest) { | 183 TEST_F(PasswordGenerationAgentTest, FillTest) { |
157 // Make sure that we are enabled before loading HTML. | 184 // Make sure that we are enabled before loading HTML. |
158 std::string html = std::string(kAccountCreationFormHTML) + | 185 std::string html = std::string(kAccountCreationFormHTML) + |
159 ChangeDetectionScript; | 186 ChangeDetectionScript; |
160 LoadHTML(html.c_str()); | 187 LoadHTML(html.c_str()); |
| 188 SetNotBlacklistedMessage(html.c_str()); |
| 189 SetAccountCreationFormsDetectedMessage(0); |
161 | 190 |
162 WebDocument document = GetMainFrame()->document(); | 191 WebDocument document = GetMainFrame()->document(); |
163 WebElement element = | 192 WebElement element = |
164 document.getElementById(WebString::fromUTF8("first_password")); | 193 document.getElementById(WebString::fromUTF8("first_password")); |
165 ASSERT_FALSE(element.isNull()); | 194 ASSERT_FALSE(element.isNull()); |
166 WebInputElement first_password_element = element.to<WebInputElement>(); | 195 WebInputElement first_password_element = element.to<WebInputElement>(); |
167 element = document.getElementById(WebString::fromUTF8("second_password")); | 196 element = document.getElementById(WebString::fromUTF8("second_password")); |
168 ASSERT_FALSE(element.isNull()); | 197 ASSERT_FALSE(element.isNull()); |
169 WebInputElement second_password_element = element.to<WebInputElement>(); | 198 WebInputElement second_password_element = element.to<WebInputElement>(); |
170 | 199 |
(...skipping 29 matching lines...) Expand all Loading... |
200 // TODO(zysxqn): Change this back to the address element once Bug 90224 | 229 // TODO(zysxqn): Change this back to the address element once Bug 90224 |
201 // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed. | 230 // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed. |
202 element = document.getElementById(WebString::fromUTF8("first_password")); | 231 element = document.getElementById(WebString::fromUTF8("first_password")); |
203 ASSERT_FALSE(element.isNull()); | 232 ASSERT_FALSE(element.isNull()); |
204 EXPECT_EQ(element, document.focusedElement()); | 233 EXPECT_EQ(element, document.focusedElement()); |
205 } | 234 } |
206 | 235 |
207 TEST_F(PasswordGenerationAgentTest, EditingTest) { | 236 TEST_F(PasswordGenerationAgentTest, EditingTest) { |
208 LoadHTML(kAccountCreationFormHTML); | 237 LoadHTML(kAccountCreationFormHTML); |
209 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 238 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
210 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 239 SetAccountCreationFormsDetectedMessage(0); |
211 | 240 |
212 WebDocument document = GetMainFrame()->document(); | 241 WebDocument document = GetMainFrame()->document(); |
213 WebElement element = | 242 WebElement element = |
214 document.getElementById(WebString::fromUTF8("first_password")); | 243 document.getElementById(WebString::fromUTF8("first_password")); |
215 ASSERT_FALSE(element.isNull()); | 244 ASSERT_FALSE(element.isNull()); |
216 WebInputElement first_password_element = element.to<WebInputElement>(); | 245 WebInputElement first_password_element = element.to<WebInputElement>(); |
217 element = document.getElementById(WebString::fromUTF8("second_password")); | 246 element = document.getElementById(WebString::fromUTF8("second_password")); |
218 ASSERT_FALSE(element.isNull()); | 247 ASSERT_FALSE(element.isNull()); |
219 WebInputElement second_password_element = element.to<WebInputElement>(); | 248 WebInputElement second_password_element = element.to<WebInputElement>(); |
220 | 249 |
(...skipping 28 matching lines...) Expand all Loading... |
249 // processed. | 278 // processed. |
250 base::MessageLoop::current()->RunUntilIdle(); | 279 base::MessageLoop::current()->RunUntilIdle(); |
251 EXPECT_EQ(empty_password, first_password_element.value()); | 280 EXPECT_EQ(empty_password, first_password_element.value()); |
252 EXPECT_EQ(empty_password, second_password_element.value()); | 281 EXPECT_EQ(empty_password, second_password_element.value()); |
253 } | 282 } |
254 | 283 |
255 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { | 284 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { |
256 // Did not receive not blacklisted message. Don't show password generation | 285 // Did not receive not blacklisted message. Don't show password generation |
257 // icon. | 286 // icon. |
258 LoadHTML(kAccountCreationFormHTML); | 287 LoadHTML(kAccountCreationFormHTML); |
259 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 288 SetAccountCreationFormsDetectedMessage(0); |
260 ExpectPasswordGenerationAvailable("first_password", false); | 289 ExpectPasswordGenerationAvailable("first_password", false); |
261 | 290 |
262 // Receive one not blacklisted message for non account creation form. Don't | 291 // Receive one not blacklisted message for non account creation form. Don't |
263 // show password generation icon. | 292 // show password generation icon. |
264 LoadHTML(kAccountCreationFormHTML); | 293 LoadHTML(kAccountCreationFormHTML); |
265 SetNotBlacklistedMessage(kSigninFormHTML); | 294 SetNotBlacklistedMessage(kSigninFormHTML); |
266 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 295 SetAccountCreationFormsDetectedMessage(0); |
267 ExpectPasswordGenerationAvailable("first_password", false); | 296 ExpectPasswordGenerationAvailable("first_password", false); |
268 | 297 |
269 // Receive one not blackliste message for account creation form. Show password | 298 // Receive one not blackliste message for account creation form. Show password |
270 // generation icon. | 299 // generation icon. |
271 LoadHTML(kAccountCreationFormHTML); | 300 LoadHTML(kAccountCreationFormHTML); |
272 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 301 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
273 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 302 SetAccountCreationFormsDetectedMessage(0); |
274 ExpectPasswordGenerationAvailable("first_password", true); | 303 ExpectPasswordGenerationAvailable("first_password", true); |
275 | 304 |
276 // Receive two not blacklisted messages, one is for account creation form and | 305 // Receive two not blacklisted messages, one is for account creation form and |
277 // the other is not. Show password generation icon. | 306 // the other is not. Show password generation icon. |
278 LoadHTML(kAccountCreationFormHTML); | 307 LoadHTML(kAccountCreationFormHTML); |
279 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 308 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
280 SetNotBlacklistedMessage(kSigninFormHTML); | 309 SetNotBlacklistedMessage(kSigninFormHTML); |
281 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 310 SetAccountCreationFormsDetectedMessage(0); |
282 ExpectPasswordGenerationAvailable("first_password", true); | 311 ExpectPasswordGenerationAvailable("first_password", true); |
283 } | 312 } |
284 | 313 |
285 TEST_F(PasswordGenerationAgentTest, AccountCreationFormsDetectedTest) { | 314 TEST_F(PasswordGenerationAgentTest, AccountCreationFormsDetectedTest) { |
286 // Did not receive account creation forms detected messege. Don't show | 315 // Did not receive account creation forms detected messege. Don't show |
287 // password generation icon. | 316 // password generation icon. |
288 LoadHTML(kAccountCreationFormHTML); | 317 LoadHTML(kAccountCreationFormHTML); |
289 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 318 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
290 ExpectPasswordGenerationAvailable("first_password", false); | 319 ExpectPasswordGenerationAvailable("first_password", false); |
291 | 320 |
292 // Receive the account creation forms detected message. Show password | 321 // Receive the account creation forms detected message. Show password |
293 // generation icon. | 322 // generation icon. |
294 LoadHTML(kAccountCreationFormHTML); | 323 LoadHTML(kAccountCreationFormHTML); |
295 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 324 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
296 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 325 SetAccountCreationFormsDetectedMessage(0); |
297 ExpectPasswordGenerationAvailable("first_password", true); | 326 ExpectPasswordGenerationAvailable("first_password", true); |
298 } | 327 } |
299 | 328 |
300 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) { | 329 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) { |
301 base::HistogramTester histogram_tester; | 330 base::HistogramTester histogram_tester; |
302 | 331 |
303 LoadHTML(kAccountCreationFormHTML); | 332 LoadHTML(kAccountCreationFormHTML); |
304 SetNotBlacklistedMessage(kAccountCreationFormHTML); | 333 SetNotBlacklistedMessage(kAccountCreationFormHTML); |
305 SetAccountCreationFormsDetectedMessage(kAccountCreationFormHTML); | 334 SetAccountCreationFormsDetectedMessage(0); |
306 ExpectPasswordGenerationAvailable("first_password", true); | 335 ExpectPasswordGenerationAvailable("first_password", true); |
307 | 336 |
308 WebDocument document = GetMainFrame()->document(); | 337 WebDocument document = GetMainFrame()->document(); |
309 WebElement element = | 338 WebElement element = |
310 document.getElementById(WebString::fromUTF8("first_password")); | 339 document.getElementById(WebString::fromUTF8("first_password")); |
311 ASSERT_FALSE(element.isNull()); | 340 ASSERT_FALSE(element.isNull()); |
312 WebInputElement first_password_element = element.to<WebInputElement>(); | 341 WebInputElement first_password_element = element.to<WebInputElement>(); |
313 | 342 |
314 // Make a password just under maximum offer size. | 343 // Make a password just under maximum offer size. |
315 first_password_element.setValue( | 344 first_password_element.setValue( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 408 |
380 histogram_tester.ExpectBucketCount( | 409 histogram_tester.ExpectBucketCount( |
381 "PasswordGeneration.Event", | 410 "PasswordGeneration.Event", |
382 autofill::password_generation::GENERATION_POPUP_SHOWN, | 411 autofill::password_generation::GENERATION_POPUP_SHOWN, |
383 1); | 412 1); |
384 } | 413 } |
385 | 414 |
386 TEST_F(PasswordGenerationAgentTest, DynamicFormTest) { | 415 TEST_F(PasswordGenerationAgentTest, DynamicFormTest) { |
387 LoadHTML(kSigninFormHTML); | 416 LoadHTML(kSigninFormHTML); |
388 SetNotBlacklistedMessage(kSigninFormHTML); | 417 SetNotBlacklistedMessage(kSigninFormHTML); |
389 SetAccountCreationFormsDetectedMessage(kSigninFormHTML); | |
390 | 418 |
391 ExecuteJavaScript( | 419 ExecuteJavaScript( |
392 "var form = document.createElement('form');" | 420 "var form = document.createElement('form');" |
393 "var username = document.createElement('input');" | 421 "var username = document.createElement('input');" |
394 "username.type = 'text';" | 422 "username.type = 'text';" |
395 "username.id = 'dynamic_username';" | 423 "username.id = 'dynamic_username';" |
396 "var first_password = document.createElement('input');" | 424 "var first_password = document.createElement('input');" |
397 "first_password.type = 'password';" | 425 "first_password.type = 'password';" |
398 "first_password.id = 'first_password';" | 426 "first_password.id = 'first_password';" |
399 "first_password.name = 'first_password';" | 427 "first_password.name = 'first_password';" |
400 "var second_password = document.createElement('input');" | 428 "var second_password = document.createElement('input');" |
401 "second_password.type = 'password';" | 429 "second_password.type = 'password';" |
402 "second_password.id = 'second_password';" | 430 "second_password.id = 'second_password';" |
403 "second_password.name = 'second_password';" | 431 "second_password.name = 'second_password';" |
404 "form.appendChild(username);" | 432 "form.appendChild(username);" |
405 "form.appendChild(first_password);" | 433 "form.appendChild(first_password);" |
406 "form.appendChild(second_password);" | 434 "form.appendChild(second_password);" |
407 "document.body.appendChild(form);"); | 435 "document.body.appendChild(form);"); |
408 ProcessPendingMessages(); | 436 ProcessPendingMessages(); |
| 437 |
| 438 // This needs to come after the DOM has been modified. |
| 439 SetAccountCreationFormsDetectedMessage(1); |
| 440 |
409 // TODO(gcasto): I'm slighty worried about flakes in this test where | 441 // TODO(gcasto): I'm slighty worried about flakes in this test where |
410 // didAssociateFormControls() isn't called. If this turns out to be a problem | 442 // didAssociateFormControls() isn't called. If this turns out to be a problem |
411 // adding a call to OnDynamicFormsSeen(GetMainFrame()) will fix it, though | 443 // adding a call to OnDynamicFormsSeen(GetMainFrame()) will fix it, though |
412 // it will weaken the test. | 444 // it will weaken the test. |
413 ExpectPasswordGenerationAvailable("first_password", true); | 445 ExpectPasswordGenerationAvailable("first_password", true); |
414 } | 446 } |
415 | 447 |
| 448 TEST_F(PasswordGenerationAgentTest, MultiplePasswordFormsTest) { |
| 449 // If two forms on the page looks like possible account creation forms, make |
| 450 // sure to trigger on the one that is specified from Autofill. |
| 451 LoadHTML(kMultipleAccountCreationFormHTML); |
| 452 SetNotBlacklistedMessage(kMultipleAccountCreationFormHTML); |
| 453 |
| 454 // Should trigger on the second form. |
| 455 SetAccountCreationFormsDetectedMessage(1); |
| 456 |
| 457 ExpectPasswordGenerationAvailable("password", false); |
| 458 |
| 459 // TODO(gcasto): Enable this check once we examine multiple heuristic matches. |
| 460 //ExpectPasswordGenerationAvailable("first_password", true); |
| 461 } |
| 462 |
416 } // namespace autofill | 463 } // namespace autofill |
OLD | NEW |