Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 1955963002: [Autofill] Send events to fields being autofilled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added focus check Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/content/renderer/form_autofill_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 " <input id=\"user\" type=\"text\" name=\"name\"" 96 " <input id=\"user\" type=\"text\" name=\"name\""
97 "onfocus=\"domAutomationController.send(true)\">" 97 "onfocus=\"domAutomationController.send(true)\">"
98 "<br>" 98 "<br>"
99 "<label for=\"password\">Password:</label>" 99 "<label for=\"password\">Password:</label>"
100 " <input id=\"password\" type=\"password\" name=\"password\"" 100 " <input id=\"password\" type=\"password\" name=\"password\""
101 "onfocus=\"domAutomationController.send(true)\">" 101 "onfocus=\"domAutomationController.send(true)\">"
102 "<br>" 102 "<br>"
103 "<input type=\"submit\" value=\"Submit\">" 103 "<input type=\"submit\" value=\"Submit\">"
104 "</form>"; 104 "</form>";
105 105
106 // TODO(crbug.com/609861): Remove the autocomplete attribute from the textarea
107 // field when the bug is fixed.
108 static const char kTestEventFormString[] =
109 "<script type=\"text/javascript\">"
110 "var inputfocus = false;"
111 "var inputkeydown = false;"
112 "var inputinput = false;"
113 "var inputchange = false;"
114 "var inputkeyup = false;"
115 "var inputblur = false;"
116 "var textfocus = false;"
117 "var textkeydown = false;"
118 "var textinput= false;"
119 "var textchange = false;"
120 "var textkeyup = false;"
121 "var textblur = false;"
122 "var selectfocus = false;"
123 "var selectinput = false;"
124 "var selectchange = false;"
125 "var selectblur = false;"
126 "</script>"
127 "<form action=\"http://www.example.com/\" method=\"POST\">"
128 "<label for=\"firstname\">First name:</label>"
129 " <input type=\"text\" id=\"firstname\""
130 " onfocus=\"domAutomationController.send(true)\"><br>"
131 "<label for=\"lastname\">Last name:</label>"
132 " <input type=\"text\" id=\"lastname\""
133 " onfocus=\"inputfocus = true\" onkeydown=\"inputkeydown = true\""
134 " oninput=\"inputinput = true\" onchange=\"inputchange = true\""
135 " onkeyup=\"inputkeyup = true\" onblur=\"inputblur = true\" ><br>"
136 "<label for=\"address1\">Address line 1:</label>"
137 " <input type=\"text\" id=\"address1\"><br>"
138 "<label for=\"address2\">Address line 2:</label>"
139 " <input type=\"text\" id=\"address2\"><br>"
140 "<label for=\"city\">City:</label>"
141 " <textarea rows=\"4\" cols=\"50\" id=\"city\" name=\"city\""
142 " autocomplete=\"address-level2\" onfocus=\"textfocus = true\""
143 " onkeydown=\"textkeydown = true\" oninput=\"textinput = true\""
144 " onchange=\"textchange = true\" onkeyup=\"textkeyup = true\""
145 " onblur=\"textblur = true\"></textarea><br>"
146 "<label for=\"state\">State:</label>"
147 " <select id=\"state\""
148 " onfocus=\"selectfocus = true\" oninput=\"selectinput = true\""
149 " onchange=\"selectchange = true\" onblur=\"selectblur = true\" >"
150 " <option value=\"\" selected=\"yes\">--</option>"
151 " <option value=\"CA\">California</option>"
152 " <option value=\"TX\">Texas</option>"
153 " </select><br>"
154 "<label for=\"zip\">ZIP code:</label>"
155 " <input type=\"text\" id=\"zip\"><br>"
156 "<label for=\"country\">Country:</label>"
157 " <select id=\"country\">"
158 " <option value=\"\" selected=\"yes\">--</option>"
159 " <option value=\"CA\">Canada</option>"
160 " <option value=\"US\">United States</option>"
161 " </select><br>"
162 "<label for=\"phone\">Phone number:</label>"
163 " <input type=\"text\" id=\"phone\"><br>"
164 "</form>";
165
106 // AutofillManagerTestDelegateImpl -------------------------------------------- 166 // AutofillManagerTestDelegateImpl --------------------------------------------
107 167
108 class AutofillManagerTestDelegateImpl 168 class AutofillManagerTestDelegateImpl
109 : public autofill::AutofillManagerTestDelegate { 169 : public autofill::AutofillManagerTestDelegate {
110 public: 170 public:
111 AutofillManagerTestDelegateImpl() 171 AutofillManagerTestDelegateImpl()
112 : waiting_for_text_change_(false) {} 172 : waiting_for_text_change_(false) {}
113 ~AutofillManagerTestDelegateImpl() override {} 173 ~AutofillManagerTestDelegateImpl() override {}
114 174
115 // autofill::AutofillManagerTestDelegate: 175 // autofill::AutofillManagerTestDelegate:
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1233
1174 // Reload the page. 1234 // Reload the page.
1175 content::WebContents* web_contents = GetWebContents(); 1235 content::WebContents* web_contents = GetWebContents();
1176 web_contents->GetController().Reload(false); 1236 web_contents->GetController().Reload(false);
1177 content::WaitForLoadStop(web_contents); 1237 content::WaitForLoadStop(web_contents);
1178 1238
1179 // Invoke Autofill. 1239 // Invoke Autofill.
1180 TryBasicFormFill(); 1240 TryBasicFormFill();
1181 } 1241 }
1182 1242
1243 // Test that filling a form sends all the expected events to the different
1244 // fields being filled.
1245 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillEvents) {
1246 CreateTestProfile();
1247
1248 // Load the test page.
1249 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
1250 browser(), GURL(std::string(kDataURIPrefix) + kTestEventFormString)));
1251
1252 // Invoke Autofill.
1253 TryBasicFormFill();
1254
1255 // Checks that all the events were fired for the input field.
1256 bool input_focus_triggered;
1257 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1258 GetRenderViewHost(), "domAutomationController.send(inputfocus);",
1259 &input_focus_triggered));
1260 EXPECT_TRUE(input_focus_triggered);
1261 bool input_keydown_triggered;
1262 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1263 GetRenderViewHost(), "domAutomationController.send(inputkeydown);",
1264 &input_keydown_triggered));
1265 EXPECT_TRUE(input_keydown_triggered);
1266 bool input_input_triggered;
1267 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1268 GetRenderViewHost(), "domAutomationController.send(inputinput);",
1269 &input_input_triggered));
1270 EXPECT_TRUE(input_input_triggered);
1271 bool input_change_triggered;
1272 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1273 GetRenderViewHost(), "domAutomationController.send(inputchange);",
1274 &input_change_triggered));
1275 EXPECT_TRUE(input_change_triggered);
1276 bool input_keyup_triggered;
1277 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1278 GetRenderViewHost(), "domAutomationController.send(inputkeyup);",
1279 &input_keyup_triggered));
1280 EXPECT_TRUE(input_keyup_triggered);
1281 bool input_blur_triggered;
1282 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1283 GetRenderViewHost(), "domAutomationController.send(inputblur);",
1284 &input_blur_triggered));
1285 EXPECT_TRUE(input_blur_triggered);
1286
1287 // Checks that all the events were fired for the textarea field.
1288 bool text_focus_triggered;
1289 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1290 GetRenderViewHost(), "domAutomationController.send(textfocus);",
1291 &text_focus_triggered));
1292 EXPECT_TRUE(text_focus_triggered);
1293 bool text_keydown_triggered;
1294 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1295 GetRenderViewHost(), "domAutomationController.send(textkeydown);",
1296 &text_keydown_triggered));
1297 EXPECT_TRUE(text_keydown_triggered);
1298 bool text_input_triggered;
1299 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1300 GetRenderViewHost(), "domAutomationController.send(textinput);",
1301 &text_input_triggered));
1302 EXPECT_TRUE(text_input_triggered);
1303 bool text_change_triggered;
1304 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1305 GetRenderViewHost(), "domAutomationController.send(textchange);",
1306 &text_change_triggered));
1307 EXPECT_TRUE(text_change_triggered);
1308 bool text_keyup_triggered;
1309 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1310 GetRenderViewHost(), "domAutomationController.send(textkeyup);",
1311 &text_keyup_triggered));
1312 EXPECT_TRUE(text_keyup_triggered);
1313 bool text_blur_triggered;
1314 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1315 GetRenderViewHost(), "domAutomationController.send(textblur);",
1316 &text_blur_triggered));
1317 EXPECT_TRUE(text_blur_triggered);
1318
1319 // Checks that all the events were fired for the select field.
1320 bool select_focus_triggered;
1321 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1322 GetRenderViewHost(), "domAutomationController.send(selectfocus);",
1323 &select_focus_triggered));
1324 EXPECT_TRUE(select_focus_triggered);
1325 bool select_input_triggered;
1326 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1327 GetRenderViewHost(), "domAutomationController.send(selectinput);",
1328 &select_input_triggered));
1329 EXPECT_TRUE(select_input_triggered);
1330 bool select_change_triggered;
1331 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1332 GetRenderViewHost(), "domAutomationController.send(selectchange);",
1333 &select_change_triggered));
1334 EXPECT_TRUE(select_change_triggered);
1335 bool select_blur_triggered;
1336 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1337 GetRenderViewHost(), "domAutomationController.send(selectblur);",
1338 &select_blur_triggered));
1339 EXPECT_TRUE(select_blur_triggered);
1340 }
1341
1183 // Test fails on Linux ASAN, see http://crbug.com/532737 1342 // Test fails on Linux ASAN, see http://crbug.com/532737
1184 #if defined(ADDRESS_SANITIZER) 1343 #if defined(ADDRESS_SANITIZER)
1185 #define MAYBE_AutofillAfterTranslate DISABLED_AutofillAfterTranslate 1344 #define MAYBE_AutofillAfterTranslate DISABLED_AutofillAfterTranslate
1186 #else 1345 #else
1187 #define MAYBE_AutofillAfterTranslate AutofillAfterTranslate 1346 #define MAYBE_AutofillAfterTranslate AutofillAfterTranslate
1188 #endif // ADDRESS_SANITIZER 1347 #endif // ADDRESS_SANITIZER
1189 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillAfterTranslate) { 1348 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, MAYBE_AutofillAfterTranslate) {
1190 // TODO(groby): Remove once the bubble is enabled by default everywhere. 1349 // TODO(groby): Remove once the bubble is enabled by default everywhere.
1191 // http://crbug.com/507442 1350 // http://crbug.com/507442
1192 #if defined(OS_MACOSX) 1351 #if defined(OS_MACOSX)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 1677 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
1519 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); 1678 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString)));
1520 ASSERT_TRUE(content::ExecuteScript( 1679 ASSERT_TRUE(content::ExecuteScript(
1521 GetRenderViewHost(), 1680 GetRenderViewHost(),
1522 "document.getElementById('user').value = 'user';")); 1681 "document.getElementById('user').value = 'user';"));
1523 FocusFieldByName("password"); 1682 FocusFieldByName("password");
1524 PasteStringAndWait("foobar"); 1683 PasteStringAndWait("foobar");
1525 } 1684 }
1526 1685
1527 } // namespace autofill 1686 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/form_autofill_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698