| 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/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2386 " <INPUT type='text' id='firstname' value='John'/>" | 2386 " <INPUT type='text' id='firstname' value='John'/>" |
| 2387 " <INPUT type='text' id='lastname' value='Smith'/>" | 2387 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2388 " <INPUT type='text' id='email' value='john@example.com'" | 2388 " <INPUT type='text' id='email' value='john@example.com'" |
| 2389 "autocomplete='off' />" | 2389 "autocomplete='off' />" |
| 2390 " <INPUT type='text' id='phone' value='1.800.555.1234'/>" | 2390 " <INPUT type='text' id='phone' value='1.800.555.1234'/>" |
| 2391 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2391 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2392 "</FORM>", | 2392 "</FORM>", |
| 2393 false); | 2393 false); |
| 2394 } | 2394 } |
| 2395 | 2395 |
| 2396 TEST_F(FormAutofillTest, DISABLED_FindFormForInputElementForUnownedForm) { | 2396 TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) { |
| 2397 TestFindFormForInputElement( | 2397 TestFindFormForInputElement( |
| 2398 "<INPUT type='text' id='firstname' value='John'/>" | 2398 "<INPUT type='text' id='firstname' value='John'/>" |
| 2399 "<INPUT type='text' id='lastname' value='Smith'/>" | 2399 "<INPUT type='text' id='lastname' value='Smith'/>" |
| 2400 "<INPUT type='text' id='email' value='john@example.com'" | 2400 "<INPUT type='text' id='email' value='john@example.com'" |
| 2401 "autocomplete='off' />" | 2401 "autocomplete='off' />" |
| 2402 "<INPUT type='text' id='phone' value='1.800.555.1234'/>" | 2402 "<INPUT type='text' id='phone' value='1.800.555.1234'/>" |
| 2403 "<INPUT type='submit' name='reply-send' value='Send'/>", | 2403 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 2404 true); | 2404 true); |
| 2405 } | 2405 } |
| 2406 | 2406 |
| 2407 TEST_F(FormAutofillTest, FindFormForTextAreaElement) { | 2407 TEST_F(FormAutofillTest, FindFormForTextAreaElement) { |
| 2408 TestFindFormForTextAreaElement( | 2408 TestFindFormForTextAreaElement( |
| 2409 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 2409 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 2410 " <INPUT type='text' id='firstname' value='John'/>" | 2410 " <INPUT type='text' id='firstname' value='John'/>" |
| 2411 " <INPUT type='text' id='lastname' value='Smith'/>" | 2411 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2412 " <INPUT type='text' id='email' value='john@example.com'" | 2412 " <INPUT type='text' id='email' value='john@example.com'" |
| 2413 "autocomplete='off' />" | 2413 "autocomplete='off' />" |
| 2414 " <TEXTAREA id='street-address'>" | 2414 " <TEXTAREA id='street-address'>" |
| 2415 "123 Fantasy Ln. " | 2415 "123 Fantasy Ln. " |
| 2416 "Apt. 42" | 2416 "Apt. 42" |
| 2417 "</TEXTAREA>" | 2417 "</TEXTAREA>" |
| 2418 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2418 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2419 "</FORM>", | 2419 "</FORM>", |
| 2420 false); | 2420 false); |
| 2421 } | 2421 } |
| 2422 | 2422 |
| 2423 TEST_F(FormAutofillTest, DISABLED_FindFormForTextAreaElementForUnownedForm) { | 2423 TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) { |
| 2424 TestFindFormForTextAreaElement( | 2424 TestFindFormForTextAreaElement( |
| 2425 "<INPUT type='text' id='firstname' value='John'/>" | 2425 "<INPUT type='text' id='firstname' value='John'/>" |
| 2426 "<INPUT type='text' id='lastname' value='Smith'/>" | 2426 "<INPUT type='text' id='lastname' value='Smith'/>" |
| 2427 "<INPUT type='text' id='email' value='john@example.com'" | 2427 "<INPUT type='text' id='email' value='john@example.com'" |
| 2428 "autocomplete='off' />" | 2428 "autocomplete='off' />" |
| 2429 "<TEXTAREA id='street-address'>" | 2429 "<TEXTAREA id='street-address'>" |
| 2430 "123 Fantasy Ln. " | 2430 "123 Fantasy Ln. " |
| 2431 "Apt. 42" | 2431 "Apt. 42" |
| 2432 "</TEXTAREA>" | 2432 "</TEXTAREA>" |
| 2433 "<INPUT type='submit' name='reply-send' value='Send'/>", | 2433 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 2434 true); | 2434 true); |
| 2435 } | 2435 } |
| 2436 | 2436 |
| 2437 // Test regular FillForm function. | 2437 // Test regular FillForm function. |
| 2438 TEST_F(FormAutofillTest, FillForm) { | 2438 TEST_F(FormAutofillTest, FillForm) { |
| 2439 TestFillForm(kFormHtml, false); | 2439 TestFillForm(kFormHtml, false); |
| 2440 } | 2440 } |
| 2441 | 2441 |
| 2442 TEST_F(FormAutofillTest, DISABLED_FillFormForUnownedForm) { | 2442 TEST_F(FormAutofillTest, FillFormForUnownedForm) { |
| 2443 TestFillForm(kUnownedFormHtml, true); | 2443 TestFillForm(kUnownedFormHtml, true); |
| 2444 } | 2444 } |
| 2445 | 2445 |
| 2446 TEST_F(FormAutofillTest, FillFormIncludingNonFocusableElements) { | 2446 TEST_F(FormAutofillTest, FillFormIncludingNonFocusableElements) { |
| 2447 static const AutofillFieldCase field_cases[] = { | 2447 static const AutofillFieldCase field_cases[] = { |
| 2448 // fields: form_control_type, name, initial_value, autocomplete_attribute, | 2448 // fields: form_control_type, name, initial_value, autocomplete_attribute, |
| 2449 // should_be_autofilled, autofill_value, expected_value | 2449 // should_be_autofilled, autofill_value, expected_value |
| 2450 | 2450 |
| 2451 // Regular empty fields (firstname & lastname) should be autofilled. | 2451 // Regular empty fields (firstname & lastname) should be autofilled. |
| 2452 {"text", | 2452 {"text", |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 }; | 2524 }; |
| 2525 TestFormFillFunctions(kFormHtml, false, field_cases, arraysize(field_cases), | 2525 TestFormFillFunctions(kFormHtml, false, field_cases, arraysize(field_cases), |
| 2526 &FillFormIncludingNonFocusableElementsWrapper, | 2526 &FillFormIncludingNonFocusableElementsWrapper, |
| 2527 &GetValueWrapper); | 2527 &GetValueWrapper); |
| 2528 } | 2528 } |
| 2529 | 2529 |
| 2530 TEST_F(FormAutofillTest, PreviewForm) { | 2530 TEST_F(FormAutofillTest, PreviewForm) { |
| 2531 TestPreviewForm(kFormHtml, false); | 2531 TestPreviewForm(kFormHtml, false); |
| 2532 } | 2532 } |
| 2533 | 2533 |
| 2534 TEST_F(FormAutofillTest, DISABLED_PreviewFormForUnownedForm) { | 2534 TEST_F(FormAutofillTest, PreviewFormForUnownedForm) { |
| 2535 TestPreviewForm(kUnownedFormHtml, true); | 2535 TestPreviewForm(kUnownedFormHtml, true); |
| 2536 } | 2536 } |
| 2537 | 2537 |
| 2538 TEST_F(FormAutofillTest, Labels) { | 2538 TEST_F(FormAutofillTest, Labels) { |
| 2539 ExpectJohnSmithLabels( | 2539 ExpectJohnSmithLabels( |
| 2540 "<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2540 "<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 2541 " <LABEL for='firstname'> First name: </LABEL>" | 2541 " <LABEL for='firstname'> First name: </LABEL>" |
| 2542 " <INPUT type='text' id='firstname' value='John'/>" | 2542 " <INPUT type='text' id='firstname' value='John'/>" |
| 2543 " <LABEL for='lastname'> Last name: </LABEL>" | 2543 " <LABEL for='lastname'> Last name: </LABEL>" |
| 2544 " <INPUT type='text' id='lastname' value='Smith'/>" | 2544 " <INPUT type='text' id='lastname' value='Smith'/>" |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 TestFillFormMaxLength( | 3399 TestFillFormMaxLength( |
| 3400 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3400 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3401 " <INPUT type='text' id='firstname' maxlength='5'/>" | 3401 " <INPUT type='text' id='firstname' maxlength='5'/>" |
| 3402 " <INPUT type='text' id='lastname' maxlength='7'/>" | 3402 " <INPUT type='text' id='lastname' maxlength='7'/>" |
| 3403 " <INPUT type='text' id='email' maxlength='9'/>" | 3403 " <INPUT type='text' id='email' maxlength='9'/>" |
| 3404 " <INPUT type='submit' name='reply-send' value='Send'/>" | 3404 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 3405 "</FORM>", | 3405 "</FORM>", |
| 3406 false); | 3406 false); |
| 3407 } | 3407 } |
| 3408 | 3408 |
| 3409 TEST_F(FormAutofillTest, DISABLED_FillFormMaxLengthForUnownedForm) { | 3409 TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) { |
| 3410 TestFillFormMaxLength( | 3410 TestFillFormMaxLength( |
| 3411 "<INPUT type='text' id='firstname' maxlength='5'/>" | 3411 "<INPUT type='text' id='firstname' maxlength='5'/>" |
| 3412 "<INPUT type='text' id='lastname' maxlength='7'/>" | 3412 "<INPUT type='text' id='lastname' maxlength='7'/>" |
| 3413 "<INPUT type='text' id='email' maxlength='9'/>" | 3413 "<INPUT type='text' id='email' maxlength='9'/>" |
| 3414 "<INPUT type='submit' name='reply-send' value='Send'/>", | 3414 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 3415 true); | 3415 true); |
| 3416 } | 3416 } |
| 3417 | 3417 |
| 3418 // This test uses negative values of the maxlength attribute for input elements. | 3418 // This test uses negative values of the maxlength attribute for input elements. |
| 3419 // In this case, the maxlength of the input elements is set to the default | 3419 // In this case, the maxlength of the input elements is set to the default |
| 3420 // maxlength (defined in WebKit.) | 3420 // maxlength (defined in WebKit.) |
| 3421 TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { | 3421 TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { |
| 3422 TestFillFormNegativeMaxLength( | 3422 TestFillFormNegativeMaxLength( |
| 3423 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3423 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3424 " <INPUT type='text' id='firstname' maxlength='-1'/>" | 3424 " <INPUT type='text' id='firstname' maxlength='-1'/>" |
| 3425 " <INPUT type='text' id='lastname' maxlength='-10'/>" | 3425 " <INPUT type='text' id='lastname' maxlength='-10'/>" |
| 3426 " <INPUT type='text' id='email' maxlength='-13'/>" | 3426 " <INPUT type='text' id='email' maxlength='-13'/>" |
| 3427 " <INPUT type='submit' name='reply-send' value='Send'/>" | 3427 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 3428 "</FORM>", | 3428 "</FORM>", |
| 3429 false); | 3429 false); |
| 3430 } | 3430 } |
| 3431 | 3431 |
| 3432 TEST_F(FormAutofillTest, DISABLED_FillFormNegativeMaxLengthForUnownedForm) { | 3432 TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) { |
| 3433 TestFillFormNegativeMaxLength( | 3433 TestFillFormNegativeMaxLength( |
| 3434 "<INPUT type='text' id='firstname' maxlength='-1'/>" | 3434 "<INPUT type='text' id='firstname' maxlength='-1'/>" |
| 3435 "<INPUT type='text' id='lastname' maxlength='-10'/>" | 3435 "<INPUT type='text' id='lastname' maxlength='-10'/>" |
| 3436 "<INPUT type='text' id='email' maxlength='-13'/>" | 3436 "<INPUT type='text' id='email' maxlength='-13'/>" |
| 3437 "<INPUT type='submit' name='reply-send' value='Send'/>", | 3437 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 3438 true); | 3438 true); |
| 3439 } | 3439 } |
| 3440 | 3440 |
| 3441 TEST_F(FormAutofillTest, FillFormEmptyName) { | 3441 TEST_F(FormAutofillTest, FillFormEmptyName) { |
| 3442 TestFillFormEmptyName( | 3442 TestFillFormEmptyName( |
| 3443 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3443 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3444 " <INPUT type='text' id='firstname'/>" | 3444 " <INPUT type='text' id='firstname'/>" |
| 3445 " <INPUT type='text' id='lastname'/>" | 3445 " <INPUT type='text' id='lastname'/>" |
| 3446 " <INPUT type='text' id='email'/>" | 3446 " <INPUT type='text' id='email'/>" |
| 3447 " <INPUT type='submit' value='Send'/>" | 3447 " <INPUT type='submit' value='Send'/>" |
| 3448 "</FORM>", | 3448 "</FORM>", |
| 3449 false); | 3449 false); |
| 3450 } | 3450 } |
| 3451 | 3451 |
| 3452 TEST_F(FormAutofillTest, DISABLED_FillFormEmptyNameForUnownedForm) { | 3452 TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) { |
| 3453 TestFillFormEmptyName( | 3453 TestFillFormEmptyName( |
| 3454 "<INPUT type='text' id='firstname'/>" | 3454 "<INPUT type='text' id='firstname'/>" |
| 3455 "<INPUT type='text' id='lastname'/>" | 3455 "<INPUT type='text' id='lastname'/>" |
| 3456 "<INPUT type='text' id='email'/>" | 3456 "<INPUT type='text' id='email'/>" |
| 3457 "<INPUT type='submit' value='Send'/>", | 3457 "<INPUT type='submit' value='Send'/>", |
| 3458 true); | 3458 true); |
| 3459 } | 3459 } |
| 3460 | 3460 |
| 3461 TEST_F(FormAutofillTest, FillFormEmptyFormNames) { | 3461 TEST_F(FormAutofillTest, FillFormEmptyFormNames) { |
| 3462 TestFillFormEmptyFormNames( | 3462 TestFillFormEmptyFormNames( |
| 3463 "<FORM action='http://buh.com' method='post'>" | 3463 "<FORM action='http://buh.com' method='post'>" |
| 3464 " <INPUT type='text' id='firstname'/>" | 3464 " <INPUT type='text' id='firstname'/>" |
| 3465 " <INPUT type='text' id='middlename'/>" | 3465 " <INPUT type='text' id='middlename'/>" |
| 3466 " <INPUT type='text' id='lastname'/>" | 3466 " <INPUT type='text' id='lastname'/>" |
| 3467 " <INPUT type='submit' value='Send'/>" | 3467 " <INPUT type='submit' value='Send'/>" |
| 3468 "</FORM>" | 3468 "</FORM>" |
| 3469 "<FORM action='http://abc.com' method='post'>" | 3469 "<FORM action='http://abc.com' method='post'>" |
| 3470 " <INPUT type='text' id='apple'/>" | 3470 " <INPUT type='text' id='apple'/>" |
| 3471 " <INPUT type='text' id='banana'/>" | 3471 " <INPUT type='text' id='banana'/>" |
| 3472 " <INPUT type='text' id='cantelope'/>" | 3472 " <INPUT type='text' id='cantelope'/>" |
| 3473 " <INPUT type='submit' value='Send'/>" | 3473 " <INPUT type='submit' value='Send'/>" |
| 3474 "</FORM>", | 3474 "</FORM>", |
| 3475 false); | 3475 false); |
| 3476 } | 3476 } |
| 3477 | 3477 |
| 3478 TEST_F(FormAutofillTest, DISABLED_FillFormEmptyFormNamesForUnownedForm) { | 3478 TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) { |
| 3479 TestFillFormEmptyFormNames( | 3479 TestFillFormEmptyFormNames( |
| 3480 "<INPUT type='text' id='firstname'/>" | 3480 "<INPUT type='text' id='firstname'/>" |
| 3481 "<INPUT type='text' id='middlename'/>" | 3481 "<INPUT type='text' id='middlename'/>" |
| 3482 "<INPUT type='text' id='lastname'/>" | 3482 "<INPUT type='text' id='lastname'/>" |
| 3483 "<INPUT type='text' id='apple'/>" | 3483 "<INPUT type='text' id='apple'/>" |
| 3484 "<INPUT type='text' id='banana'/>" | 3484 "<INPUT type='text' id='banana'/>" |
| 3485 "<INPUT type='text' id='cantelope'/>" | 3485 "<INPUT type='text' id='cantelope'/>" |
| 3486 "<INPUT type='submit' value='Send'/>", | 3486 "<INPUT type='submit' value='Send'/>", |
| 3487 true); | 3487 true); |
| 3488 } | 3488 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3624 TestFillFormNonEmptyField( | 3624 TestFillFormNonEmptyField( |
| 3625 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3625 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3626 " <INPUT type='text' id='firstname'/>" | 3626 " <INPUT type='text' id='firstname'/>" |
| 3627 " <INPUT type='text' id='lastname'/>" | 3627 " <INPUT type='text' id='lastname'/>" |
| 3628 " <INPUT type='text' id='email'/>" | 3628 " <INPUT type='text' id='email'/>" |
| 3629 " <INPUT type='submit' value='Send'/>" | 3629 " <INPUT type='submit' value='Send'/>" |
| 3630 "</FORM>", | 3630 "</FORM>", |
| 3631 false); | 3631 false); |
| 3632 } | 3632 } |
| 3633 | 3633 |
| 3634 TEST_F(FormAutofillTest, DISABLED_FillFormNonEmptyFieldForUnownedForm) { | 3634 TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) { |
| 3635 TestFillFormNonEmptyField("<INPUT type='text' id='firstname'/>" | 3635 TestFillFormNonEmptyField("<INPUT type='text' id='firstname'/>" |
| 3636 "<INPUT type='text' id='lastname'/>" | 3636 "<INPUT type='text' id='lastname'/>" |
| 3637 "<INPUT type='text' id='email'/>" | 3637 "<INPUT type='text' id='email'/>" |
| 3638 "<INPUT type='submit' value='Send'/>", | 3638 "<INPUT type='submit' value='Send'/>", |
| 3639 true); | 3639 true); |
| 3640 } | 3640 } |
| 3641 | 3641 |
| 3642 TEST_F(FormAutofillTest, ClearFormWithNode) { | 3642 TEST_F(FormAutofillTest, ClearFormWithNode) { |
| 3643 TestClearFormWithNode( | 3643 TestClearFormWithNode( |
| 3644 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3644 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3645 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3645 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3646 " <INPUT type='text' id='lastname' value='Earp'/>" | 3646 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3647 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" | 3647 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" |
| 3648 " <INPUT type='text' id='notenabled' disabled='disabled'>" | 3648 " <INPUT type='text' id='notenabled' disabled='disabled'>" |
| 3649 " <INPUT type='month' id='month' value='2012-11'>" | 3649 " <INPUT type='month' id='month' value='2012-11'>" |
| 3650 " <INPUT type='month' id='month-disabled' value='2012-11'" | 3650 " <INPUT type='month' id='month-disabled' value='2012-11'" |
| 3651 " disabled='disabled'>" | 3651 " disabled='disabled'>" |
| 3652 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" | 3652 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" |
| 3653 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" | 3653 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" |
| 3654 " Banana!" | 3654 " Banana!" |
| 3655 " </TEXTAREA>" | 3655 " </TEXTAREA>" |
| 3656 " <TEXTAREA id='textarea-noAC' autocomplete='off'>Carrot?</TEXTAREA>" | 3656 " <TEXTAREA id='textarea-noAC' autocomplete='off'>Carrot?</TEXTAREA>" |
| 3657 " <INPUT type='submit' value='Send'/>" | 3657 " <INPUT type='submit' value='Send'/>" |
| 3658 "</FORM>", | 3658 "</FORM>", |
| 3659 false); | 3659 false); |
| 3660 } | 3660 } |
| 3661 | 3661 |
| 3662 TEST_F(FormAutofillTest, DISABLED_ClearFormWithNodeForUnownedForm) { | 3662 TEST_F(FormAutofillTest, ClearFormWithNodeForUnownedForm) { |
| 3663 TestClearFormWithNode( | 3663 TestClearFormWithNode( |
| 3664 " <!-- Indented on purpose //-->" | 3664 " <!-- Indented on purpose //-->" |
| 3665 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3665 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3666 " <INPUT type='text' id='lastname' value='Earp'/>" | 3666 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3667 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" | 3667 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" |
| 3668 " <INPUT type='text' id='notenabled' disabled='disabled'>" | 3668 " <INPUT type='text' id='notenabled' disabled='disabled'>" |
| 3669 " <INPUT type='month' id='month' value='2012-11'>" | 3669 " <INPUT type='month' id='month' value='2012-11'>" |
| 3670 " <INPUT type='month' id='month-disabled' value='2012-11'" | 3670 " <INPUT type='month' id='month-disabled' value='2012-11'" |
| 3671 " disabled='disabled'>" | 3671 " disabled='disabled'>" |
| 3672 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" | 3672 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3687 " <OPTION selected>?</OPTION>" | 3687 " <OPTION selected>?</OPTION>" |
| 3688 " <OPTION>AA</OPTION>" | 3688 " <OPTION>AA</OPTION>" |
| 3689 " <OPTION>AE</OPTION>" | 3689 " <OPTION>AE</OPTION>" |
| 3690 " <OPTION>AK</OPTION>" | 3690 " <OPTION>AK</OPTION>" |
| 3691 " </SELECT>" | 3691 " </SELECT>" |
| 3692 " <INPUT type='submit' value='Send'/>" | 3692 " <INPUT type='submit' value='Send'/>" |
| 3693 "</FORM>", | 3693 "</FORM>", |
| 3694 false); | 3694 false); |
| 3695 } | 3695 } |
| 3696 | 3696 |
| 3697 TEST_F(FormAutofillTest, | 3697 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOneForUnownedForm) { |
| 3698 DISABLED_ClearFormWithNodeContainingSelectOneForUnownedForm) { | |
| 3699 TestClearFormWithNodeContainingSelectOne( | 3698 TestClearFormWithNodeContainingSelectOne( |
| 3700 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3699 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3701 "<INPUT type='text' id='lastname' value='Earp'/>" | 3700 "<INPUT type='text' id='lastname' value='Earp'/>" |
| 3702 "<SELECT id='state' name='state'>" | 3701 "<SELECT id='state' name='state'>" |
| 3703 " <OPTION selected>?</OPTION>" | 3702 " <OPTION selected>?</OPTION>" |
| 3704 " <OPTION>AA</OPTION>" | 3703 " <OPTION>AA</OPTION>" |
| 3705 " <OPTION>AE</OPTION>" | 3704 " <OPTION>AE</OPTION>" |
| 3706 " <OPTION>AK</OPTION>" | 3705 " <OPTION>AK</OPTION>" |
| 3707 "</SELECT>" | 3706 "</SELECT>" |
| 3708 "<INPUT type='submit' value='Send'/>", | 3707 "<INPUT type='submit' value='Send'/>", |
| 3709 true); | 3708 true); |
| 3710 } | 3709 } |
| 3711 | 3710 |
| 3712 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { | 3711 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { |
| 3713 TestClearPreviewedFormWithElement( | 3712 TestClearPreviewedFormWithElement( |
| 3714 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3713 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3715 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3714 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3716 " <INPUT type='text' id='lastname'/>" | 3715 " <INPUT type='text' id='lastname'/>" |
| 3717 " <INPUT type='text' id='email'/>" | 3716 " <INPUT type='text' id='email'/>" |
| 3718 " <INPUT type='email' id='email2'/>" | 3717 " <INPUT type='email' id='email2'/>" |
| 3719 " <INPUT type='tel' id='phone'/>" | 3718 " <INPUT type='tel' id='phone'/>" |
| 3720 " <INPUT type='submit' value='Send'/>" | 3719 " <INPUT type='submit' value='Send'/>" |
| 3721 "</FORM>"); | 3720 "</FORM>"); |
| 3722 } | 3721 } |
| 3723 | 3722 |
| 3724 TEST_F(FormAutofillTest, DISABLED_ClearPreviewedFormWithElementForUnownedForm) { | 3723 TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { |
| 3725 TestClearPreviewedFormWithElement( | 3724 TestClearPreviewedFormWithElement( |
| 3726 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3725 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3727 "<INPUT type='text' id='lastname'/>" | 3726 "<INPUT type='text' id='lastname'/>" |
| 3728 "<INPUT type='text' id='email'/>" | 3727 "<INPUT type='text' id='email'/>" |
| 3729 "<INPUT type='email' id='email2'/>" | 3728 "<INPUT type='email' id='email2'/>" |
| 3730 "<INPUT type='tel' id='phone'/>" | 3729 "<INPUT type='tel' id='phone'/>" |
| 3731 "<INPUT type='submit' value='Send'/>"); | 3730 "<INPUT type='submit' value='Send'/>"); |
| 3732 } | 3731 } |
| 3733 | 3732 |
| 3734 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { | 3733 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { |
| 3735 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3734 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
| 3736 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3735 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3737 " <INPUT type='text' id='firstname' value='W'/>" | 3736 " <INPUT type='text' id='firstname' value='W'/>" |
| 3738 " <INPUT type='text' id='lastname'/>" | 3737 " <INPUT type='text' id='lastname'/>" |
| 3739 " <INPUT type='text' id='email'/>" | 3738 " <INPUT type='text' id='email'/>" |
| 3740 " <INPUT type='email' id='email2'/>" | 3739 " <INPUT type='email' id='email2'/>" |
| 3741 " <INPUT type='tel' id='phone'/>" | 3740 " <INPUT type='tel' id='phone'/>" |
| 3742 " <INPUT type='submit' value='Send'/>" | 3741 " <INPUT type='submit' value='Send'/>" |
| 3743 "</FORM>"); | 3742 "</FORM>"); |
| 3744 } | 3743 } |
| 3745 | 3744 |
| 3746 TEST_F(FormAutofillTest, | 3745 TEST_F(FormAutofillTest, |
| 3747 DISABLED_ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { | 3746 ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { |
| 3748 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3747 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
| 3749 "<INPUT type='text' id='firstname' value='W'/>" | 3748 "<INPUT type='text' id='firstname' value='W'/>" |
| 3750 "<INPUT type='text' id='lastname'/>" | 3749 "<INPUT type='text' id='lastname'/>" |
| 3751 "<INPUT type='text' id='email'/>" | 3750 "<INPUT type='text' id='email'/>" |
| 3752 "<INPUT type='email' id='email2'/>" | 3751 "<INPUT type='email' id='email2'/>" |
| 3753 "<INPUT type='tel' id='phone'/>" | 3752 "<INPUT type='tel' id='phone'/>" |
| 3754 "<INPUT type='submit' value='Send'/>"); | 3753 "<INPUT type='submit' value='Send'/>"); |
| 3755 } | 3754 } |
| 3756 | 3755 |
| 3757 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { | 3756 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { |
| 3758 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3757 TestClearPreviewedFormWithAutofilledInitiatingNode( |
| 3759 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3758 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3760 " <INPUT type='text' id='firstname' value='W'/>" | 3759 " <INPUT type='text' id='firstname' value='W'/>" |
| 3761 " <INPUT type='text' id='lastname'/>" | 3760 " <INPUT type='text' id='lastname'/>" |
| 3762 " <INPUT type='text' id='email'/>" | 3761 " <INPUT type='text' id='email'/>" |
| 3763 " <INPUT type='email' id='email2'/>" | 3762 " <INPUT type='email' id='email2'/>" |
| 3764 " <INPUT type='tel' id='phone'/>" | 3763 " <INPUT type='tel' id='phone'/>" |
| 3765 " <INPUT type='submit' value='Send'/>" | 3764 " <INPUT type='submit' value='Send'/>" |
| 3766 "</FORM>"); | 3765 "</FORM>"); |
| 3767 } | 3766 } |
| 3768 | 3767 |
| 3769 TEST_F(FormAutofillTest, | 3768 TEST_F(FormAutofillTest, |
| 3770 DISABLED_ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { | 3769 ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { |
| 3771 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3770 TestClearPreviewedFormWithAutofilledInitiatingNode( |
| 3772 "<INPUT type='text' id='firstname' value='W'/>" | 3771 "<INPUT type='text' id='firstname' value='W'/>" |
| 3773 "<INPUT type='text' id='lastname'/>" | 3772 "<INPUT type='text' id='lastname'/>" |
| 3774 "<INPUT type='text' id='email'/>" | 3773 "<INPUT type='text' id='email'/>" |
| 3775 "<INPUT type='email' id='email2'/>" | 3774 "<INPUT type='email' id='email2'/>" |
| 3776 "<INPUT type='tel' id='phone'/>" | 3775 "<INPUT type='tel' id='phone'/>" |
| 3777 "<INPUT type='submit' value='Send'/>"); | 3776 "<INPUT type='submit' value='Send'/>"); |
| 3778 } | 3777 } |
| 3779 | 3778 |
| 3780 // Autofill's "Clear Form" should clear only autofilled fields | 3779 // Autofill's "Clear Form" should clear only autofilled fields |
| 3781 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { | 3780 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { |
| 3782 TestClearOnlyAutofilledFields( | 3781 TestClearOnlyAutofilledFields( |
| 3783 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3782 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3784 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3783 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3785 " <INPUT type='text' id='lastname' value='Earp'/>" | 3784 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3786 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3785 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" |
| 3787 " <INPUT type='tel' id='phone' value='650-777-9999'/>" | 3786 " <INPUT type='tel' id='phone' value='650-777-9999'/>" |
| 3788 " <INPUT type='submit' value='Send'/>" | 3787 " <INPUT type='submit' value='Send'/>" |
| 3789 "</FORM>"); | 3788 "</FORM>"); |
| 3790 } | 3789 } |
| 3791 | 3790 |
| 3792 TEST_F(FormAutofillTest, DISABLED_ClearOnlyAutofilledFieldsForUnownedForm) { | 3791 TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) { |
| 3793 TestClearOnlyAutofilledFields( | 3792 TestClearOnlyAutofilledFields( |
| 3794 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3793 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3795 "<INPUT type='text' id='lastname' value='Earp'/>" | 3794 "<INPUT type='text' id='lastname' value='Earp'/>" |
| 3796 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3795 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" |
| 3797 "<INPUT type='tel' id='phone' value='650-777-9999'/>" | 3796 "<INPUT type='tel' id='phone' value='650-777-9999'/>" |
| 3798 "<INPUT type='submit' value='Send'/>"); | 3797 "<INPUT type='submit' value='Send'/>"); |
| 3799 } | 3798 } |
| 3800 | 3799 |
| 3801 // If we have multiple labels per id, the labels concatenated into label string. | 3800 // If we have multiple labels per id, the labels concatenated into label string. |
| 3802 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { | 3801 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3941 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3940 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 3942 | 3941 |
| 3943 expected.name = ASCIIToUTF16("country"); | 3942 expected.name = ASCIIToUTF16("country"); |
| 3944 expected.value = ASCIIToUTF16("AL"); | 3943 expected.value = ASCIIToUTF16("AL"); |
| 3945 expected.form_control_type = "select-one"; | 3944 expected.form_control_type = "select-one"; |
| 3946 expected.max_length = 0; | 3945 expected.max_length = 0; |
| 3947 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3946 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3948 } | 3947 } |
| 3949 | 3948 |
| 3950 TEST_F(FormAutofillTest, | 3949 TEST_F(FormAutofillTest, |
| 3951 DISABLED_UnownedFormElementsAndFieldSetsToFormDataFieldsets) { | 3950 UnownedFormElementsAndFieldSetsToFormDataFieldsets) { |
| 3952 std::vector<WebElement> fieldsets; | 3951 std::vector<WebElement> fieldsets; |
| 3953 std::vector<WebFormControlElement> control_elements; | 3952 std::vector<WebFormControlElement> control_elements; |
| 3954 | 3953 |
| 3955 const ExtractMask extract_mask = | 3954 const ExtractMask extract_mask = |
| 3956 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 3955 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 3957 const GURL dummy_origin("http://www.example.com"); | 3956 const GURL dummy_origin("http://www.example.com"); |
| 3958 | 3957 |
| 3959 LoadHTML("<DIV>" | 3958 LoadHTML("<DIV>" |
| 3960 " <FIELDSET>" | 3959 " <FIELDSET>" |
| 3961 " <LABEL for='firstname'>First name:</LABEL>" | 3960 " <LABEL for='firstname'>First name:</LABEL>" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4003 expected.label = ASCIIToUTF16("Last name:"); | 4002 expected.label = ASCIIToUTF16("Last name:"); |
| 4004 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 4003 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 4005 | 4004 |
| 4006 expected.name = ASCIIToUTF16("email"); | 4005 expected.name = ASCIIToUTF16("email"); |
| 4007 expected.value = ASCIIToUTF16("john@example.com"); | 4006 expected.value = ASCIIToUTF16("john@example.com"); |
| 4008 expected.label = ASCIIToUTF16("Email:"); | 4007 expected.label = ASCIIToUTF16("Email:"); |
| 4009 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 4008 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 4010 } | 4009 } |
| 4011 | 4010 |
| 4012 TEST_F(FormAutofillTest, | 4011 TEST_F(FormAutofillTest, |
| 4013 DISABLED_UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldse
t) { | 4012 UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { |
| 4014 std::vector<WebElement> fieldsets; | 4013 std::vector<WebElement> fieldsets; |
| 4015 std::vector<WebFormControlElement> control_elements; | 4014 std::vector<WebFormControlElement> control_elements; |
| 4016 | 4015 |
| 4017 const ExtractMask extract_mask = | 4016 const ExtractMask extract_mask = |
| 4018 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 4017 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 4019 const GURL dummy_origin("http://www.example.com"); | 4018 const GURL dummy_origin("http://www.example.com"); |
| 4020 | 4019 |
| 4021 LoadHTML("<DIV>" | 4020 LoadHTML("<DIV>" |
| 4022 " <FIELDSET>" | 4021 " <FIELDSET>" |
| 4023 " <LABEL for='firstname'>First name:</LABEL>" | 4022 " <LABEL for='firstname'>First name:</LABEL>" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4062 expected.value = ASCIIToUTF16("Smith"); | 4061 expected.value = ASCIIToUTF16("Smith"); |
| 4063 expected.label = ASCIIToUTF16("Last name:"); | 4062 expected.label = ASCIIToUTF16("Last name:"); |
| 4064 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 4063 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 4065 | 4064 |
| 4066 expected.name = ASCIIToUTF16("email"); | 4065 expected.name = ASCIIToUTF16("email"); |
| 4067 expected.value = ASCIIToUTF16("john@example.com"); | 4066 expected.value = ASCIIToUTF16("john@example.com"); |
| 4068 expected.label = ASCIIToUTF16("Email:"); | 4067 expected.label = ASCIIToUTF16("Email:"); |
| 4069 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 4068 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 4070 } | 4069 } |
| 4071 | 4070 |
| 4072 TEST_F(FormAutofillTest, | 4071 TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) { |
| 4073 DISABLED_UnownedFormElementsAndFieldSetsToFormDataWithForm) { | |
| 4074 std::vector<WebElement> fieldsets; | 4072 std::vector<WebElement> fieldsets; |
| 4075 std::vector<WebFormControlElement> control_elements; | 4073 std::vector<WebFormControlElement> control_elements; |
| 4076 | 4074 |
| 4077 const ExtractMask extract_mask = | 4075 const ExtractMask extract_mask = |
| 4078 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 4076 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 4079 const GURL dummy_origin("http://www.example.com"); | 4077 const GURL dummy_origin("http://www.example.com"); |
| 4080 | 4078 |
| 4081 LoadHTML(kFormHtml); | 4079 LoadHTML(kFormHtml); |
| 4082 | 4080 |
| 4083 WebFrame* frame = GetMainFrame(); | 4081 WebFrame* frame = GetMainFrame(); |
| 4084 ASSERT_NE(nullptr, frame); | 4082 ASSERT_NE(nullptr, frame); |
| 4085 | 4083 |
| 4086 control_elements = GetUnownedAutofillableFormFieldElements( | 4084 control_elements = GetUnownedAutofillableFormFieldElements( |
| 4087 frame->document().all(), &fieldsets); | 4085 frame->document().all(), &fieldsets); |
| 4088 ASSERT_TRUE(control_elements.empty()); | 4086 ASSERT_TRUE(control_elements.empty()); |
| 4089 ASSERT_TRUE(fieldsets.empty()); | 4087 ASSERT_TRUE(fieldsets.empty()); |
| 4090 | 4088 |
| 4091 FormData form; | 4089 FormData form; |
| 4092 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( | 4090 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( |
| 4093 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, | 4091 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, |
| 4094 extract_mask, &form, nullptr)); | 4092 extract_mask, &form, nullptr)); |
| 4095 } | 4093 } |
| 4096 | 4094 |
| 4097 } // namespace autofill | 4095 } // namespace autofill |
| OLD | NEW |