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, FindFormForInputElementForUnownedForm) { | 2396 TEST_F(FormAutofillTest, DISABLED_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, FindFormForTextAreaElementForUnownedForm) { | 2423 TEST_F(FormAutofillTest, DISABLED_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, FillFormForUnownedForm) { | 2442 TEST_F(FormAutofillTest, DISABLED_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, PreviewFormForUnownedForm) { | 2534 TEST_F(FormAutofillTest, DISABLED_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, FillFormMaxLengthForUnownedForm) { | 3409 TEST_F(FormAutofillTest, DISABLED_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, FillFormNegativeMaxLengthForUnownedForm) { | 3432 TEST_F(FormAutofillTest, DISABLED_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, FillFormEmptyNameForUnownedForm) { | 3452 TEST_F(FormAutofillTest, DISABLED_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, FillFormEmptyFormNamesForUnownedForm) { | 3478 TEST_F(FormAutofillTest, DISABLED_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, FillFormNonEmptyFieldForUnownedForm) { | 3634 TEST_F(FormAutofillTest, DISABLED_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, ClearFormWithNodeForUnownedForm) { | 3662 TEST_F(FormAutofillTest, DISABLED_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, ClearFormWithNodeContainingSelectOneForUnownedForm) { | 3697 TEST_F(FormAutofillTest, |
| 3698 DISABLED_ClearFormWithNodeContainingSelectOneForUnownedForm) { |
3698 TestClearFormWithNodeContainingSelectOne( | 3699 TestClearFormWithNodeContainingSelectOne( |
3699 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3700 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
3700 "<INPUT type='text' id='lastname' value='Earp'/>" | 3701 "<INPUT type='text' id='lastname' value='Earp'/>" |
3701 "<SELECT id='state' name='state'>" | 3702 "<SELECT id='state' name='state'>" |
3702 " <OPTION selected>?</OPTION>" | 3703 " <OPTION selected>?</OPTION>" |
3703 " <OPTION>AA</OPTION>" | 3704 " <OPTION>AA</OPTION>" |
3704 " <OPTION>AE</OPTION>" | 3705 " <OPTION>AE</OPTION>" |
3705 " <OPTION>AK</OPTION>" | 3706 " <OPTION>AK</OPTION>" |
3706 "</SELECT>" | 3707 "</SELECT>" |
3707 "<INPUT type='submit' value='Send'/>", | 3708 "<INPUT type='submit' value='Send'/>", |
3708 true); | 3709 true); |
3709 } | 3710 } |
3710 | 3711 |
3711 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { | 3712 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { |
3712 TestClearPreviewedFormWithElement( | 3713 TestClearPreviewedFormWithElement( |
3713 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3714 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
3714 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3715 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
3715 " <INPUT type='text' id='lastname'/>" | 3716 " <INPUT type='text' id='lastname'/>" |
3716 " <INPUT type='text' id='email'/>" | 3717 " <INPUT type='text' id='email'/>" |
3717 " <INPUT type='email' id='email2'/>" | 3718 " <INPUT type='email' id='email2'/>" |
3718 " <INPUT type='tel' id='phone'/>" | 3719 " <INPUT type='tel' id='phone'/>" |
3719 " <INPUT type='submit' value='Send'/>" | 3720 " <INPUT type='submit' value='Send'/>" |
3720 "</FORM>"); | 3721 "</FORM>"); |
3721 } | 3722 } |
3722 | 3723 |
3723 TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { | 3724 TEST_F(FormAutofillTest, DISABLED_ClearPreviewedFormWithElementForUnownedForm) { |
3724 TestClearPreviewedFormWithElement( | 3725 TestClearPreviewedFormWithElement( |
3725 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3726 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
3726 "<INPUT type='text' id='lastname'/>" | 3727 "<INPUT type='text' id='lastname'/>" |
3727 "<INPUT type='text' id='email'/>" | 3728 "<INPUT type='text' id='email'/>" |
3728 "<INPUT type='email' id='email2'/>" | 3729 "<INPUT type='email' id='email2'/>" |
3729 "<INPUT type='tel' id='phone'/>" | 3730 "<INPUT type='tel' id='phone'/>" |
3730 "<INPUT type='submit' value='Send'/>"); | 3731 "<INPUT type='submit' value='Send'/>"); |
3731 } | 3732 } |
3732 | 3733 |
3733 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { | 3734 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { |
3734 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3735 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
3735 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3736 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
3736 " <INPUT type='text' id='firstname' value='W'/>" | 3737 " <INPUT type='text' id='firstname' value='W'/>" |
3737 " <INPUT type='text' id='lastname'/>" | 3738 " <INPUT type='text' id='lastname'/>" |
3738 " <INPUT type='text' id='email'/>" | 3739 " <INPUT type='text' id='email'/>" |
3739 " <INPUT type='email' id='email2'/>" | 3740 " <INPUT type='email' id='email2'/>" |
3740 " <INPUT type='tel' id='phone'/>" | 3741 " <INPUT type='tel' id='phone'/>" |
3741 " <INPUT type='submit' value='Send'/>" | 3742 " <INPUT type='submit' value='Send'/>" |
3742 "</FORM>"); | 3743 "</FORM>"); |
3743 } | 3744 } |
3744 | 3745 |
3745 TEST_F(FormAutofillTest, | 3746 TEST_F(FormAutofillTest, |
3746 ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { | 3747 DISABLED_ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { |
3747 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3748 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
3748 "<INPUT type='text' id='firstname' value='W'/>" | 3749 "<INPUT type='text' id='firstname' value='W'/>" |
3749 "<INPUT type='text' id='lastname'/>" | 3750 "<INPUT type='text' id='lastname'/>" |
3750 "<INPUT type='text' id='email'/>" | 3751 "<INPUT type='text' id='email'/>" |
3751 "<INPUT type='email' id='email2'/>" | 3752 "<INPUT type='email' id='email2'/>" |
3752 "<INPUT type='tel' id='phone'/>" | 3753 "<INPUT type='tel' id='phone'/>" |
3753 "<INPUT type='submit' value='Send'/>"); | 3754 "<INPUT type='submit' value='Send'/>"); |
3754 } | 3755 } |
3755 | 3756 |
3756 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { | 3757 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { |
3757 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3758 TestClearPreviewedFormWithAutofilledInitiatingNode( |
3758 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3759 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
3759 " <INPUT type='text' id='firstname' value='W'/>" | 3760 " <INPUT type='text' id='firstname' value='W'/>" |
3760 " <INPUT type='text' id='lastname'/>" | 3761 " <INPUT type='text' id='lastname'/>" |
3761 " <INPUT type='text' id='email'/>" | 3762 " <INPUT type='text' id='email'/>" |
3762 " <INPUT type='email' id='email2'/>" | 3763 " <INPUT type='email' id='email2'/>" |
3763 " <INPUT type='tel' id='phone'/>" | 3764 " <INPUT type='tel' id='phone'/>" |
3764 " <INPUT type='submit' value='Send'/>" | 3765 " <INPUT type='submit' value='Send'/>" |
3765 "</FORM>"); | 3766 "</FORM>"); |
3766 } | 3767 } |
3767 | 3768 |
3768 TEST_F(FormAutofillTest, | 3769 TEST_F(FormAutofillTest, |
3769 ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { | 3770 DISABLED_ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { |
3770 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3771 TestClearPreviewedFormWithAutofilledInitiatingNode( |
3771 "<INPUT type='text' id='firstname' value='W'/>" | 3772 "<INPUT type='text' id='firstname' value='W'/>" |
3772 "<INPUT type='text' id='lastname'/>" | 3773 "<INPUT type='text' id='lastname'/>" |
3773 "<INPUT type='text' id='email'/>" | 3774 "<INPUT type='text' id='email'/>" |
3774 "<INPUT type='email' id='email2'/>" | 3775 "<INPUT type='email' id='email2'/>" |
3775 "<INPUT type='tel' id='phone'/>" | 3776 "<INPUT type='tel' id='phone'/>" |
3776 "<INPUT type='submit' value='Send'/>"); | 3777 "<INPUT type='submit' value='Send'/>"); |
3777 } | 3778 } |
3778 | 3779 |
3779 // Autofill's "Clear Form" should clear only autofilled fields | 3780 // Autofill's "Clear Form" should clear only autofilled fields |
3780 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { | 3781 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { |
3781 TestClearOnlyAutofilledFields( | 3782 TestClearOnlyAutofilledFields( |
3782 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3783 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
3783 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3784 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
3784 " <INPUT type='text' id='lastname' value='Earp'/>" | 3785 " <INPUT type='text' id='lastname' value='Earp'/>" |
3785 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3786 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" |
3786 " <INPUT type='tel' id='phone' value='650-777-9999'/>" | 3787 " <INPUT type='tel' id='phone' value='650-777-9999'/>" |
3787 " <INPUT type='submit' value='Send'/>" | 3788 " <INPUT type='submit' value='Send'/>" |
3788 "</FORM>"); | 3789 "</FORM>"); |
3789 } | 3790 } |
3790 | 3791 |
3791 TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) { | 3792 TEST_F(FormAutofillTest, DISABLED_ClearOnlyAutofilledFieldsForUnownedForm) { |
3792 TestClearOnlyAutofilledFields( | 3793 TestClearOnlyAutofilledFields( |
3793 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3794 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
3794 "<INPUT type='text' id='lastname' value='Earp'/>" | 3795 "<INPUT type='text' id='lastname' value='Earp'/>" |
3795 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3796 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" |
3796 "<INPUT type='tel' id='phone' value='650-777-9999'/>" | 3797 "<INPUT type='tel' id='phone' value='650-777-9999'/>" |
3797 "<INPUT type='submit' value='Send'/>"); | 3798 "<INPUT type='submit' value='Send'/>"); |
3798 } | 3799 } |
3799 | 3800 |
3800 // If we have multiple labels per id, the labels concatenated into label string. | 3801 // If we have multiple labels per id, the labels concatenated into label string. |
3801 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { | 3802 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3940 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3941 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
3941 | 3942 |
3942 expected.name = ASCIIToUTF16("country"); | 3943 expected.name = ASCIIToUTF16("country"); |
3943 expected.value = ASCIIToUTF16("AL"); | 3944 expected.value = ASCIIToUTF16("AL"); |
3944 expected.form_control_type = "select-one"; | 3945 expected.form_control_type = "select-one"; |
3945 expected.max_length = 0; | 3946 expected.max_length = 0; |
3946 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3947 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
3947 } | 3948 } |
3948 | 3949 |
3949 TEST_F(FormAutofillTest, | 3950 TEST_F(FormAutofillTest, |
3950 UnownedFormElementsAndFieldSetsToFormDataFieldsets) { | 3951 DISABLED_UnownedFormElementsAndFieldSetsToFormDataFieldsets) { |
3951 std::vector<WebElement> fieldsets; | 3952 std::vector<WebElement> fieldsets; |
3952 std::vector<WebFormControlElement> control_elements; | 3953 std::vector<WebFormControlElement> control_elements; |
3953 | 3954 |
3954 const ExtractMask extract_mask = | 3955 const ExtractMask extract_mask = |
3955 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 3956 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
3956 const GURL dummy_origin("http://www.example.com"); | 3957 const GURL dummy_origin("http://www.example.com"); |
3957 | 3958 |
3958 LoadHTML("<DIV>" | 3959 LoadHTML("<DIV>" |
3959 " <FIELDSET>" | 3960 " <FIELDSET>" |
3960 " <LABEL for='firstname'>First name:</LABEL>" | 3961 " <LABEL for='firstname'>First name:</LABEL>" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4002 expected.label = ASCIIToUTF16("Last name:"); | 4003 expected.label = ASCIIToUTF16("Last name:"); |
4003 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 4004 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
4004 | 4005 |
4005 expected.name = ASCIIToUTF16("email"); | 4006 expected.name = ASCIIToUTF16("email"); |
4006 expected.value = ASCIIToUTF16("john@example.com"); | 4007 expected.value = ASCIIToUTF16("john@example.com"); |
4007 expected.label = ASCIIToUTF16("Email:"); | 4008 expected.label = ASCIIToUTF16("Email:"); |
4008 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 4009 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
4009 } | 4010 } |
4010 | 4011 |
4011 TEST_F(FormAutofillTest, | 4012 TEST_F(FormAutofillTest, |
4012 UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { | 4013 DISABLED_UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldse
t) { |
4013 std::vector<WebElement> fieldsets; | 4014 std::vector<WebElement> fieldsets; |
4014 std::vector<WebFormControlElement> control_elements; | 4015 std::vector<WebFormControlElement> control_elements; |
4015 | 4016 |
4016 const ExtractMask extract_mask = | 4017 const ExtractMask extract_mask = |
4017 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 4018 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
4018 const GURL dummy_origin("http://www.example.com"); | 4019 const GURL dummy_origin("http://www.example.com"); |
4019 | 4020 |
4020 LoadHTML("<DIV>" | 4021 LoadHTML("<DIV>" |
4021 " <FIELDSET>" | 4022 " <FIELDSET>" |
4022 " <LABEL for='firstname'>First name:</LABEL>" | 4023 " <LABEL for='firstname'>First name:</LABEL>" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 expected.value = ASCIIToUTF16("Smith"); | 4062 expected.value = ASCIIToUTF16("Smith"); |
4062 expected.label = ASCIIToUTF16("Last name:"); | 4063 expected.label = ASCIIToUTF16("Last name:"); |
4063 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 4064 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
4064 | 4065 |
4065 expected.name = ASCIIToUTF16("email"); | 4066 expected.name = ASCIIToUTF16("email"); |
4066 expected.value = ASCIIToUTF16("john@example.com"); | 4067 expected.value = ASCIIToUTF16("john@example.com"); |
4067 expected.label = ASCIIToUTF16("Email:"); | 4068 expected.label = ASCIIToUTF16("Email:"); |
4068 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 4069 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
4069 } | 4070 } |
4070 | 4071 |
4071 TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) { | 4072 TEST_F(FormAutofillTest, |
| 4073 DISABLED_UnownedFormElementsAndFieldSetsToFormDataWithForm) { |
4072 std::vector<WebElement> fieldsets; | 4074 std::vector<WebElement> fieldsets; |
4073 std::vector<WebFormControlElement> control_elements; | 4075 std::vector<WebFormControlElement> control_elements; |
4074 | 4076 |
4075 const ExtractMask extract_mask = | 4077 const ExtractMask extract_mask = |
4076 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 4078 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
4077 const GURL dummy_origin("http://www.example.com"); | 4079 const GURL dummy_origin("http://www.example.com"); |
4078 | 4080 |
4079 LoadHTML(kFormHtml); | 4081 LoadHTML(kFormHtml); |
4080 | 4082 |
4081 WebFrame* frame = GetMainFrame(); | 4083 WebFrame* frame = GetMainFrame(); |
4082 ASSERT_NE(nullptr, frame); | 4084 ASSERT_NE(nullptr, frame); |
4083 | 4085 |
4084 control_elements = GetUnownedAutofillableFormFieldElements( | 4086 control_elements = GetUnownedAutofillableFormFieldElements( |
4085 frame->document().all(), &fieldsets); | 4087 frame->document().all(), &fieldsets); |
4086 ASSERT_TRUE(control_elements.empty()); | 4088 ASSERT_TRUE(control_elements.empty()); |
4087 ASSERT_TRUE(fieldsets.empty()); | 4089 ASSERT_TRUE(fieldsets.empty()); |
4088 | 4090 |
4089 FormData form; | 4091 FormData form; |
4090 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( | 4092 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( |
4091 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, | 4093 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, |
4092 extract_mask, &form, nullptr)); | 4094 extract_mask, &form, nullptr)); |
4093 } | 4095 } |
4094 | 4096 |
4095 } // namespace autofill | 4097 } // namespace autofill |
OLD | NEW |