Chromium Code Reviews| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 157 |
| 158 WebElement web_element = frame->document().getElementById("element"); | 158 WebElement web_element = frame->document().getElementById("element"); |
| 159 WebFormControlElement element = web_element.to<WebFormControlElement>(); | 159 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 160 FormFieldData result; | 160 FormFieldData result; |
| 161 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | 161 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| 162 | 162 |
| 163 FormFieldData expected; | 163 FormFieldData expected; |
| 164 expected.name = ASCIIToUTF16("element"); | 164 expected.name = ASCIIToUTF16("element"); |
| 165 expected.value = ASCIIToUTF16("value"); | 165 expected.value = ASCIIToUTF16("value"); |
| 166 expected.form_control_type = ASCIIToUTF16("text"); | 166 expected.form_control_type = ASCIIToUTF16("text"); |
| 167 expected.autocomplete_attribute = ASCIIToUTF16("off"); | |
| 167 expected.max_length = WebInputElement::defaultMaxLength(); | 168 expected.max_length = WebInputElement::defaultMaxLength(); |
| 168 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | 169 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
| 169 } | 170 } |
| 170 | 171 |
| 171 // We should be able to extract a text field with maxlength specified. | 172 // We should be able to extract a text field with maxlength specified. |
| 172 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldMaxLength) { | 173 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldMaxLength) { |
| 173 LoadHTML("<INPUT type=\"text\" id=\"element\" value=\"value\"" | 174 LoadHTML("<INPUT type=\"text\" id=\"element\" value=\"value\"" |
| 174 " maxlength=\"5\"/>"); | 175 " maxlength=\"5\"/>"); |
| 175 | 176 |
| 176 WebFrame* frame = GetMainFrame(); | 177 WebFrame* frame = GetMainFrame(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | 310 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| 310 expected.name = ASCIIToUTF16("submit"); | 311 expected.name = ASCIIToUTF16("submit"); |
| 311 expected.form_control_type = ASCIIToUTF16("submit"); | 312 expected.form_control_type = ASCIIToUTF16("submit"); |
| 312 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | 313 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
| 313 } | 314 } |
| 314 | 315 |
| 315 // We should be able to extract the autocompletetype attribute. | 316 // We should be able to extract the autocompletetype attribute. |
| 316 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { | 317 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { |
| 317 std::string html = | 318 std::string html = |
| 318 "<INPUT type=\"text\" id=\"absent\"/>" | 319 "<INPUT type=\"text\" id=\"absent\"/>" |
| 319 "<INPUT type=\"text\" id=\"empty\" x-autocompletetype=\"\"/>" | 320 "<INPUT type=\"text\" id=\"empty\" autocomplete=\"\"/>" |
| 320 "<INPUT type=\"text\" id=\"whitespace\" x-autocompletetype=\" \"/>" | 321 "<INPUT type=\"text\" id=\"off\" autocomplete=\"off\"/>" |
| 321 "<INPUT type=\"text\" id=\"regular\" x-autocompletetype=\"email\"/>" | 322 "<INPUT type=\"text\" id=\"regular\" autocomplete=\"email\"/>" |
| 322 "<INPUT type=\"text\" id=\"multi-valued\" " | 323 "<INPUT type=\"text\" id=\"multi-valued\" " |
| 323 " x-autocompletetype=\"x-confirm-email email\"/>" | 324 " autocomplete=\"billing email\"/>" |
| 324 "<INPUT type=\"text\" id=\"unprefixed\" autocompletetype=\"email\"/>" | 325 "<INPUT type=\"text\" id=\"experimental\" x-autocompletetype=\"email\"/>" |
| 325 "<SELECT id=\"select\" x-autocompletetype=\"state\"/>" | 326 "<SELECT id=\"select\" autocomplete=\"state\"/>" |
| 326 " <OPTION value=\"CA\">California</OPTION>" | 327 " <OPTION value=\"CA\">California</OPTION>" |
| 327 " <OPTION value=\"TX\">Texas</OPTION>" | 328 " <OPTION value=\"TX\">Texas</OPTION>" |
| 328 "</SELECT>"; | 329 "</SELECT>"; |
| 329 html += | 330 html += |
| 330 "<INPUT type=\"text\" id=\"malicious\" x-autocompletetype=\"" + | 331 "<INPUT type=\"text\" id=\"malicious\" autocomplete=\"" + |
| 331 std::string(10000, 'x') + "\"/>"; | 332 std::string(10000, 'x') + "\"/>"; |
| 332 LoadHTML(html.c_str()); | 333 LoadHTML(html.c_str()); |
| 333 | 334 |
| 334 WebFrame* frame = GetMainFrame(); | 335 WebFrame* frame = GetMainFrame(); |
| 335 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | 336 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| 336 | 337 |
| 337 // An absent attribute is equivalent to an empty one. | 338 // An absent attribute is equivalent to an empty one. |
| 338 WebElement web_element = frame->document().getElementById("absent"); | 339 { |
| 339 WebFormControlElement element = web_element.to<WebFormControlElement>(); | 340 WebElement web_element = frame->document().getElementById("absent"); |
| 340 FormFieldData result1; | 341 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 341 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result1); | 342 FormFieldData result; |
| 343 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); | |
|
Dan Beam
2012/10/19 00:12:44
nit: these tests overall could probably be a bit l
Ilya Sherman
2012/10/19 04:19:32
Didn't extract a function, but I consolidated a lo
| |
| 342 | 344 |
| 343 FormFieldData expected; | 345 FormFieldData expected; |
| 344 expected.name = ASCIIToUTF16("absent"); | 346 expected.name = ASCIIToUTF16("absent"); |
| 345 expected.form_control_type = ASCIIToUTF16("text"); | 347 expected.form_control_type = ASCIIToUTF16("text"); |
| 346 expected.autocomplete_type = string16(); | 348 expected.autocomplete_attribute = string16(); |
| 347 expected.max_length = WebInputElement::defaultMaxLength(); | 349 expected.max_length = WebInputElement::defaultMaxLength(); |
| 348 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); | 350 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
| 351 } | |
| 349 | 352 |
| 350 web_element = frame->document().getElementById("empty"); | 353 // Make sure there are no issues parsing an empty attribute. |
| 351 element = web_element.to<WebFormControlElement>(); | 354 { |
| 352 FormFieldData result2; | 355 WebElement web_element = frame->document().getElementById("empty"); |
| 353 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result2); | 356 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 354 expected.name = ASCIIToUTF16("empty"); | 357 FormFieldData result; |
| 355 expected.form_control_type = ASCIIToUTF16("text"); | 358 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
| 356 expected.autocomplete_type = string16(); | |
| 357 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 358 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); | |
| 359 | 359 |
| 360 // The renderer should trim whitespace. | 360 FormFieldData expected; |
| 361 web_element = frame->document().getElementById("whitespace"); | 361 expected.name = ASCIIToUTF16("empty"); |
| 362 element = web_element.to<WebFormControlElement>(); | 362 expected.form_control_type = ASCIIToUTF16("text"); |
| 363 FormFieldData result3; | 363 expected.autocomplete_attribute = string16(); |
| 364 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result3); | 364 expected.max_length = WebInputElement::defaultMaxLength(); |
| 365 expected.name = ASCIIToUTF16("whitespace"); | 365 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
| 366 expected.form_control_type = ASCIIToUTF16("text"); | 366 } |
| 367 expected.autocomplete_type = string16(); | 367 |
| 368 expected.max_length = WebInputElement::defaultMaxLength(); | 368 // Make sure there are no issues parsing an attribute value that isn't a type |
| 369 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); | 369 // hint. |
| 370 { | |
| 371 WebElement web_element = frame->document().getElementById("off"); | |
| 372 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
| 373 FormFieldData result; | |
| 374 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); | |
| 375 | |
| 376 FormFieldData expected; | |
| 377 expected.name = ASCIIToUTF16("off"); | |
| 378 expected.form_control_type = ASCIIToUTF16("text"); | |
| 379 expected.autocomplete_attribute = ASCIIToUTF16("off"); | |
| 380 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 381 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | |
| 382 } | |
| 370 | 383 |
| 371 // Common case: exactly one type specified. | 384 // Common case: exactly one type specified. |
| 372 web_element = frame->document().getElementById("regular"); | 385 { |
| 373 element = web_element.to<WebFormControlElement>(); | 386 WebElement web_element = frame->document().getElementById("regular"); |
| 374 FormFieldData result4; | 387 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 375 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result4); | 388 FormFieldData result; |
| 376 expected.name = ASCIIToUTF16("regular"); | 389 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
| 377 expected.form_control_type = ASCIIToUTF16("text"); | |
| 378 expected.autocomplete_type = ASCIIToUTF16("email"); | |
| 379 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 380 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result4); | |
| 381 | 390 |
| 382 // Verify that we correctly extract fallback types as well. | 391 FormFieldData expected; |
| 383 web_element = frame->document().getElementById("multi-valued"); | 392 expected.name = ASCIIToUTF16("regular"); |
| 384 element = web_element.to<WebFormControlElement>(); | 393 expected.form_control_type = ASCIIToUTF16("text"); |
| 385 FormFieldData result5; | 394 expected.autocomplete_attribute = ASCIIToUTF16("email"); |
| 386 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result5); | 395 expected.max_length = WebInputElement::defaultMaxLength(); |
| 387 expected.name = ASCIIToUTF16("multi-valued"); | 396 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
| 388 expected.form_control_type = ASCIIToUTF16("text"); | 397 } |
| 389 expected.autocomplete_type = ASCIIToUTF16("x-confirm-email email"); | |
| 390 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 391 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result5); | |
| 392 | 398 |
| 393 // The attribute is not yet part of the HTML standard, so we only recognize | 399 // Verify that we correctly extract multiple tokens as well. |
| 394 // the prefixed version -- 'x-autocompletetype' -- and not the unprefixed one. | 400 { |
| 395 web_element = frame->document().getElementById("unprefixed"); | 401 WebElement web_element = frame->document().getElementById("multi-valued"); |
| 396 element = web_element.to<WebFormControlElement>(); | 402 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 397 FormFieldData result6; | 403 FormFieldData result; |
| 398 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result6); | 404 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
| 399 expected.name = ASCIIToUTF16("unprefixed"); | 405 |
| 400 expected.form_control_type = ASCIIToUTF16("text"); | 406 FormFieldData expected; |
| 401 expected.autocomplete_type = string16(); | 407 expected.name = ASCIIToUTF16("multi-valued"); |
| 402 expected.max_length = WebInputElement::defaultMaxLength(); | 408 expected.form_control_type = ASCIIToUTF16("text"); |
| 403 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result6); | 409 expected.autocomplete_attribute = ASCIIToUTF16("billing email"); |
| 410 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 411 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | |
| 412 } | |
| 413 | |
| 414 // We previously extracted this data from the experimental | |
| 415 // 'x-autocompletetype' attribute. Now that the field type hints are part of | |
| 416 // the spec under the autocomplete attribute, we no longer support the | |
| 417 // experimental version. | |
| 418 { | |
| 419 WebElement web_element = frame->document().getElementById("experimental"); | |
| 420 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
| 421 FormFieldData result; | |
| 422 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); | |
| 423 | |
| 424 FormFieldData expected; | |
| 425 expected.name = ASCIIToUTF16("experimental"); | |
| 426 expected.form_control_type = ASCIIToUTF16("text"); | |
| 427 expected.autocomplete_attribute = string16(); | |
| 428 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 429 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | |
| 430 } | |
| 404 | 431 |
| 405 // <select> elements should behave no differently from text fields here. | 432 // <select> elements should behave no differently from text fields here. |
| 406 web_element = frame->document().getElementById("select"); | 433 { |
| 407 element = web_element.to<WebFormControlElement>(); | 434 WebElement web_element = frame->document().getElementById("select"); |
| 408 FormFieldData result7; | 435 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 409 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result7); | 436 FormFieldData result; |
| 410 expected.name = ASCIIToUTF16("select"); | 437 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
| 411 expected.form_control_type = ASCIIToUTF16("select-one"); | 438 |
| 412 expected.autocomplete_type = ASCIIToUTF16("state"); | 439 FormFieldData expected; |
| 413 expected.max_length = 0; | 440 expected.name = ASCIIToUTF16("select"); |
| 414 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result7); | 441 expected.form_control_type = ASCIIToUTF16("select-one"); |
| 442 expected.autocomplete_attribute = ASCIIToUTF16("state"); | |
| 443 expected.max_length = 0; | |
| 444 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | |
| 445 } | |
| 415 | 446 |
| 416 // Very long attribute values should be replaced by a default string, to | 447 // Very long attribute values should be replaced by a default string, to |
| 417 // prevent malicious websites from DOSing the browser process. | 448 // prevent malicious websites from DOSing the browser process. |
| 418 web_element = frame->document().getElementById("malicious"); | 449 { |
| 419 element = web_element.to<WebFormControlElement>(); | 450 WebElement web_element = frame->document().getElementById("malicious"); |
| 420 FormFieldData result8; | 451 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 421 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result8); | 452 FormFieldData result; |
| 422 expected.name = ASCIIToUTF16("malicious"); | 453 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
| 423 expected.form_control_type = ASCIIToUTF16("text"); | 454 |
| 424 expected.autocomplete_type = ASCIIToUTF16("x-max-data-length-exceeded"); | 455 FormFieldData expected; |
| 425 expected.max_length = WebInputElement::defaultMaxLength(); | 456 expected.name = ASCIIToUTF16("malicious"); |
| 426 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result8); | 457 expected.form_control_type = ASCIIToUTF16("text"); |
| 458 expected.autocomplete_attribute = | |
| 459 ASCIIToUTF16("x-max-data-length-exceeded"); | |
| 460 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 461 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | |
| 462 } | |
| 427 } | 463 } |
| 428 | 464 |
| 429 TEST_F(FormAutofillTest, WebFormElementToFormData) { | 465 TEST_F(FormAutofillTest, WebFormElementToFormData) { |
| 430 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 466 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 431 " <LABEL for=\"firstname\">First name:</LABEL>" | 467 " <LABEL for=\"firstname\">First name:</LABEL>" |
| 432 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 468 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 433 " <LABEL for=\"lastname\">Last name:</LABEL>" | 469 " <LABEL for=\"lastname\">Last name:</LABEL>" |
| 434 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 470 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| 435 " <LABEL for=\"state\">State:</LABEL>" | 471 " <LABEL for=\"state\">State:</LABEL>" |
| 436 " <SELECT id=\"state\"/>" | 472 " <SELECT id=\"state\"/>" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 expected.value = ASCIIToUTF16("John"); | 775 expected.value = ASCIIToUTF16("John"); |
| 740 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | 776 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
| 741 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); | 777 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); |
| 742 | 778 |
| 743 expected.name = ASCIIToUTF16("lastname"); | 779 expected.name = ASCIIToUTF16("lastname"); |
| 744 expected.value = ASCIIToUTF16("Smith"); | 780 expected.value = ASCIIToUTF16("Smith"); |
| 745 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 781 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 746 | 782 |
| 747 expected.name = ASCIIToUTF16("email"); | 783 expected.name = ASCIIToUTF16("email"); |
| 748 expected.value = ASCIIToUTF16("john@example.com"); | 784 expected.value = ASCIIToUTF16("john@example.com"); |
| 785 expected.autocomplete_attribute = ASCIIToUTF16("off"); | |
| 749 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 786 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 750 | 787 |
| 751 expected.name = ASCIIToUTF16("phone"); | 788 expected.name = ASCIIToUTF16("phone"); |
| 752 expected.value = ASCIIToUTF16("1.800.555.1234"); | 789 expected.value = ASCIIToUTF16("1.800.555.1234"); |
| 790 expected.autocomplete_attribute = string16(); | |
| 753 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); | 791 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); |
| 754 | 792 |
| 755 // Try again, but require autocomplete. | 793 // Try again, but require autocomplete. |
| 756 FormData form2; | 794 FormData form2; |
| 757 FormFieldData field2; | 795 FormFieldData field2; |
| 758 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 796 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, |
| 759 autofill::REQUIRE_AUTOCOMPLETE)); | 797 autofill::REQUIRE_AUTOCOMPLETE)); |
| 760 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 798 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
| 761 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 799 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
| 762 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 800 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
| (...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2489 expected.name = ASCIIToUTF16("firstname"); | 2527 expected.name = ASCIIToUTF16("firstname"); |
| 2490 expected.value = string16(); | 2528 expected.value = string16(); |
| 2491 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2529 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 2492 | 2530 |
| 2493 expected.name = ASCIIToUTF16("lastname"); | 2531 expected.name = ASCIIToUTF16("lastname"); |
| 2494 expected.value = string16(); | 2532 expected.value = string16(); |
| 2495 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 2533 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 2496 | 2534 |
| 2497 expected.name = ASCIIToUTF16("noAC"); | 2535 expected.name = ASCIIToUTF16("noAC"); |
| 2498 expected.value = string16(); | 2536 expected.value = string16(); |
| 2537 expected.autocomplete_attribute = ASCIIToUTF16("off"); | |
| 2499 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 2538 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 2500 | 2539 |
| 2501 expected.name = ASCIIToUTF16("notenabled"); | 2540 expected.name = ASCIIToUTF16("notenabled"); |
| 2502 expected.value = ASCIIToUTF16("no clear"); | 2541 expected.value = ASCIIToUTF16("no clear"); |
| 2542 expected.autocomplete_attribute = string16(); | |
| 2503 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]); | 2543 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]); |
| 2504 | 2544 |
| 2505 // Verify that the cursor position has been updated. | 2545 // Verify that the cursor position has been updated. |
| 2506 EXPECT_EQ(0, firstname.selectionStart()); | 2546 EXPECT_EQ(0, firstname.selectionStart()); |
| 2507 EXPECT_EQ(0, firstname.selectionEnd()); | 2547 EXPECT_EQ(0, firstname.selectionEnd()); |
| 2508 } | 2548 } |
| 2509 | 2549 |
| 2510 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { | 2550 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { |
| 2511 LoadHTML( | 2551 LoadHTML( |
| 2512 "<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" | 2552 "<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2931 expected.form_control_type = ASCIIToUTF16("text"); | 2971 expected.form_control_type = ASCIIToUTF16("text"); |
| 2932 expected.max_length = WebInputElement::defaultMaxLength(); | 2972 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2933 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 2973 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 2934 | 2974 |
| 2935 expected.name = ASCIIToUTF16("country"); | 2975 expected.name = ASCIIToUTF16("country"); |
| 2936 expected.value = ASCIIToUTF16("AL"); | 2976 expected.value = ASCIIToUTF16("AL"); |
| 2937 expected.form_control_type = ASCIIToUTF16("select-one"); | 2977 expected.form_control_type = ASCIIToUTF16("select-one"); |
| 2938 expected.max_length = 0; | 2978 expected.max_length = 0; |
| 2939 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2979 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 2940 } | 2980 } |
| OLD | NEW |