| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 SendKeyToDataListPopup(ui::DomKey::ARROW_DOWN); | 795 SendKeyToDataListPopup(ui::DomKey::ARROW_DOWN); |
| 796 SendKeyToDataListPopup(ui::DomKey::ENTER); | 796 SendKeyToDataListPopup(ui::DomKey::ENTER); |
| 797 ExpectFieldValue("firstname", "Adam"); | 797 ExpectFieldValue("firstname", "Adam"); |
| 798 std::string color; | 798 std::string color; |
| 799 GetFieldBackgroundColor("firstname", &color); | 799 GetFieldBackgroundColor("firstname", &color); |
| 800 EXPECT_EQ(color, orginalcolor); | 800 EXPECT_EQ(color, orginalcolor); |
| 801 } | 801 } |
| 802 | 802 |
| 803 // Test that a JavaScript oninput event is fired after auto-filling a form. | 803 // Test that a JavaScript oninput event is fired after auto-filling a form. |
| 804 // Flakily times out on ChromeOS http://crbug.com/585885 | 804 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 805 #if defined(OS_CHROMEOS) | 805 // Flaky on Windows. http://crbug.com/726659 |
| 806 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 806 #define MAYBE_OnInputAfterAutofill DISABLED_OnInputAfterAutofill | 807 #define MAYBE_OnInputAfterAutofill DISABLED_OnInputAfterAutofill |
| 807 #else | 808 #else |
| 808 #define MAYBE_OnInputAfterAutofill OnInputAfterAutofill | 809 #define MAYBE_OnInputAfterAutofill OnInputAfterAutofill |
| 809 #endif | 810 #endif |
| 810 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_OnInputAfterAutofill) { | 811 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_OnInputAfterAutofill) { |
| 811 CreateTestProfile(); | 812 CreateTestProfile(); |
| 812 | 813 |
| 813 const char kOnInputScript[] = | 814 const char kOnInputScript[] = |
| 814 "<script>" | 815 "<script>" |
| 815 "focused_fired = false;" | 816 "focused_fired = false;" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 GetRenderViewHost(), | 874 GetRenderViewHost(), |
| 874 "domAutomationController.send(unchanged_select_fired);", | 875 "domAutomationController.send(unchanged_select_fired);", |
| 875 &unchanged_select_fired)); | 876 &unchanged_select_fired)); |
| 876 EXPECT_TRUE(focused_fired); | 877 EXPECT_TRUE(focused_fired); |
| 877 EXPECT_TRUE(unfocused_fired); | 878 EXPECT_TRUE(unfocused_fired); |
| 878 EXPECT_TRUE(changed_select_fired); | 879 EXPECT_TRUE(changed_select_fired); |
| 879 EXPECT_FALSE(unchanged_select_fired); | 880 EXPECT_FALSE(unchanged_select_fired); |
| 880 } | 881 } |
| 881 | 882 |
| 882 // Test that a JavaScript onchange event is fired after auto-filling a form. | 883 // Test that a JavaScript onchange event is fired after auto-filling a form. |
| 883 // Flaky on CrOS only. http://crbug.com/578095 | 884 // Flaky on CrOS. http://crbug.com/578095 |
| 884 #if defined(OS_CHROMEOS) | 885 // Flaky on Windows. http://crbug.com/726659 |
| 886 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 885 #define MAYBE_OnChangeAfterAutofill DISABLED_OnChangeAfterAutofill | 887 #define MAYBE_OnChangeAfterAutofill DISABLED_OnChangeAfterAutofill |
| 886 #else | 888 #else |
| 887 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill | 889 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill |
| 888 #endif | 890 #endif |
| 889 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_OnChangeAfterAutofill) { | 891 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_OnChangeAfterAutofill) { |
| 890 CreateTestProfile(); | 892 CreateTestProfile(); |
| 891 | 893 |
| 892 const char kOnChangeScript[] = | 894 const char kOnChangeScript[] = |
| 893 "<script>" | 895 "<script>" |
| 894 "focused_fired = false;" | 896 "focused_fired = false;" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 1039 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 1038 GetRenderViewHost(), | 1040 GetRenderViewHost(), |
| 1039 "domAutomationController.send(selectElementEvents[1]);", | 1041 "domAutomationController.send(selectElementEvents[1]);", |
| 1040 &select_element_events[1])); | 1042 &select_element_events[1])); |
| 1041 | 1043 |
| 1042 EXPECT_EQ("input", select_element_events[0]); | 1044 EXPECT_EQ("input", select_element_events[0]); |
| 1043 EXPECT_EQ("change", select_element_events[1]); | 1045 EXPECT_EQ("change", select_element_events[1]); |
| 1044 } | 1046 } |
| 1045 | 1047 |
| 1046 // Test that we can autofill forms distinguished only by their |id| attribute. | 1048 // Test that we can autofill forms distinguished only by their |id| attribute. |
| 1047 // Flaky on CrOS only. http://crbug.com/578095 | 1049 // Flaky on CrOS. http://crbug.com/578095 |
| 1048 #if defined(OS_CHROMEOS) | 1050 // Flaky on Windows. http://crbug.com/726659 |
| 1049 #define MAYBE_AutofillFormsDistinguishedById DISABLED_AutofillFormsDistinguished
ById | 1051 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1052 #define MAYBE_AutofillFormsDistinguishedById \ |
| 1053 DISABLED_AutofillFormsDistinguishedById |
| 1050 #else | 1054 #else |
| 1051 #define MAYBE_AutofillFormsDistinguishedById AutofillFormsDistinguishedById | 1055 #define MAYBE_AutofillFormsDistinguishedById AutofillFormsDistinguishedById |
| 1052 #endif | 1056 #endif |
| 1053 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1057 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1054 MAYBE_AutofillFormsDistinguishedById) { | 1058 MAYBE_AutofillFormsDistinguishedById) { |
| 1055 CreateTestProfile(); | 1059 CreateTestProfile(); |
| 1056 | 1060 |
| 1057 // Load the test page. | 1061 // Load the test page. |
| 1058 const std::string kURL = | 1062 const std::string kURL = |
| 1059 std::string(kDataURIPrefix) + kTestFormString + | 1063 std::string(kDataURIPrefix) + kTestFormString + |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1070 | 1074 |
| 1071 // Invoke Autofill. | 1075 // Invoke Autofill. |
| 1072 TryBasicFormFill(); | 1076 TryBasicFormFill(); |
| 1073 } | 1077 } |
| 1074 | 1078 |
| 1075 // Test that we properly autofill forms with repeated fields. | 1079 // Test that we properly autofill forms with repeated fields. |
| 1076 // In the wild, the repeated fields are typically either email fields | 1080 // In the wild, the repeated fields are typically either email fields |
| 1077 // (duplicated for "confirmation"); or variants that are hot-swapped via | 1081 // (duplicated for "confirmation"); or variants that are hot-swapped via |
| 1078 // JavaScript, with only one actually visible at any given time. | 1082 // JavaScript, with only one actually visible at any given time. |
| 1079 // Flakily times out on ChromeOS http://crbug.com/585885 | 1083 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 1080 #if defined(OS_CHROMEOS) | 1084 // Flaky on Windows. http://crbug.com/726659 |
| 1085 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1081 #define MAYBE_AutofillFormWithRepeatedField \ | 1086 #define MAYBE_AutofillFormWithRepeatedField \ |
| 1082 DISABLED_AutofillFormWithRepeatedField | 1087 DISABLED_AutofillFormWithRepeatedField |
| 1083 #else | 1088 #else |
| 1084 #define MAYBE_AutofillFormWithRepeatedField AutofillFormWithRepeatedField | 1089 #define MAYBE_AutofillFormWithRepeatedField AutofillFormWithRepeatedField |
| 1085 #endif | 1090 #endif |
| 1086 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1091 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1087 MAYBE_AutofillFormWithRepeatedField) { | 1092 MAYBE_AutofillFormWithRepeatedField) { |
| 1088 CreateTestProfile(); | 1093 CreateTestProfile(); |
| 1089 | 1094 |
| 1090 // Load the test page. | 1095 // Load the test page. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 " </select><br>" | 1179 " </select><br>" |
| 1175 "<label for=\"phone\">Phone number:</label>" | 1180 "<label for=\"phone\">Phone number:</label>" |
| 1176 " <input type=\"text\" id=\"phone\"><br>" | 1181 " <input type=\"text\" id=\"phone\"><br>" |
| 1177 "</form>"))); | 1182 "</form>"))); |
| 1178 | 1183 |
| 1179 // Invoke Autofill. | 1184 // Invoke Autofill. |
| 1180 TryBasicFormFill(); | 1185 TryBasicFormFill(); |
| 1181 } | 1186 } |
| 1182 | 1187 |
| 1183 // Flakily fails on ChromeOS (crbug.com/646576). | 1188 // Flakily fails on ChromeOS (crbug.com/646576). |
| 1184 #if defined(OS_CHROMEOS) | 1189 // Flaky on Windows (crbug.com/726659). |
| 1190 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1185 #define MAYBE_DynamicFormFill DISABLED_DynamicFormFill | 1191 #define MAYBE_DynamicFormFill DISABLED_DynamicFormFill |
| 1186 #else | 1192 #else |
| 1187 #define MAYBE_DynamicFormFill DynamicFormFill | 1193 #define MAYBE_DynamicFormFill DynamicFormFill |
| 1188 #endif | 1194 #endif |
| 1189 // Test that we can Autofill dynamically generated forms. | 1195 // Test that we can Autofill dynamically generated forms. |
| 1190 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_DynamicFormFill) { | 1196 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_DynamicFormFill) { |
| 1191 CreateTestProfile(); | 1197 CreateTestProfile(); |
| 1192 | 1198 |
| 1193 // Load the test page. | 1199 // Load the test page. |
| 1194 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1200 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567"); | 1539 ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567"); |
| 1534 ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567"); | 1540 ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567"); |
| 1535 ExpectFieldValue("PHONE_HOME_EXT-1", std::string()); | 1541 ExpectFieldValue("PHONE_HOME_EXT-1", std::string()); |
| 1536 ExpectFieldValue("PHONE_HOME_EXT-2", std::string()); | 1542 ExpectFieldValue("PHONE_HOME_EXT-2", std::string()); |
| 1537 ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1"); | 1543 ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1"); |
| 1538 } | 1544 } |
| 1539 | 1545 |
| 1540 // Test that Autofill does not fill in read-only fields. | 1546 // Test that Autofill does not fill in read-only fields. |
| 1541 // Flaky on the official cros-trunk. crbug.com/516052 | 1547 // Flaky on the official cros-trunk. crbug.com/516052 |
| 1542 // Also flaky on ChromiumOS generally. crbug.com/585885 | 1548 // Also flaky on ChromiumOS generally. crbug.com/585885 |
| 1543 #if defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) | 1549 // Also flaky on Windows. crbug.com/726659 |
| 1550 #if defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) || defined(OS_WIN) |
| 1544 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields | 1551 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields |
| 1545 #else | 1552 #else |
| 1546 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields | 1553 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields |
| 1547 #endif // defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) | 1554 #endif // defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) |
| 1548 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1555 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1549 MAYBE_NoAutofillForReadOnlyFields) { | 1556 MAYBE_NoAutofillForReadOnlyFields) { |
| 1550 std::string addr_line1("1234 H St."); | 1557 std::string addr_line1("1234 H St."); |
| 1551 | 1558 |
| 1552 AutofillProfile profile; | 1559 AutofillProfile profile; |
| 1553 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob")); | 1560 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob")); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 // the active field. | 1736 // the active field. |
| 1730 ASSERT_TRUE(content::ExecuteScript( | 1737 ASSERT_TRUE(content::ExecuteScript( |
| 1731 GetRenderViewHost(), | 1738 GetRenderViewHost(), |
| 1732 "document.querySelector('input').autocomplete = 'off';")); | 1739 "document.querySelector('input').autocomplete = 'off';")); |
| 1733 | 1740 |
| 1734 // Press the down arrow to select the suggestion and attempt to preview the | 1741 // Press the down arrow to select the suggestion and attempt to preview the |
| 1735 // autofilled form. | 1742 // autofilled form. |
| 1736 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); | 1743 SendKeyToPopupAndWait(ui::DomKey::ARROW_DOWN); |
| 1737 } | 1744 } |
| 1738 | 1745 |
| 1739 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1746 // Flaky on Windows |
| 1740 PastedPasswordIsSaved) { | 1747 #if defined(OS_WIN) |
| 1748 #define MAYBE_PastedPasswordIsSaved DISABLED_PastedPasswordIsSaved |
| 1749 #else |
| 1750 #define MAYBE_PastedPasswordIsSaved PastedPasswordIsSaved |
| 1751 #endif |
| 1752 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_PastedPasswordIsSaved) { |
| 1741 // Serve test page from a HTTPS server so that Form Not Secure warnings do not | 1753 // Serve test page from a HTTPS server so that Form Not Secure warnings do not |
| 1742 // interfere with the test. | 1754 // interfere with the test. |
| 1743 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 1755 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 1744 net::SSLServerConfig ssl_config; | 1756 net::SSLServerConfig ssl_config; |
| 1745 ssl_config.client_cert_type = | 1757 ssl_config.client_cert_type = |
| 1746 net::SSLServerConfig::ClientCertType::NO_CLIENT_CERT; | 1758 net::SSLServerConfig::ClientCertType::NO_CLIENT_CERT; |
| 1747 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config); | 1759 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config); |
| 1748 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); | 1760 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 1749 ASSERT_TRUE(https_server.Start()); | 1761 ASSERT_TRUE(https_server.Start()); |
| 1750 | 1762 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 std::string script_focus( | 1866 std::string script_focus( |
| 1855 "window.focus();" | 1867 "window.focus();" |
| 1856 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); | 1868 "document.getElementById('CREDIT_CARD_NUMBER').focus();"); |
| 1857 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); | 1869 ASSERT_TRUE(content::ExecuteScript(cross_frame, script_focus)); |
| 1858 | 1870 |
| 1859 // Send an arrow dow keypress in order to trigger the autofill popup. | 1871 // Send an arrow dow keypress in order to trigger the autofill popup. |
| 1860 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); | 1872 SendKeyToPageAndWait(ui::DomKey::ARROW_DOWN); |
| 1861 } | 1873 } |
| 1862 | 1874 |
| 1863 } // namespace autofill | 1875 } // namespace autofill |
| OLD | NEW |