| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // key press event callback. It is necessary to have this sinkbecause if no | 462 // key press event callback. It is necessary to have this sinkbecause if no |
| 463 // key press event callback handles the event (at least on Mac), a DCHECK | 463 // key press event callback handles the event (at least on Mac), a DCHECK |
| 464 // ends up going off that the |event| doesn't have an |os_event| associated | 464 // ends up going off that the |event| doesn't have an |os_event| associated |
| 465 // with it. | 465 // with it. |
| 466 content::RenderWidgetHost::KeyPressEventCallback key_press_event_sink_; | 466 content::RenderWidgetHost::KeyPressEventCallback key_press_event_sink_; |
| 467 | 467 |
| 468 DISALLOW_COPY_AND_ASSIGN(AutofillInteractiveTest); | 468 DISALLOW_COPY_AND_ASSIGN(AutofillInteractiveTest); |
| 469 }; | 469 }; |
| 470 | 470 |
| 471 // Test that basic form fill is working. | 471 // Test that basic form fill is working. |
| 472 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, BasicFormFill) { | 472 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 473 #if defined(OS_CHROMEOS) |
| 474 #define MAYBE_BasicFormFill DISABLED_BasicFormFill |
| 475 #else |
| 476 #define MAYBE_BasicFormFill BasicFormFill |
| 477 #endif |
| 478 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_BasicFormFill) { |
| 473 CreateTestProfile(); | 479 CreateTestProfile(); |
| 474 | 480 |
| 475 // Load the test page. | 481 // Load the test page. |
| 476 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 482 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 477 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 483 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
| 478 | 484 |
| 479 // Invoke Autofill. | 485 // Invoke Autofill. |
| 480 TryBasicFormFill(); | 486 TryBasicFormFill(); |
| 481 } | 487 } |
| 482 | 488 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 SendKeyToPageAndWait(ui::VKEY_DOWN); | 685 SendKeyToPageAndWait(ui::VKEY_DOWN); |
| 680 SendKeyToDataListPopup(ui::VKEY_DOWN); | 686 SendKeyToDataListPopup(ui::VKEY_DOWN); |
| 681 SendKeyToDataListPopup(ui::VKEY_RETURN); | 687 SendKeyToDataListPopup(ui::VKEY_RETURN); |
| 682 ExpectFieldValue("firstname", "Adam"); | 688 ExpectFieldValue("firstname", "Adam"); |
| 683 std::string color; | 689 std::string color; |
| 684 GetFieldBackgroundColor("firstname", &color); | 690 GetFieldBackgroundColor("firstname", &color); |
| 685 EXPECT_EQ(color, orginalcolor); | 691 EXPECT_EQ(color, orginalcolor); |
| 686 } | 692 } |
| 687 | 693 |
| 688 // Test that a JavaScript oninput event is fired after auto-filling a form. | 694 // Test that a JavaScript oninput event is fired after auto-filling a form. |
| 689 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) { | 695 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 696 #if defined(OS_CHROMEOS) |
| 697 #define MAYBE_OnInputAfterAutofill DISABLED_OnInputAfterAutofill |
| 698 #else |
| 699 #define MAYBE_OnInputAfterAutofill OnInputAfterAutofill |
| 700 #endif |
| 701 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_OnInputAfterAutofill) { |
| 690 CreateTestProfile(); | 702 CreateTestProfile(); |
| 691 | 703 |
| 692 const char kOnInputScript[] = | 704 const char kOnInputScript[] = |
| 693 "<script>" | 705 "<script>" |
| 694 "focused_fired = false;" | 706 "focused_fired = false;" |
| 695 "unfocused_fired = false;" | 707 "unfocused_fired = false;" |
| 696 "changed_select_fired = false;" | 708 "changed_select_fired = false;" |
| 697 "unchanged_select_fired = false;" | 709 "unchanged_select_fired = false;" |
| 698 "document.getElementById('firstname').oninput = function() {" | 710 "document.getElementById('firstname').oninput = function() {" |
| 699 " focused_fired = true;" | 711 " focused_fired = true;" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 840 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 829 GetRenderViewHost(), | 841 GetRenderViewHost(), |
| 830 "domAutomationController.send(unchanged_select_fired);", | 842 "domAutomationController.send(unchanged_select_fired);", |
| 831 &unchanged_select_fired)); | 843 &unchanged_select_fired)); |
| 832 EXPECT_TRUE(focused_fired); | 844 EXPECT_TRUE(focused_fired); |
| 833 EXPECT_TRUE(unfocused_fired); | 845 EXPECT_TRUE(unfocused_fired); |
| 834 EXPECT_TRUE(changed_select_fired); | 846 EXPECT_TRUE(changed_select_fired); |
| 835 EXPECT_FALSE(unchanged_select_fired); | 847 EXPECT_FALSE(unchanged_select_fired); |
| 836 } | 848 } |
| 837 | 849 |
| 838 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, InputFiresBeforeChange) { | 850 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 851 #if defined(OS_CHROMEOS) |
| 852 #define MAYBE_InputFiresBeforeChange DISABLED_InputFiresBeforeChange |
| 853 #else |
| 854 #define MAYBE_InputFiresBeforeChange InputFiresBeforeChange |
| 855 #endif |
| 856 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_InputFiresBeforeChange) { |
| 839 CreateTestProfile(); | 857 CreateTestProfile(); |
| 840 | 858 |
| 841 const char kInputFiresBeforeChangeScript[] = | 859 const char kInputFiresBeforeChangeScript[] = |
| 842 "<script>" | 860 "<script>" |
| 843 "inputElementEvents = [];" | 861 "inputElementEvents = [];" |
| 844 "function recordInputElementEvent(e) {" | 862 "function recordInputElementEvent(e) {" |
| 845 " if (e.target.tagName != 'INPUT') throw 'only <input> tags allowed';" | 863 " if (e.target.tagName != 'INPUT') throw 'only <input> tags allowed';" |
| 846 " inputElementEvents.push(e.type);" | 864 " inputElementEvents.push(e.type);" |
| 847 "}" | 865 "}" |
| 848 "selectElementEvents = [];" | 866 "selectElementEvents = [];" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL))); | 957 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL))); |
| 940 | 958 |
| 941 // Invoke Autofill. | 959 // Invoke Autofill. |
| 942 TryBasicFormFill(); | 960 TryBasicFormFill(); |
| 943 } | 961 } |
| 944 | 962 |
| 945 // Test that we properly autofill forms with repeated fields. | 963 // Test that we properly autofill forms with repeated fields. |
| 946 // In the wild, the repeated fields are typically either email fields | 964 // In the wild, the repeated fields are typically either email fields |
| 947 // (duplicated for "confirmation"); or variants that are hot-swapped via | 965 // (duplicated for "confirmation"); or variants that are hot-swapped via |
| 948 // JavaScript, with only one actually visible at any given time. | 966 // JavaScript, with only one actually visible at any given time. |
| 949 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillFormWithRepeatedField) { | 967 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 968 #if defined(OS_CHROMEOS) |
| 969 #define MAYBE_AutofillFormWithRepeatedField \ |
| 970 DISABLED_AutofillFormWithRepeatedField |
| 971 #else |
| 972 #define MAYBE_AutofillFormWithRepeatedField AutofillFormWithRepeatedField |
| 973 #endif |
| 974 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 975 MAYBE_AutofillFormWithRepeatedField) { |
| 950 CreateTestProfile(); | 976 CreateTestProfile(); |
| 951 | 977 |
| 952 // Load the test page. | 978 // Load the test page. |
| 953 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 979 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 954 GURL(std::string(kDataURIPrefix) + | 980 GURL(std::string(kDataURIPrefix) + |
| 955 "<form action=\"http://www.example.com/\" method=\"POST\">" | 981 "<form action=\"http://www.example.com/\" method=\"POST\">" |
| 956 "<label for=\"firstname\">First name:</label>" | 982 "<label for=\"firstname\">First name:</label>" |
| 957 " <input type=\"text\" id=\"firstname\"" | 983 " <input type=\"text\" id=\"firstname\"" |
| 958 " onfocus=\"domAutomationController.send(true)\"><br>" | 984 " onfocus=\"domAutomationController.send(true)\"><br>" |
| 959 "<label for=\"lastname\">Last name:</label>" | 985 "<label for=\"lastname\">Last name:</label>" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 ExpectFieldValue("PHONE_HOME_NUMBER_3-2", "555"); | 1295 ExpectFieldValue("PHONE_HOME_NUMBER_3-2", "555"); |
| 1270 ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567"); | 1296 ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567"); |
| 1271 ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567"); | 1297 ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567"); |
| 1272 ExpectFieldValue("PHONE_HOME_EXT-1", std::string()); | 1298 ExpectFieldValue("PHONE_HOME_EXT-1", std::string()); |
| 1273 ExpectFieldValue("PHONE_HOME_EXT-2", std::string()); | 1299 ExpectFieldValue("PHONE_HOME_EXT-2", std::string()); |
| 1274 ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1"); | 1300 ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1"); |
| 1275 } | 1301 } |
| 1276 | 1302 |
| 1277 // Test that Autofill does not fill in read-only fields. | 1303 // Test that Autofill does not fill in read-only fields. |
| 1278 // Flaky on the official cros-trunk. crbug.com/516052 | 1304 // Flaky on the official cros-trunk. crbug.com/516052 |
| 1279 #if defined(OFFICIAL_BUILD) | 1305 // Also flaky on ChromiumOS generally. crbug.com/585885 |
| 1306 #if defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) |
| 1280 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields | 1307 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields |
| 1281 #else | 1308 #else |
| 1282 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields | 1309 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields |
| 1283 #endif // defined(OFFICIAL_BUILD) | 1310 #endif // defined(OFFICIAL_BUILD) || defined(OS_CHROMEOS) |
| 1284 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1311 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1285 MAYBE_NoAutofillForReadOnlyFields) { | 1312 MAYBE_NoAutofillForReadOnlyFields) { |
| 1286 std::string addr_line1("1234 H St."); | 1313 std::string addr_line1("1234 H St."); |
| 1287 | 1314 |
| 1288 AutofillProfile profile; | 1315 AutofillProfile profile; |
| 1289 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob")); | 1316 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob")); |
| 1290 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); | 1317 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); |
| 1291 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("bsmith@gmail.com")); | 1318 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("bsmith@gmail.com")); |
| 1292 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16(addr_line1)); | 1319 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16(addr_line1)); |
| 1293 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose")); | 1320 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose")); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 ASSERT_TRUE(content::ExecuteScript( | 1460 ASSERT_TRUE(content::ExecuteScript( |
| 1434 GetRenderViewHost(), | 1461 GetRenderViewHost(), |
| 1435 "document.getElementById('testform').submit();")); | 1462 "document.getElementById('testform').submit();")); |
| 1436 // This will ensure the test didn't hang. | 1463 // This will ensure the test didn't hang. |
| 1437 load_stop_observer.Wait(); | 1464 load_stop_observer.Wait(); |
| 1438 } | 1465 } |
| 1439 | 1466 |
| 1440 // Test that Chrome doesn't crash when autocomplete is disabled while the user | 1467 // Test that Chrome doesn't crash when autocomplete is disabled while the user |
| 1441 // is interacting with the form. This is a regression test for | 1468 // is interacting with the form. This is a regression test for |
| 1442 // http://crbug.com/160476 | 1469 // http://crbug.com/160476 |
| 1470 // Flakily times out on ChromeOS http://crbug.com/585885 |
| 1471 #if defined(OS_CHROMEOS) |
| 1472 #define MAYBE_DisableAutocompleteWhileFilling \ |
| 1473 DISABLED_DisableAutocompleteWhileFilling |
| 1474 #else |
| 1475 #define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling |
| 1476 #endif |
| 1443 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1477 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
| 1444 DisableAutocompleteWhileFilling) { | 1478 MAYBE_DisableAutocompleteWhileFilling) { |
| 1445 CreateTestProfile(); | 1479 CreateTestProfile(); |
| 1446 | 1480 |
| 1447 // Load the test page. | 1481 // Load the test page. |
| 1448 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1482 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 1449 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 1483 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
| 1450 | 1484 |
| 1451 // Invoke Autofill: Start filling the first name field with "M" and wait for | 1485 // Invoke Autofill: Start filling the first name field with "M" and wait for |
| 1452 // the popup to be shown. | 1486 // the popup to be shown. |
| 1453 FocusFirstNameField(); | 1487 FocusFirstNameField(); |
| 1454 SendKeyToPageAndWait(ui::VKEY_M); | 1488 SendKeyToPageAndWait(ui::VKEY_M); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1469 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1503 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 1470 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); | 1504 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); |
| 1471 ASSERT_TRUE(content::ExecuteScript( | 1505 ASSERT_TRUE(content::ExecuteScript( |
| 1472 GetRenderViewHost(), | 1506 GetRenderViewHost(), |
| 1473 "document.getElementById('user').value = 'user';")); | 1507 "document.getElementById('user').value = 'user';")); |
| 1474 FocusFieldByName("password"); | 1508 FocusFieldByName("password"); |
| 1475 PasteStringAndWait("foobar"); | 1509 PasteStringAndWait("foobar"); |
| 1476 } | 1510 } |
| 1477 | 1511 |
| 1478 } // namespace autofill | 1512 } // namespace autofill |
| OLD | NEW |