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

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

Issue 11728003: Change ExecuteJavaScript* helper functions in browser_test_utils.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding files for gpu_tests and NaCl browser tests. Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/automation/automation_misc_browsertest.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) 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 std::string js; 212 std::string js;
213 for (FormMap::const_iterator i = data.begin(); i != data.end(); ++i) { 213 for (FormMap::const_iterator i = data.begin(); i != data.end(); ++i) {
214 js += "document.getElementById('" + i->first + "').value = '" + 214 js += "document.getElementById('" + i->first + "').value = '" +
215 i->second + "';"; 215 i->second + "';";
216 } 216 }
217 js += "document.getElementById('testform').submit();"; 217 js += "document.getElementById('testform').submit();";
218 218
219 WindowedPersonalDataManagerObserver observer(browser()); 219 WindowedPersonalDataManagerObserver observer(browser());
220 ASSERT_TRUE( 220 ASSERT_TRUE(
221 content::ExecuteJavaScript(render_view_host(), L"", ASCIIToWide(js))); 221 content::ExecuteJavaScript(render_view_host(), "", js));
222 observer.Wait(); 222 observer.Wait();
223 } 223 }
224 224
225 void SubmitCreditCard(const char* name, 225 void SubmitCreditCard(const char* name,
226 const char* number, 226 const char* number,
227 const char* exp_month, 227 const char* exp_month,
228 const char* exp_year) { 228 const char* exp_year) {
229 FormMap data; 229 FormMap data;
230 data["CREDIT_CARD_NAME"] = name; 230 data["CREDIT_CARD_NAME"] = name;
231 data["CREDIT_CARD_NUMBER"] = number; 231 data["CREDIT_CARD_NUMBER"] = number;
232 data["CREDIT_CARD_EXP_MONTH"] = exp_month; 232 data["CREDIT_CARD_EXP_MONTH"] = exp_month;
233 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = exp_year; 233 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = exp_year;
234 FillFormAndSubmit("autofill_creditcard_form.html", data); 234 FillFormAndSubmit("autofill_creditcard_form.html", data);
235 } 235 }
236 236
237 // Populates a webpage form using autofill data and keypress events. 237 // Populates a webpage form using autofill data and keypress events.
238 // This function focuses the specified input field in the form, and then 238 // This function focuses the specified input field in the form, and then
239 // sends keypress events to the tab to cause the form to be populated. 239 // sends keypress events to the tab to cause the form to be populated.
240 void PopulateForm(const std::string& field_id) { 240 void PopulateForm(const std::string& field_id) {
241 std::string js("document.getElementById('" + field_id + "').focus();"); 241 std::string js("document.getElementById('" + field_id + "').focus();");
242 ASSERT_TRUE( 242 ASSERT_TRUE(
243 content::ExecuteJavaScript(render_view_host(), L"", ASCIIToWide(js))); 243 content::ExecuteJavaScript(render_view_host(), "", js));
244 244
245 SendKeyAndWait(ui::VKEY_DOWN, 245 SendKeyAndWait(ui::VKEY_DOWN,
246 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); 246 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
247 SendKeyAndWait(ui::VKEY_DOWN, 247 SendKeyAndWait(ui::VKEY_DOWN,
248 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); 248 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
249 SendKeyAndWait(ui::VKEY_RETURN, 249 SendKeyAndWait(ui::VKEY_RETURN,
250 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); 250 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
251 } 251 }
252 252
253 // Aggregate profiles from forms into Autofill preferences. Returns the number 253 // Aggregate profiles from forms into Autofill preferences. Returns the number
(...skipping 28 matching lines...) Expand all
282 data["ADDRESS_HOME_STATE"] = fields[8]; 282 data["ADDRESS_HOME_STATE"] = fields[8];
283 data["ADDRESS_HOME_ZIP"] = fields[9]; 283 data["ADDRESS_HOME_ZIP"] = fields[9];
284 data["ADDRESS_HOME_COUNTRY"] = fields[10]; 284 data["ADDRESS_HOME_COUNTRY"] = fields[10];
285 data["PHONE_HOME_WHOLE_NUMBER"] = fields[11]; 285 data["PHONE_HOME_WHOLE_NUMBER"] = fields[11];
286 286
287 FillFormAndSubmit("duplicate_profiles_test.html", data); 287 FillFormAndSubmit("duplicate_profiles_test.html", data);
288 } 288 }
289 return lines.size(); 289 return lines.size();
290 } 290 }
291 291
292 void ExpectFieldValue(const std::wstring& field_name, 292 void ExpectFieldValue(const std::string& field_name,
293 const std::string& expected_value) { 293 const std::string& expected_value) {
294 std::string value; 294 std::string value;
295 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( 295 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
296 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", 296 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
297 L"window.domAutomationController.send(" 297 "",
298 L"document.getElementById('" + field_name + L"').value);", &value)); 298 "window.domAutomationController.send("
299 " document.getElementById('" + field_name + "').value);",
300 &value));
299 EXPECT_EQ(expected_value, value); 301 EXPECT_EQ(expected_value, value);
300 } 302 }
301 303
302 RenderViewHost* render_view_host() { 304 RenderViewHost* render_view_host() {
303 return chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 305 return chrome::GetActiveWebContents(browser())->GetRenderViewHost();
304 } 306 }
305 307
306 void SimulateURLFetch(bool success) { 308 void SimulateURLFetch(bool success) {
307 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 309 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
308 ASSERT_TRUE(fetcher); 310 ASSERT_TRUE(fetcher);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 346 }
345 347
346 void FocusFirstNameField() { 348 void FocusFirstNameField() {
347 LOG(WARNING) << "Clicking on the tab."; 349 LOG(WARNING) << "Clicking on the tab.";
348 content::SimulateMouseClick(chrome::GetActiveWebContents(browser()), 0, 350 content::SimulateMouseClick(chrome::GetActiveWebContents(browser()), 0,
349 WebKit::WebMouseEvent::ButtonLeft); 351 WebKit::WebMouseEvent::ButtonLeft);
350 352
351 LOG(WARNING) << "Focusing the first name field."; 353 LOG(WARNING) << "Focusing the first name field.";
352 bool result = false; 354 bool result = false;
353 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 355 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
354 render_view_host(), L"", 356 render_view_host(),
355 L"if (document.readyState === 'complete')" 357 "",
356 L" document.getElementById('firstname').focus();" 358 "if (document.readyState === 'complete')"
357 L"else" 359 " document.getElementById('firstname').focus();"
358 L" domAutomationController.send(false);", 360 "else"
361 " domAutomationController.send(false);",
359 &result)); 362 &result));
360 ASSERT_TRUE(result); 363 ASSERT_TRUE(result);
361 } 364 }
362 365
363 void ExpectFilledTestForm() { 366 void ExpectFilledTestForm() {
364 ExpectFieldValue(L"firstname", "Milton"); 367 ExpectFieldValue("firstname", "Milton");
365 ExpectFieldValue(L"lastname", "Waddams"); 368 ExpectFieldValue("lastname", "Waddams");
366 ExpectFieldValue(L"address1", "4120 Freidrich Lane"); 369 ExpectFieldValue("address1", "4120 Freidrich Lane");
367 ExpectFieldValue(L"address2", "Basement"); 370 ExpectFieldValue("address2", "Basement");
368 ExpectFieldValue(L"city", "Austin"); 371 ExpectFieldValue("city", "Austin");
369 ExpectFieldValue(L"state", "TX"); 372 ExpectFieldValue("state", "TX");
370 ExpectFieldValue(L"zip", "78744"); 373 ExpectFieldValue("zip", "78744");
371 ExpectFieldValue(L"country", "US"); 374 ExpectFieldValue("country", "US");
372 ExpectFieldValue(L"phone", "5125551234"); 375 ExpectFieldValue("phone", "5125551234");
373 } 376 }
374 377
375 void SendKeyAndWait(ui::KeyboardCode key, int notification_type) { 378 void SendKeyAndWait(ui::KeyboardCode key, int notification_type) {
376 content::WindowedNotificationObserver observer( 379 content::WindowedNotificationObserver observer(
377 notification_type, content::Source<RenderViewHost>(render_view_host())); 380 notification_type, content::Source<RenderViewHost>(render_view_host()));
378 content::SimulateKeyPress(chrome::GetActiveWebContents(browser()), 381 content::SimulateKeyPress(chrome::GetActiveWebContents(browser()),
379 key, false, false, false, false); 382 key, false, false, false, false);
380 observer.Wait(); 383 observer.Wait();
381 } 384 }
382 385
383 void TryBasicFormFill() { 386 void TryBasicFormFill() {
384 FocusFirstNameField(); 387 FocusFirstNameField();
385 388
386 // Start filling the first name field with "M" and wait for the popup to be 389 // Start filling the first name field with "M" and wait for the popup to be
387 // shown. 390 // shown.
388 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; 391 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup.";
389 SendKeyAndWait( 392 SendKeyAndWait(
390 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); 393 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
391 394
392 // Press the down arrow to select the suggestion and preview the autofilled 395 // Press the down arrow to select the suggestion and preview the autofilled
393 // form. 396 // form.
394 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; 397 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview.";
395 SendKeyAndWait( 398 SendKeyAndWait(
396 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); 399 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
397 400
398 // The previewed values should not be accessible to JavaScript. 401 // The previewed values should not be accessible to JavaScript.
399 ExpectFieldValue(L"firstname", "M"); 402 ExpectFieldValue("firstname", "M");
400 ExpectFieldValue(L"lastname", ""); 403 ExpectFieldValue("lastname", "");
401 ExpectFieldValue(L"address1", ""); 404 ExpectFieldValue("address1", "");
402 ExpectFieldValue(L"address2", ""); 405 ExpectFieldValue("address2", "");
403 ExpectFieldValue(L"city", ""); 406 ExpectFieldValue("city", "");
404 ExpectFieldValue(L"state", ""); 407 ExpectFieldValue("state", "");
405 ExpectFieldValue(L"zip", ""); 408 ExpectFieldValue("zip", "");
406 ExpectFieldValue(L"country", ""); 409 ExpectFieldValue("country", "");
407 ExpectFieldValue(L"phone", ""); 410 ExpectFieldValue("phone", "");
408 // TODO(isherman): It would be nice to test that the previewed values are 411 // TODO(isherman): It would be nice to test that the previewed values are
409 // displayed: http://crbug.com/57220 412 // displayed: http://crbug.com/57220
410 413
411 // Press Enter to accept the autofill suggestions. 414 // Press Enter to accept the autofill suggestions.
412 LOG(WARNING) << "Simulating Return press to fill the form."; 415 LOG(WARNING) << "Simulating Return press to fill the form.";
413 SendKeyAndWait( 416 SendKeyAndWait(
414 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); 417 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
415 418
416 // The form should be filled. 419 // The form should be filled.
417 ExpectFilledTestForm(); 420 ExpectFilledTestForm();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ExpectFilledTestForm(); 533 ExpectFilledTestForm();
531 534
532 // The change event should have already fired for unfocused fields, both of 535 // The change event should have already fired for unfocused fields, both of
533 // <input> and of <select> type. However, it should not yet have fired for the 536 // <input> and of <select> type. However, it should not yet have fired for the
534 // focused field. 537 // focused field.
535 bool focused_fired = false; 538 bool focused_fired = false;
536 bool unfocused_fired = false; 539 bool unfocused_fired = false;
537 bool changed_select_fired = false; 540 bool changed_select_fired = false;
538 bool unchanged_select_fired = false; 541 bool unchanged_select_fired = false;
539 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 542 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
540 render_view_host(), L"", 543 render_view_host(),
541 L"domAutomationController.send(focused_fired);", &focused_fired)); 544 "",
545 "domAutomationController.send(focused_fired);",
546 &focused_fired));
542 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 547 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
543 render_view_host(), L"", 548 render_view_host(),
544 L"domAutomationController.send(unfocused_fired);", &unfocused_fired)); 549 "",
550 "domAutomationController.send(unfocused_fired);",
551 &unfocused_fired));
545 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 552 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
546 render_view_host(), L"", 553 render_view_host(),
547 L"domAutomationController.send(changed_select_fired);", 554 "",
555 "domAutomationController.send(changed_select_fired);",
548 &changed_select_fired)); 556 &changed_select_fired));
549 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 557 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
550 render_view_host(), L"", 558 render_view_host(),
551 L"domAutomationController.send(unchanged_select_fired);", 559 "",
560 "domAutomationController.send(unchanged_select_fired);",
552 &unchanged_select_fired)); 561 &unchanged_select_fired));
553 EXPECT_FALSE(focused_fired); 562 EXPECT_FALSE(focused_fired);
554 EXPECT_TRUE(unfocused_fired); 563 EXPECT_TRUE(unfocused_fired);
555 EXPECT_TRUE(changed_select_fired); 564 EXPECT_TRUE(changed_select_fired);
556 EXPECT_FALSE(unchanged_select_fired); 565 EXPECT_FALSE(unchanged_select_fired);
557 566
558 // Unfocus the first name field. Its change event should fire. 567 // Unfocus the first name field. Its change event should fire.
559 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 568 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
560 render_view_host(), L"", 569 render_view_host(),
561 L"document.getElementById('firstname').blur();" 570 "",
562 L"domAutomationController.send(focused_fired);", &focused_fired)); 571 "document.getElementById('firstname').blur();"
572 "domAutomationController.send(focused_fired);", &focused_fired));
563 EXPECT_TRUE(focused_fired); 573 EXPECT_TRUE(focused_fired);
564 } 574 }
565 575
566 // Test that we can autofill forms distinguished only by their |id| attribute. 576 // Test that we can autofill forms distinguished only by their |id| attribute.
567 // DISABLED: http://crbug.com/150084 577 // DISABLED: http://crbug.com/150084
568 IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormsDistinguishedById) { 578 IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormsDistinguishedById) {
569 CreateTestProfile(); 579 CreateTestProfile();
570 580
571 // Load the test page. 581 // Load the test page.
572 const std::string kURL = 582 const std::string kURL =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 " <option value=\"\" selected=\"yes\">--</option>" 635 " <option value=\"\" selected=\"yes\">--</option>"
626 " <option value=\"CA\">Canada</option>" 636 " <option value=\"CA\">Canada</option>"
627 " <option value=\"US\">United States</option>" 637 " <option value=\"US\">United States</option>"
628 " </select><br>" 638 " </select><br>"
629 "<label for=\"phone\">Phone number:</label>" 639 "<label for=\"phone\">Phone number:</label>"
630 " <input type=\"text\" id=\"phone\"><br>" 640 " <input type=\"text\" id=\"phone\"><br>"
631 "</form>"))); 641 "</form>")));
632 642
633 // Invoke Autofill. 643 // Invoke Autofill.
634 TryBasicFormFill(); 644 TryBasicFormFill();
635 ExpectFieldValue(L"state_freeform", ""); 645 ExpectFieldValue("state_freeform", "");
636 } 646 }
637 647
638 // http://crbug.com/150084 648 // http://crbug.com/150084
639 #if defined(OS_MAC) 649 #if defined(OS_MAC)
640 #define MAYBE_AutofillFormWithNonAutofillableField \ 650 #define MAYBE_AutofillFormWithNonAutofillableField \
641 AutofillFormWithNonAutofillableField 651 AutofillFormWithNonAutofillableField
642 #else 652 #else
643 #define MAYBE_AutofillFormWithNonAutofillableField \ 653 #define MAYBE_AutofillFormWithNonAutofillableField \
644 DISABLED_AutofillFormWithNonAutofillableField 654 DISABLED_AutofillFormWithNonAutofillableField
645 #endif 655 #endif
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 "" 773 ""
764 " for (var i = 0; i < elements.length; i++) {" 774 " for (var i = 0; i < elements.length; i++) {"
765 " var name = elements[i][0];" 775 " var name = elements[i][0];"
766 " var label = elements[i][1];" 776 " var label = elements[i][1];"
767 " AddElement(name, label);" 777 " AddElement(name, label);"
768 " }" 778 " }"
769 "};" 779 "};"
770 "</script>"))); 780 "</script>")));
771 781
772 // Dynamically construct the form. 782 // Dynamically construct the form.
773 ASSERT_TRUE(content::ExecuteJavaScript(render_view_host(), L"", 783 ASSERT_TRUE(content::ExecuteJavaScript(render_view_host(), "",
774 L"BuildForm();")); 784 "BuildForm();"));
775 785
776 // Invoke Autofill. 786 // Invoke Autofill.
777 TryBasicFormFill(); 787 TryBasicFormFill();
778 } 788 }
779 789
780 // Test that form filling works after reloading the current page. 790 // Test that form filling works after reloading the current page.
781 // This test brought to you by http://crbug.com/69204 791 // This test brought to you by http://crbug.com/69204
782 #if defined(OS_MACOSX) 792 #if defined(OS_MACOSX)
783 // Now flaky on everything but mac. 793 // Now flaky on everything but mac.
784 // http://crbug.com/150084 794 // http://crbug.com/150084
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 SimulateURLFetch(true); 873 SimulateURLFetch(true);
864 874
865 content::WindowedNotificationObserver translation_observer( 875 content::WindowedNotificationObserver translation_observer(
866 chrome::NOTIFICATION_PAGE_TRANSLATED, 876 chrome::NOTIFICATION_PAGE_TRANSLATED,
867 content::NotificationService::AllSources()); 877 content::NotificationService::AllSources());
868 878
869 // Simulate translation to kick onTranslateElementLoad. 879 // Simulate translation to kick onTranslateElementLoad.
870 // But right now, the call stucks here. 880 // But right now, the call stucks here.
871 // Once click the text field, it starts again. 881 // Once click the text field, it starts again.
872 ASSERT_TRUE(content::ExecuteJavaScript( 882 ASSERT_TRUE(content::ExecuteJavaScript(
873 render_view_host(), L"", 883 render_view_host(),
874 L"cr.googleTranslate.onTranslateElementLoad();")); 884 "",
885 "cr.googleTranslate.onTranslateElementLoad();"));
875 886
876 // Simulate the render notifying the translation has been done. 887 // Simulate the render notifying the translation has been done.
877 translation_observer.Wait(); 888 translation_observer.Wait();
878 889
879 TryBasicFormFill(); 890 TryBasicFormFill();
880 } 891 }
881 892
882 // Test filling profiles with unicode strings and crazy characters. 893 // Test filling profiles with unicode strings and crazy characters.
883 // TODO(isherman): rewrite as unit test under PersonalDataManagerTest. 894 // TODO(isherman): rewrite as unit test under PersonalDataManagerTest.
884 IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) { 895 IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose")); 1186 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose"));
1176 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); 1187 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
1177 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110")); 1188 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110"));
1178 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1-408-555-4567")); 1189 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1-408-555-4567"));
1179 SetProfile(profile); 1190 SetProfile(profile);
1180 1191
1181 GURL url = test_server()->GetURL("files/autofill/form_phones.html"); 1192 GURL url = test_server()->GetURL("files/autofill/form_phones.html");
1182 ui_test_utils::NavigateToURL(browser(), url); 1193 ui_test_utils::NavigateToURL(browser(), url);
1183 PopulateForm("NAME_FIRST"); 1194 PopulateForm("NAME_FIRST");
1184 1195
1185 ExpectFieldValue(L"NAME_FIRST", "Bob"); 1196 ExpectFieldValue("NAME_FIRST", "Bob");
1186 ExpectFieldValue(L"NAME_LAST", "Smith"); 1197 ExpectFieldValue("NAME_LAST", "Smith");
1187 ExpectFieldValue(L"ADDRESS_HOME_LINE1", "1234 H St."); 1198 ExpectFieldValue("ADDRESS_HOME_LINE1", "1234 H St.");
1188 ExpectFieldValue(L"ADDRESS_HOME_CITY", "San Jose"); 1199 ExpectFieldValue("ADDRESS_HOME_CITY", "San Jose");
1189 ExpectFieldValue(L"ADDRESS_HOME_STATE", "CA"); 1200 ExpectFieldValue("ADDRESS_HOME_STATE", "CA");
1190 ExpectFieldValue(L"ADDRESS_HOME_ZIP", "95110"); 1201 ExpectFieldValue("ADDRESS_HOME_ZIP", "95110");
1191 ExpectFieldValue(L"PHONE_HOME_WHOLE_NUMBER", "14085554567"); 1202 ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "14085554567");
1192 ExpectFieldValue(L"PHONE_HOME_CITY_CODE-1", "408"); 1203 ExpectFieldValue("PHONE_HOME_CITY_CODE-1", "408");
1193 ExpectFieldValue(L"PHONE_HOME_CITY_CODE-2", "408"); 1204 ExpectFieldValue("PHONE_HOME_CITY_CODE-2", "408");
1194 ExpectFieldValue(L"PHONE_HOME_NUMBER", "5554567"); 1205 ExpectFieldValue("PHONE_HOME_NUMBER", "5554567");
1195 ExpectFieldValue(L"PHONE_HOME_NUMBER_3-1", "555"); 1206 ExpectFieldValue("PHONE_HOME_NUMBER_3-1", "555");
1196 ExpectFieldValue(L"PHONE_HOME_NUMBER_3-2", "555"); 1207 ExpectFieldValue("PHONE_HOME_NUMBER_3-2", "555");
1197 ExpectFieldValue(L"PHONE_HOME_NUMBER_4-1", "4567"); 1208 ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567");
1198 ExpectFieldValue(L"PHONE_HOME_NUMBER_4-2", "4567"); 1209 ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567");
1199 ExpectFieldValue(L"PHONE_HOME_EXT-1", ""); 1210 ExpectFieldValue("PHONE_HOME_EXT-1", "");
1200 ExpectFieldValue(L"PHONE_HOME_EXT-2", ""); 1211 ExpectFieldValue("PHONE_HOME_EXT-2", "");
1201 ExpectFieldValue(L"PHONE_HOME_COUNTRY_CODE-1", "1"); 1212 ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1");
1202 } 1213 }
1203 1214
1204 // Test profile is saved if phone number is valid in selected country. 1215 // Test profile is saved if phone number is valid in selected country.
1205 // The data file contains two profiles with valid phone numbers and two 1216 // The data file contains two profiles with valid phone numbers and two
1206 // profiles with invalid phone numbers from their respective country. 1217 // profiles with invalid phone numbers from their respective country.
1207 // DISABLED: http://crbug.com/150084 1218 // DISABLED: http://crbug.com/150084
1208 IN_PROC_BROWSER_TEST_F(AutofillTest, 1219 IN_PROC_BROWSER_TEST_F(AutofillTest,
1209 DISABLED_ProfileSavedWithValidCountryPhone) { 1220 DISABLED_ProfileSavedWithValidCountryPhone) {
1210 ASSERT_TRUE(test_server()->Start()); 1221 ASSERT_TRUE(test_server()->Start());
1211 std::vector<FormMap> profiles; 1222 std::vector<FormMap> profiles;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); 1339 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
1329 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110")); 1340 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110"));
1330 profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Company X")); 1341 profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Company X"));
1331 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("408-871-4567")); 1342 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("408-871-4567"));
1332 SetProfile(profile); 1343 SetProfile(profile);
1333 1344
1334 GURL url = test_server()->GetURL("files/autofill/read_only_field_test.html"); 1345 GURL url = test_server()->GetURL("files/autofill/read_only_field_test.html");
1335 ui_test_utils::NavigateToURL(browser(), url); 1346 ui_test_utils::NavigateToURL(browser(), url);
1336 PopulateForm("firstname"); 1347 PopulateForm("firstname");
1337 1348
1338 ExpectFieldValue(L"email", ""); 1349 ExpectFieldValue("email", "");
1339 ExpectFieldValue(L"address", addr_line1); 1350 ExpectFieldValue("address", addr_line1);
1340 } 1351 }
1341 1352
1342 // http://crbug.com/150084 1353 // http://crbug.com/150084
1343 #if defined(OS_MACOSX) 1354 #if defined(OS_MACOSX)
1344 #define MAYBE_FormFillableOnReset FormFillableOnReset 1355 #define MAYBE_FormFillableOnReset FormFillableOnReset
1345 #else 1356 #else
1346 #define MAYBE_FormFillableOnReset DISABLED_FormFillableOnReset 1357 #define MAYBE_FormFillableOnReset DISABLED_FormFillableOnReset
1347 #endif 1358 #endif
1348 // Test form is fillable from a profile after form was reset. 1359 // Test form is fillable from a profile after form was reset.
1349 // Steps: 1360 // Steps:
1350 // 1. Fill form using a saved profile. 1361 // 1. Fill form using a saved profile.
1351 // 2. Reset the form. 1362 // 2. Reset the form.
1352 // 3. Fill form using a saved profile. 1363 // 3. Fill form using a saved profile.
1353 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillableOnReset) { 1364 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillableOnReset) {
1354 ASSERT_TRUE(test_server()->Start()); 1365 ASSERT_TRUE(test_server()->Start());
1355 1366
1356 CreateTestProfile(); 1367 CreateTestProfile();
1357 1368
1358 GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html"); 1369 GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html");
1359 ui_test_utils::NavigateToURL(browser(), url); 1370 ui_test_utils::NavigateToURL(browser(), url);
1360 PopulateForm("NAME_FIRST"); 1371 PopulateForm("NAME_FIRST");
1361 1372
1362 ASSERT_TRUE(content::ExecuteJavaScript( 1373 ASSERT_TRUE(content::ExecuteJavaScript(
1363 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", 1374 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
1364 L"document.getElementById('testform').reset()")); 1375 "",
1376 "document.getElementById('testform').reset()"));
1365 1377
1366 PopulateForm("NAME_FIRST"); 1378 PopulateForm("NAME_FIRST");
1367 1379
1368 ExpectFieldValue(L"NAME_FIRST", "Milton"); 1380 ExpectFieldValue("NAME_FIRST", "Milton");
1369 ExpectFieldValue(L"NAME_LAST", "Waddams"); 1381 ExpectFieldValue("NAME_LAST", "Waddams");
1370 ExpectFieldValue(L"EMAIL_ADDRESS", "red.swingline@initech.com"); 1382 ExpectFieldValue("EMAIL_ADDRESS", "red.swingline@initech.com");
1371 ExpectFieldValue(L"ADDRESS_HOME_LINE1", "4120 Freidrich Lane"); 1383 ExpectFieldValue("ADDRESS_HOME_LINE1", "4120 Freidrich Lane");
1372 ExpectFieldValue(L"ADDRESS_HOME_CITY", "Austin"); 1384 ExpectFieldValue("ADDRESS_HOME_CITY", "Austin");
1373 ExpectFieldValue(L"ADDRESS_HOME_STATE", "Texas"); 1385 ExpectFieldValue("ADDRESS_HOME_STATE", "Texas");
1374 ExpectFieldValue(L"ADDRESS_HOME_ZIP", "78744"); 1386 ExpectFieldValue("ADDRESS_HOME_ZIP", "78744");
1375 ExpectFieldValue(L"ADDRESS_HOME_COUNTRY", "United States"); 1387 ExpectFieldValue("ADDRESS_HOME_COUNTRY", "United States");
1376 ExpectFieldValue(L"PHONE_HOME_WHOLE_NUMBER", "5125551234"); 1388 ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "5125551234");
1377 } 1389 }
1378 1390
1379 // http://crbug.com/150084 1391 // http://crbug.com/150084
1380 #if defined(OS_MACOSX) 1392 #if defined(OS_MACOSX)
1381 #define MAYBE_DistinguishMiddleInitialWithinName \ 1393 #define MAYBE_DistinguishMiddleInitialWithinName \
1382 DistinguishMiddleInitialWithinName 1394 DistinguishMiddleInitialWithinName
1383 #else 1395 #else
1384 #define MAYBE_DistinguishMiddleInitialWithinName \ 1396 #define MAYBE_DistinguishMiddleInitialWithinName \
1385 DISABLED_DistinguishMiddleInitialWithinName 1397 DISABLED_DistinguishMiddleInitialWithinName
1386 #endif 1398 #endif
1387 // Test Autofill distinguishes a middle initial in a name. 1399 // Test Autofill distinguishes a middle initial in a name.
1388 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DistinguishMiddleInitialWithinName) { 1400 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DistinguishMiddleInitialWithinName) {
1389 ASSERT_TRUE(test_server()->Start()); 1401 ASSERT_TRUE(test_server()->Start());
1390 1402
1391 CreateTestProfile(); 1403 CreateTestProfile();
1392 1404
1393 GURL url = test_server()->GetURL( 1405 GURL url = test_server()->GetURL(
1394 "files/autofill/autofill_middleinit_form.html"); 1406 "files/autofill/autofill_middleinit_form.html");
1395 ui_test_utils::NavigateToURL(browser(), url); 1407 ui_test_utils::NavigateToURL(browser(), url);
1396 PopulateForm("NAME_FIRST"); 1408 PopulateForm("NAME_FIRST");
1397 1409
1398 ExpectFieldValue(L"NAME_MIDDLE", "C"); 1410 ExpectFieldValue("NAME_MIDDLE", "C");
1399 } 1411 }
1400 1412
1401 // http://crbug.com/150084 1413 // http://crbug.com/150084
1402 #if defined(OS_MACOSX) 1414 #if defined(OS_MACOSX)
1403 #define MAYBE_MultipleEmailFilledByOneUserGesture \ 1415 #define MAYBE_MultipleEmailFilledByOneUserGesture \
1404 MultipleEmailFilledByOneUserGesture 1416 MultipleEmailFilledByOneUserGesture
1405 #else 1417 #else
1406 #define MAYBE_MultipleEmailFilledByOneUserGesture \ 1418 #define MAYBE_MultipleEmailFilledByOneUserGesture \
1407 DISABLED_MultipleEmailFilledByOneUserGesture 1419 DISABLED_MultipleEmailFilledByOneUserGesture
1408 #endif 1420 #endif
(...skipping 10 matching lines...) Expand all
1419 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); 1431 profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
1420 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(email)); 1432 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(email));
1421 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("4088714567")); 1433 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("4088714567"));
1422 SetProfile(profile); 1434 SetProfile(profile);
1423 1435
1424 GURL url = test_server()->GetURL( 1436 GURL url = test_server()->GetURL(
1425 "files/autofill/autofill_confirmemail_form.html"); 1437 "files/autofill/autofill_confirmemail_form.html");
1426 ui_test_utils::NavigateToURL(browser(), url); 1438 ui_test_utils::NavigateToURL(browser(), url);
1427 PopulateForm("NAME_FIRST"); 1439 PopulateForm("NAME_FIRST");
1428 1440
1429 ExpectFieldValue(L"EMAIL_CONFIRM", email); 1441 ExpectFieldValue("EMAIL_CONFIRM", email);
1430 // TODO(isherman): verify entire form. 1442 // TODO(isherman): verify entire form.
1431 } 1443 }
1432 1444
1433 // Test profile not aggregated if email found in non-email field. 1445 // Test profile not aggregated if email found in non-email field.
1434 IN_PROC_BROWSER_TEST_F(AutofillTest, ProfileWithEmailInOtherFieldNotSaved) { 1446 IN_PROC_BROWSER_TEST_F(AutofillTest, ProfileWithEmailInOtherFieldNotSaved) {
1435 ASSERT_TRUE(test_server()->Start()); 1447 ASSERT_TRUE(test_server()->Start());
1436 1448
1437 FormMap data; 1449 FormMap data;
1438 data["NAME_FIRST"] = "Bob"; 1450 data["NAME_FIRST"] = "Bob";
1439 data["NAME_LAST"] = "Smith"; 1451 data["NAME_LAST"] = "Smith";
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 "files/autofill/latency_after_submit_test.html"); 1516 "files/autofill/latency_after_submit_test.html");
1505 ui_test_utils::NavigateToURL(browser(), url); 1517 ui_test_utils::NavigateToURL(browser(), url);
1506 PopulateForm("NAME_FIRST"); 1518 PopulateForm("NAME_FIRST");
1507 1519
1508 content::WindowedNotificationObserver load_stop_observer( 1520 content::WindowedNotificationObserver load_stop_observer(
1509 content::NOTIFICATION_LOAD_STOP, 1521 content::NOTIFICATION_LOAD_STOP,
1510 content::Source<content::NavigationController>( 1522 content::Source<content::NavigationController>(
1511 &chrome::GetActiveWebContents(browser())->GetController())); 1523 &chrome::GetActiveWebContents(browser())->GetController()));
1512 1524
1513 ASSERT_TRUE(content::ExecuteJavaScript( 1525 ASSERT_TRUE(content::ExecuteJavaScript(
1514 render_view_host(), L"", 1526 render_view_host(),
1515 ASCIIToWide("document.getElementById('testform').submit();"))); 1527 "",
1528 "document.getElementById('testform').submit();"));
1516 // This will ensure the test didn't hang. 1529 // This will ensure the test didn't hang.
1517 load_stop_observer.Wait(); 1530 load_stop_observer.Wait();
1518 } 1531 }
1519 1532
1520 // http://crbug.com/150084 1533 // http://crbug.com/150084
1521 #if defined(OS_MACOSX) 1534 #if defined(OS_MACOSX)
1522 #define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling 1535 #define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling
1523 #else 1536 #else
1524 #define MAYBE_DisableAutocompleteWhileFilling \ 1537 #define MAYBE_DisableAutocompleteWhileFilling \
1525 DISABLED_DisableAutocompleteWhileFilling 1538 DISABLED_DisableAutocompleteWhileFilling
(...skipping 10 matching lines...) Expand all
1536 1549
1537 // Invoke Autofill: Start filling the first name field with "M" and wait for 1550 // Invoke Autofill: Start filling the first name field with "M" and wait for
1538 // the popup to be shown. 1551 // the popup to be shown.
1539 FocusFirstNameField(); 1552 FocusFirstNameField();
1540 SendKeyAndWait( 1553 SendKeyAndWait(
1541 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); 1554 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
1542 1555
1543 // Now that the popup with suggestions is showing, disable autocomplete for 1556 // Now that the popup with suggestions is showing, disable autocomplete for
1544 // the active field. 1557 // the active field.
1545 ASSERT_TRUE(content::ExecuteJavaScript( 1558 ASSERT_TRUE(content::ExecuteJavaScript(
1546 render_view_host(), L"", 1559 render_view_host(),
1547 L"document.querySelector('input').autocomplete = 'off';")); 1560 "",
1561 "document.querySelector('input').autocomplete = 'off';"));
1548 1562
1549 // Press the down arrow to select the suggestion and attempt to preview the 1563 // Press the down arrow to select the suggestion and attempt to preview the
1550 // autofilled form. 1564 // autofilled form.
1551 content::SimulateKeyPress(chrome::GetActiveWebContents(browser()), 1565 content::SimulateKeyPress(chrome::GetActiveWebContents(browser()),
1552 ui::VKEY_DOWN, false, false, false, false); 1566 ui::VKEY_DOWN, false, false, false, false);
1553 1567
1554 // Wait for any IPCs to complete by performing an action that generates an 1568 // Wait for any IPCs to complete by performing an action that generates an
1555 // IPC that's easy to wait for. Chrome shouldn't crash. 1569 // IPC that's easy to wait for. Chrome shouldn't crash.
1556 bool result = false; 1570 bool result = false;
1557 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 1571 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
1558 render_view_host(), L"", 1572 render_view_host(),
1559 L"var city = document.getElementById('city');" 1573 "",
1560 L"city.onfocus = function() { domAutomationController.send(true); };" 1574 "var city = document.getElementById('city');"
1561 L"city.focus()", 1575 "city.onfocus = function() { domAutomationController.send(true); };"
1576 "city.focus()",
1562 &result)); 1577 &result));
1563 ASSERT_TRUE(result); 1578 ASSERT_TRUE(result);
1564 SendKeyAndWait( 1579 SendKeyAndWait(
1565 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); 1580 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
1566 } 1581 }
1567 1582
1568 // Test that profiles merge for aggregated data with same address. 1583 // Test that profiles merge for aggregated data with same address.
1569 // The criterion for when two profiles are expected to be merged is when their 1584 // The criterion for when two profiles are expected to be merged is when their
1570 // 'Address Line 1' and 'City' data match. When two profiles are merged, any 1585 // 'Address Line 1' and 'City' data match. When two profiles are merged, any
1571 // remaining address fields are expected to be overwritten. Any non-address 1586 // remaining address fields are expected to be overwritten. Any non-address
(...skipping 22 matching lines...) Expand all
1594 // TODO(isherman): this looks redundant, consider removing. 1609 // TODO(isherman): this looks redundant, consider removing.
1595 // DISABLED: http://crbug.com/150084 1610 // DISABLED: http://crbug.com/150084
1596 IN_PROC_BROWSER_TEST_F(AutofillTest, 1611 IN_PROC_BROWSER_TEST_F(AutofillTest,
1597 DISABLED_MergeAggregatedDuplicatedProfiles) { 1612 DISABLED_MergeAggregatedDuplicatedProfiles) {
1598 int num_of_profiles = 1613 int num_of_profiles =
1599 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); 1614 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt");
1600 1615
1601 ASSERT_GT(num_of_profiles, 1616 ASSERT_GT(num_of_profiles,
1602 static_cast<int>(personal_data_manager()->GetProfiles().size())); 1617 static_cast<int>(personal_data_manager()->GetProfiles().size()));
1603 } 1618 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/automation_misc_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698