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

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

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