| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); | 640 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); |
| 641 | 641 |
| 642 // Press tab to accept the autofill suggestions. | 642 // Press tab to accept the autofill suggestions. |
| 643 SendKeyToPopupAndWait(ui::DomKey::TAB); | 643 SendKeyToPopupAndWait(ui::DomKey::TAB); |
| 644 | 644 |
| 645 // The form should be filled. | 645 // The form should be filled. |
| 646 ExpectFilledTestForm(); | 646 ExpectFilledTestForm(); |
| 647 } | 647 } |
| 648 | 648 |
| 649 // crbug.com/516052 | 649 // crbug.com/516052 |
| 650 #if defined(OS_CHROMEOS) | 650 // Flaky on Windows http://crbug.com/728488 |
| 651 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 651 #define MAYBE_AutofillViaClick DISABLED_AutofillViaClick | 652 #define MAYBE_AutofillViaClick DISABLED_AutofillViaClick |
| 652 #else | 653 #else |
| 653 #define MAYBE_AutofillViaClick AutofillViaClick | 654 #define MAYBE_AutofillViaClick AutofillViaClick |
| 654 #endif | 655 #endif |
| 655 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillViaClick) { | 656 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillViaClick) { |
| 656 CreateTestProfile(); | 657 CreateTestProfile(); |
| 657 | 658 |
| 658 // Load the test page. | 659 // Load the test page. |
| 659 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 660 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
| 660 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); | 661 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 671 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); | 672 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); |
| 672 | 673 |
| 673 // Press Enter to accept the autofill suggestions. | 674 // Press Enter to accept the autofill suggestions. |
| 674 SendKeyToPopupAndWait(ui::DomKey::ENTER); | 675 SendKeyToPopupAndWait(ui::DomKey::ENTER); |
| 675 | 676 |
| 676 // The form should be filled. | 677 // The form should be filled. |
| 677 ExpectFilledTestForm(); | 678 ExpectFilledTestForm(); |
| 678 } | 679 } |
| 679 | 680 |
| 680 // Makes sure that the first click does *not* activate the popup. | 681 // Makes sure that the first click does *not* activate the popup. |
| 681 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForFirstClick) { | 682 // Flaky on Windows http://crbug.com/728488 |
| 683 #if defined(OS_WIN) |
| 684 #define MAYBE_DontAutofillForFirstClick DISABLED_DontAutofillForFirstClick |
| 685 #else |
| 686 #define MAYBE_DontAutofillForFirstClick DontAutofillForFirstClick |
| 687 #endif |
| 688 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 689 MAYBE_DontAutofillForFirstClick) { |
| 682 CreateTestProfile(); | 690 CreateTestProfile(); |
| 683 | 691 |
| 684 // Load the test page. | 692 // Load the test page. |
| 685 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 693 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
| 686 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); | 694 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); |
| 687 | 695 |
| 688 // Click the first name field while it's out of focus, then twiddle our thumbs | 696 // Click the first name field while it's out of focus, then twiddle our thumbs |
| 689 // a bit. If a popup were to show, it would hit the asserts in | 697 // a bit. If a popup were to show, it would hit the asserts in |
| 690 // AutofillManagerTestDelegateImpl while we're wasting time. | 698 // AutofillManagerTestDelegateImpl while we're wasting time. |
| 691 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 699 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
| 692 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); | 700 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); |
| 693 | 701 |
| 694 // The second click should activate the popup since the first click focused | 702 // The second click should activate the popup since the first click focused |
| 695 // the field. | 703 // the field. |
| 696 test_delegate()->Reset(); | 704 test_delegate()->Reset(); |
| 697 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 705 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
| 698 test_delegate()->Wait(); | 706 test_delegate()->Wait(); |
| 699 } | 707 } |
| 700 | 708 |
| 701 // Makes sure that clicking outside the focused field doesn't activate | 709 // Makes sure that clicking outside the focused field doesn't activate |
| 702 // the popup. | 710 // the popup. |
| 703 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForOutsideClick) { | 711 // Flaky on Windows http://crbug.com/728488 |
| 712 #if defined(OS_WIN) |
| 713 #define MAYBE_DontAutofillForOutsideClick DISABLED_DontAutofillForOutsideClick |
| 714 #else |
| 715 #define MAYBE_DontAutofillForOutsideClick DontAutofillForOutsideClick |
| 716 #endif |
| 717 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 718 MAYBE_DontAutofillForOutsideClick) { |
| 704 CreateTestProfile(); | 719 CreateTestProfile(); |
| 705 | 720 |
| 706 // Load the test page. | 721 // Load the test page. |
| 707 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 722 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
| 708 browser(), | 723 browser(), |
| 709 GURL(std::string(kDataURIPrefix) + kTestFormString + | 724 GURL(std::string(kDataURIPrefix) + kTestFormString + |
| 710 "<button disabled id='disabled-button'>Cant click this</button>"))); | 725 "<button disabled id='disabled-button'>Cant click this</button>"))); |
| 711 | 726 |
| 712 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); | 727 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); |
| 713 | 728 |
| 714 // Clicking a disabled button will generate a mouse event but focus doesn't | 729 // Clicking a disabled button will generate a mouse event but focus doesn't |
| 715 // change. This tests that autofill can handle a mouse event outside a focused | 730 // change. This tests that autofill can handle a mouse event outside a focused |
| 716 // input *without* showing the popup. | 731 // input *without* showing the popup. |
| 717 ASSERT_NO_FATAL_FAILURE(ClickElementWithId("disabled-button")); | 732 ASSERT_NO_FATAL_FAILURE(ClickElementWithId("disabled-button")); |
| 718 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); | 733 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); |
| 719 | 734 |
| 720 test_delegate()->Reset(); | 735 test_delegate()->Reset(); |
| 721 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 736 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
| 722 test_delegate()->Wait(); | 737 test_delegate()->Wait(); |
| 723 } | 738 } |
| 724 | 739 |
| 725 // Test that a field is still autofillable after the previously autofilled | 740 // Test that a field is still autofillable after the previously autofilled |
| 726 // value is deleted. | 741 // value is deleted. |
| 727 // TODO(crbug.com/603488) Test is timing out flakily on CrOS. | 742 // TODO(crbug.com/603488) Test is timing out flakily on CrOS. |
| 728 #if defined(OS_CHROMEOS) | 743 // Flaky on Windows http://crbug.com/728488 |
| 744 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 729 #define MAYBE_OnDeleteValueAfterAutofill DISABLED_OnDeleteValueAfterAutofill | 745 #define MAYBE_OnDeleteValueAfterAutofill DISABLED_OnDeleteValueAfterAutofill |
| 730 #else | 746 #else |
| 731 #define MAYBE_OnDeleteValueAfterAutofill OnDeleteValueAfterAutofill | 747 #define MAYBE_OnDeleteValueAfterAutofill OnDeleteValueAfterAutofill |
| 732 #endif | 748 #endif |
| 733 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 749 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 734 MAYBE_OnDeleteValueAfterAutofill) { | 750 MAYBE_OnDeleteValueAfterAutofill) { |
| 735 CreateTestProfile(); | 751 CreateTestProfile(); |
| 736 | 752 |
| 737 // Load the test page. | 753 // Load the test page. |
| 738 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 754 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 GetRenderViewHost(), | 970 GetRenderViewHost(), |
| 955 "domAutomationController.send(unchanged_select_fired);", | 971 "domAutomationController.send(unchanged_select_fired);", |
| 956 &unchanged_select_fired)); | 972 &unchanged_select_fired)); |
| 957 EXPECT_TRUE(focused_fired); | 973 EXPECT_TRUE(focused_fired); |
| 958 EXPECT_TRUE(unfocused_fired); | 974 EXPECT_TRUE(unfocused_fired); |
| 959 EXPECT_TRUE(changed_select_fired); | 975 EXPECT_TRUE(changed_select_fired); |
| 960 EXPECT_FALSE(unchanged_select_fired); | 976 EXPECT_FALSE(unchanged_select_fired); |
| 961 } | 977 } |
| 962 | 978 |
| 963 // Flakily times out on ChromeOS http://crbug.com/585885 | 979 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 964 #if defined(OS_CHROMEOS) | 980 // Flaky on Windows http://crbug.com/728488 |
| 981 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 965 #define MAYBE_InputFiresBeforeChange DISABLED_InputFiresBeforeChange | 982 #define MAYBE_InputFiresBeforeChange DISABLED_InputFiresBeforeChange |
| 966 #else | 983 #else |
| 967 #define MAYBE_InputFiresBeforeChange InputFiresBeforeChange | 984 #define MAYBE_InputFiresBeforeChange InputFiresBeforeChange |
| 968 #endif | 985 #endif |
| 969 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_InputFiresBeforeChange) { | 986 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_InputFiresBeforeChange) { |
| 970 CreateTestProfile(); | 987 CreateTestProfile(); |
| 971 | 988 |
| 972 const char kInputFiresBeforeChangeScript[] = | 989 const char kInputFiresBeforeChangeScript[] = |
| 973 "<script>" | 990 "<script>" |
| 974 "inputElementEvents = [];" | 991 "inputElementEvents = [];" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 "<label for=\"phone\">Phone number:</label>" | 1144 "<label for=\"phone\">Phone number:</label>" |
| 1128 " <input type=\"text\" id=\"phone\"><br>" | 1145 " <input type=\"text\" id=\"phone\"><br>" |
| 1129 "</form>"))); | 1146 "</form>"))); |
| 1130 | 1147 |
| 1131 // Invoke Autofill. | 1148 // Invoke Autofill. |
| 1132 TryBasicFormFill(); | 1149 TryBasicFormFill(); |
| 1133 ExpectFieldValue("state_freeform", std::string()); | 1150 ExpectFieldValue("state_freeform", std::string()); |
| 1134 } | 1151 } |
| 1135 | 1152 |
| 1136 // TODO(crbug.com/603488) Test is timing out flakily on CrOS. | 1153 // TODO(crbug.com/603488) Test is timing out flakily on CrOS. |
| 1137 #if defined(OS_CHROMEOS) | 1154 // Flaky on Windows http://crbug.com/728488 |
| 1155 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1138 #define MAYBE_AutofillFormWithNonAutofillableField \ | 1156 #define MAYBE_AutofillFormWithNonAutofillableField \ |
| 1139 DISABLED_AutofillFormWithNonAutofillableField | 1157 DISABLED_AutofillFormWithNonAutofillableField |
| 1140 #else | 1158 #else |
| 1141 #define MAYBE_AutofillFormWithNonAutofillableField \ | 1159 #define MAYBE_AutofillFormWithNonAutofillableField \ |
| 1142 AutofillFormWithNonAutofillableField | 1160 AutofillFormWithNonAutofillableField |
| 1143 #endif | 1161 #endif |
| 1144 // Test that we properly autofill forms with non-autofillable fields. | 1162 // Test that we properly autofill forms with non-autofillable fields. |
| 1145 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1163 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1146 MAYBE_AutofillFormWithNonAutofillableField) { | 1164 MAYBE_AutofillFormWithNonAutofillableField) { |
| 1147 CreateTestProfile(); | 1165 CreateTestProfile(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 web_contents->GetController().Reload(content::ReloadType::NORMAL, false); | 1317 web_contents->GetController().Reload(content::ReloadType::NORMAL, false); |
| 1300 content::WaitForLoadStop(web_contents); | 1318 content::WaitForLoadStop(web_contents); |
| 1301 | 1319 |
| 1302 // Invoke Autofill. | 1320 // Invoke Autofill. |
| 1303 TryBasicFormFill(); | 1321 TryBasicFormFill(); |
| 1304 } | 1322 } |
| 1305 | 1323 |
| 1306 // Test that filling a form sends all the expected events to the different | 1324 // Test that filling a form sends all the expected events to the different |
| 1307 // fields being filled. | 1325 // fields being filled. |
| 1308 // Flakily fails on ChromeOS (crbug.com/646576). | 1326 // Flakily fails on ChromeOS (crbug.com/646576). |
| 1309 #if defined(OS_CHROMEOS) | 1327 // Flaky on Windows http://crbug.com/728488 |
| 1328 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1310 #define MAYBE_AutofillEvents DISABLED_AutofillEvents | 1329 #define MAYBE_AutofillEvents DISABLED_AutofillEvents |
| 1311 #else | 1330 #else |
| 1312 #define MAYBE_AutofillEvents AutofillEvents | 1331 #define MAYBE_AutofillEvents AutofillEvents |
| 1313 #endif | 1332 #endif |
| 1314 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillEvents) { | 1333 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillEvents) { |
| 1315 CreateTestProfile(); | 1334 CreateTestProfile(); |
| 1316 | 1335 |
| 1317 // Load the test page. | 1336 // Load the test page. |
| 1318 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 1337 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
| 1319 browser(), GURL(std::string(kDataURIPrefix) + kTestEventFormString))); | 1338 browser(), GURL(std::string(kDataURIPrefix) + kTestEventFormString))); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 GetRenderViewHost(), | 1724 GetRenderViewHost(), |
| 1706 "document.getElementById('testform').submit();")); | 1725 "document.getElementById('testform').submit();")); |
| 1707 // This will ensure the test didn't hang. | 1726 // This will ensure the test didn't hang. |
| 1708 load_stop_observer.Wait(); | 1727 load_stop_observer.Wait(); |
| 1709 } | 1728 } |
| 1710 | 1729 |
| 1711 // Test that Chrome doesn't crash when autocomplete is disabled while the user | 1730 // Test that Chrome doesn't crash when autocomplete is disabled while the user |
| 1712 // is interacting with the form. This is a regression test for | 1731 // is interacting with the form. This is a regression test for |
| 1713 // http://crbug.com/160476 | 1732 // http://crbug.com/160476 |
| 1714 // Flakily times out on ChromeOS http://crbug.com/585885 | 1733 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 1715 #if defined(OS_CHROMEOS) | 1734 // Flaky on Windows http://crbug.com/728488 |
| 1735 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1716 #define MAYBE_DisableAutocompleteWhileFilling \ | 1736 #define MAYBE_DisableAutocompleteWhileFilling \ |
| 1717 DISABLED_DisableAutocompleteWhileFilling | 1737 DISABLED_DisableAutocompleteWhileFilling |
| 1718 #else | 1738 #else |
| 1719 #define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling | 1739 #define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling |
| 1720 #endif | 1740 #endif |
| 1721 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1741 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1722 MAYBE_DisableAutocompleteWhileFilling) { | 1742 MAYBE_DisableAutocompleteWhileFilling) { |
| 1723 CreateTestProfile(); | 1743 CreateTestProfile(); |
| 1724 | 1744 |
| 1725 // Load the test page. | 1745 // Load the test page. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 1853 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 1834 cross_frame, | 1854 cross_frame, |
| 1835 "window.domAutomationController.send(" | 1855 "window.domAutomationController.send(" |
| 1836 " document.getElementById('NAME_FIRST').value);", | 1856 " document.getElementById('NAME_FIRST').value);", |
| 1837 &value)); | 1857 &value)); |
| 1838 EXPECT_EQ("Milton", value); | 1858 EXPECT_EQ("Milton", value); |
| 1839 } | 1859 } |
| 1840 | 1860 |
| 1841 // This test verifies that credit card (payment card list) popup works when the | 1861 // This test verifies that credit card (payment card list) popup works when the |
| 1842 // form is inside an OOPIF. | 1862 // form is inside an OOPIF. |
| 1843 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, CrossSitePaymentForms) { | 1863 // Flaky on Windows http://crbug.com/728488 |
| 1844 | 1864 #if defined(OS_WIN) |
| 1865 #define MAYBE_CrossSitePaymentForms DISABLED_MAYBE_CrossSitePaymentForms |
| 1866 #else |
| 1867 #define MAYBE_CrossSitePaymentForms CrossSitePaymentForms |
| 1868 #endif |
| 1869 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_CrossSitePaymentForms) { |
| 1845 // Main frame is on a.com, iframe is on b.com. | 1870 // Main frame is on a.com, iframe is on b.com. |
| 1846 GURL url = embedded_test_server()->GetURL( | 1871 GURL url = embedded_test_server()->GetURL( |
| 1847 "a.com", "/autofill/cross_origin_iframe.html"); | 1872 "a.com", "/autofill/cross_origin_iframe.html"); |
| 1848 ui_test_utils::NavigateToURL(browser(), url); | 1873 ui_test_utils::NavigateToURL(browser(), url); |
| 1849 GURL iframe_url = embedded_test_server()->GetURL( | 1874 GURL iframe_url = embedded_test_server()->GetURL( |
| 1850 "b.com", "/autofill/autofill_creditcard_form.html"); | 1875 "b.com", "/autofill/autofill_creditcard_form.html"); |
| 1851 EXPECT_TRUE( | 1876 EXPECT_TRUE( |
| 1852 content::NavigateIframeToURL(GetWebContents(), "crossFrame", iframe_url)); | 1877 content::NavigateIframeToURL(GetWebContents(), "crossFrame", iframe_url)); |
| 1853 | 1878 |
| 1854 // Let |test_delegate()| also observe autofill events in the iframe. | 1879 // Let |test_delegate()| also observe autofill events in the iframe. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1866 std::string script_focus( | 1891 std::string script_focus( |
| 1867 "window.focus();" | 1892 "window.focus();" |
| 1868 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); | 1893 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); |
| 1869 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); | 1894 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); |
| 1870 | 1895 |
| 1871 // Send an arrow dow keypress in order to trigger the autofill popup. | 1896 // Send an arrow dow keypress in order to trigger the autofill popup. |
| 1872 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); | 1897 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); |
| 1873 } | 1898 } |
| 1874 | 1899 |
| 1875 } // namespace autofill | 1900 } // namespace autofill |
| OLD | NEW |