OLD | NEW |
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" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 17 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
18 #include "chrome/browser/api/infobars/infobar_service.h" | 18 #include "chrome/browser/api/infobars/infobar_service.h" |
19 #include "chrome/browser/autofill/autofill_common_test.h" | 19 #include "chrome/browser/autofill/autofill_common_test.h" |
| 20 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| 21 #include "chrome/browser/autofill/autofill_manager.h" |
20 #include "chrome/browser/autofill/autofill_profile.h" | 22 #include "chrome/browser/autofill/autofill_profile.h" |
21 #include "chrome/browser/autofill/credit_card.h" | 23 #include "chrome/browser/autofill/credit_card.h" |
22 #include "chrome/browser/autofill/personal_data_manager.h" | 24 #include "chrome/browser/autofill/personal_data_manager.h" |
23 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 25 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
24 #include "chrome/browser/autofill/personal_data_manager_observer.h" | 26 #include "chrome/browser/autofill/personal_data_manager_observer.h" |
25 #include "chrome/browser/autofill/validation.h" | 27 #include "chrome/browser/autofill/validation.h" |
26 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/translate/translate_infobar_delegate.h" | 29 #include "chrome/browser/translate/translate_infobar_delegate.h" |
28 #include "chrome/browser/translate/translate_manager.h" | 30 #include "chrome/browser/translate/translate_manager.h" |
29 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 146 } |
145 | 147 |
146 private: | 148 private: |
147 bool alerted_; | 149 bool alerted_; |
148 bool has_run_message_loop_; | 150 bool has_run_message_loop_; |
149 Browser* browser_; | 151 Browser* browser_; |
150 content::NotificationRegistrar registrar_; | 152 content::NotificationRegistrar registrar_; |
151 InfoBarService* infobar_service_; | 153 InfoBarService* infobar_service_; |
152 }; | 154 }; |
153 | 155 |
| 156 class TestAutofillExternalDelegate : public AutofillExternalDelegate { |
| 157 public: |
| 158 TestAutofillExternalDelegate(content::WebContents* web_contents, |
| 159 AutofillManager* autofill_manager) |
| 160 : AutofillExternalDelegate(web_contents, autofill_manager), |
| 161 keyboard_listener_(NULL) { |
| 162 } |
| 163 virtual ~TestAutofillExternalDelegate() {} |
| 164 |
| 165 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE { |
| 166 AutofillExternalDelegate::OnPopupShown(listener); |
| 167 keyboard_listener_ = listener; |
| 168 } |
| 169 |
| 170 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE { |
| 171 keyboard_listener_ = NULL; |
| 172 AutofillExternalDelegate::OnPopupHidden(listener); |
| 173 } |
| 174 |
| 175 content::KeyboardListener* keyboard_listener() { |
| 176 return keyboard_listener_; |
| 177 } |
| 178 |
| 179 private: |
| 180 // The popup that is currently registered as a keyboard listener, or NULL if |
| 181 // there is none. |
| 182 content::KeyboardListener* keyboard_listener_; |
| 183 |
| 184 DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate); |
| 185 }; |
| 186 |
154 class AutofillTest : public InProcessBrowserTest { | 187 class AutofillTest : public InProcessBrowserTest { |
155 protected: | 188 protected: |
156 AutofillTest() {} | 189 AutofillTest() {} |
157 | 190 |
158 virtual void SetUpOnMainThread() OVERRIDE { | 191 virtual void SetUpOnMainThread() OVERRIDE { |
159 // Don't want Keychain coming up on Mac. | 192 // Don't want Keychain coming up on Mac. |
160 autofill_test::DisableSystemServices(browser()->profile()); | 193 autofill_test::DisableSystemServices(browser()->profile()); |
| 194 |
| 195 // When testing the native UI, hook up a test external delegate, which |
| 196 // allows us to forward keyboard events to the popup directly. |
| 197 content::WebContents* web_contents = |
| 198 browser()->tab_strip_model()->GetActiveWebContents(); |
| 199 AutofillManager* autofill_manager = |
| 200 AutofillManager::FromWebContents(web_contents); |
| 201 if (autofill_manager->IsNativeUiEnabled()) { |
| 202 external_delegate_.reset( |
| 203 new TestAutofillExternalDelegate(web_contents, autofill_manager)); |
| 204 autofill_manager->SetExternalDelegate(external_delegate_.get()); |
| 205 } |
| 206 } |
| 207 |
| 208 virtual void CleanUpOnMainThread() OVERRIDE { |
| 209 // Make sure to close any showing popups prior to tearing down the UI. |
| 210 content::WebContents* web_contents = |
| 211 browser()->tab_strip_model()->GetActiveWebContents(); |
| 212 AutofillManager* autofill_manager = |
| 213 AutofillManager::FromWebContents(web_contents); |
| 214 autofill_manager->delegate()->HideAutofillPopup(); |
161 } | 215 } |
162 | 216 |
163 PersonalDataManager* personal_data_manager() { | 217 PersonalDataManager* personal_data_manager() { |
164 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); | 218 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); |
165 } | 219 } |
166 | 220 |
167 void CreateTestProfile() { | 221 void CreateTestProfile() { |
168 AutofillProfile profile; | 222 AutofillProfile profile; |
169 autofill_test::SetProfileInfo( | 223 autofill_test::SetProfileInfo( |
170 &profile, "Milton", "C.", "Waddams", | 224 &profile, "Milton", "C.", "Waddams", |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 FillFormAndSubmit("autofill_creditcard_form.html", data); | 288 FillFormAndSubmit("autofill_creditcard_form.html", data); |
235 } | 289 } |
236 | 290 |
237 // Populates a webpage form using autofill data and keypress events. | 291 // Populates a webpage form using autofill data and keypress events. |
238 // This function focuses the specified input field in the form, and then | 292 // 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. | 293 // sends keypress events to the tab to cause the form to be populated. |
240 void PopulateForm(const std::string& field_id) { | 294 void PopulateForm(const std::string& field_id) { |
241 std::string js("document.getElementById('" + field_id + "').focus();"); | 295 std::string js("document.getElementById('" + field_id + "').focus();"); |
242 ASSERT_TRUE(content::ExecuteScript(render_view_host(), js)); | 296 ASSERT_TRUE(content::ExecuteScript(render_view_host(), js)); |
243 | 297 |
244 SendKeyAndWait(ui::VKEY_DOWN, | 298 SendKeyToPageAndWait(ui::VKEY_DOWN, |
245 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 299 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
246 SendKeyAndWait(ui::VKEY_DOWN, | 300 SendKeyToPopupAndWait(ui::VKEY_DOWN, |
247 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 301 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
248 SendKeyAndWait(ui::VKEY_RETURN, | 302 SendKeyToPopupAndWait(ui::VKEY_RETURN, |
249 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 303 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
250 } | 304 } |
251 | 305 |
252 // Aggregate profiles from forms into Autofill preferences. Returns the number | 306 // Aggregate profiles from forms into Autofill preferences. Returns the number |
253 // of parsed profiles. | 307 // of parsed profiles. |
254 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { | 308 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { |
255 CHECK(test_server()->Start()); | 309 CHECK(test_server()->Start()); |
256 | 310 |
257 std::string data; | 311 std::string data; |
258 base::FilePath data_file = | 312 base::FilePath data_file = |
259 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), | 313 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 ExpectFieldValue("lastname", "Waddams"); | 423 ExpectFieldValue("lastname", "Waddams"); |
370 ExpectFieldValue("address1", "4120 Freidrich Lane"); | 424 ExpectFieldValue("address1", "4120 Freidrich Lane"); |
371 ExpectFieldValue("address2", "Basement"); | 425 ExpectFieldValue("address2", "Basement"); |
372 ExpectFieldValue("city", "Austin"); | 426 ExpectFieldValue("city", "Austin"); |
373 ExpectFieldValue("state", "TX"); | 427 ExpectFieldValue("state", "TX"); |
374 ExpectFieldValue("zip", "78744"); | 428 ExpectFieldValue("zip", "78744"); |
375 ExpectFieldValue("country", "US"); | 429 ExpectFieldValue("country", "US"); |
376 ExpectFieldValue("phone", "5125551234"); | 430 ExpectFieldValue("phone", "5125551234"); |
377 } | 431 } |
378 | 432 |
379 void SendKeyAndWait(ui::KeyboardCode key, int notification_type) { | 433 void SendKeyToPageAndWait(ui::KeyboardCode key, int notification_type) { |
380 content::WindowedNotificationObserver observer( | 434 content::WindowedNotificationObserver observer( |
381 notification_type, content::Source<RenderViewHost>(render_view_host())); | 435 notification_type, content::Source<RenderViewHost>(render_view_host())); |
382 content::SimulateKeyPress( | 436 content::SimulateKeyPress( |
383 browser()->tab_strip_model()->GetActiveWebContents(), | 437 browser()->tab_strip_model()->GetActiveWebContents(), |
384 key, false, false, false, false); | 438 key, false, false, false, false); |
385 observer.Wait(); | 439 observer.Wait(); |
386 } | 440 } |
387 | 441 |
| 442 void SendKeyToPopupAndWait(ui::KeyboardCode key, int notification_type) { |
| 443 // TODO(isherman): Remove this condition once the WebKit popup UI code is |
| 444 // removed. |
| 445 if (!external_delegate_) { |
| 446 // When testing the WebKit-based UI, route all keys to the page. |
| 447 SendKeyToPageAndWait(key, notification_type); |
| 448 return; |
| 449 } |
| 450 |
| 451 // When testing the native UI, route popup-targeted key presses via the |
| 452 // external delegate. |
| 453 content::WindowedNotificationObserver observer( |
| 454 notification_type, content::Source<RenderViewHost>(render_view_host())); |
| 455 content::NativeWebKeyboardEvent event; |
| 456 event.windowsKeyCode = key; |
| 457 external_delegate_->keyboard_listener()->HandleKeyPressEvent(event); |
| 458 observer.Wait(); |
| 459 } |
| 460 |
388 void TryBasicFormFill() { | 461 void TryBasicFormFill() { |
389 FocusFirstNameField(); | 462 FocusFirstNameField(); |
390 | 463 |
391 // Start filling the first name field with "M" and wait for the popup to be | 464 // Start filling the first name field with "M" and wait for the popup to be |
392 // shown. | 465 // shown. |
393 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; | 466 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; |
394 SendKeyAndWait( | 467 SendKeyToPageAndWait( |
395 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 468 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
396 | 469 |
397 // Press the down arrow to select the suggestion and preview the autofilled | 470 // Press the down arrow to select the suggestion and preview the autofilled |
398 // form. | 471 // form. |
399 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; | 472 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; |
400 SendKeyAndWait( | 473 SendKeyToPopupAndWait( |
401 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 474 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
402 | 475 |
403 // The previewed values should not be accessible to JavaScript. | 476 // The previewed values should not be accessible to JavaScript. |
404 ExpectFieldValue("firstname", "M"); | 477 ExpectFieldValue("firstname", "M"); |
405 ExpectFieldValue("lastname", ""); | 478 ExpectFieldValue("lastname", ""); |
406 ExpectFieldValue("address1", ""); | 479 ExpectFieldValue("address1", ""); |
407 ExpectFieldValue("address2", ""); | 480 ExpectFieldValue("address2", ""); |
408 ExpectFieldValue("city", ""); | 481 ExpectFieldValue("city", ""); |
409 ExpectFieldValue("state", ""); | 482 ExpectFieldValue("state", ""); |
410 ExpectFieldValue("zip", ""); | 483 ExpectFieldValue("zip", ""); |
411 ExpectFieldValue("country", ""); | 484 ExpectFieldValue("country", ""); |
412 ExpectFieldValue("phone", ""); | 485 ExpectFieldValue("phone", ""); |
413 // TODO(isherman): It would be nice to test that the previewed values are | 486 // TODO(isherman): It would be nice to test that the previewed values are |
414 // displayed: http://crbug.com/57220 | 487 // displayed: http://crbug.com/57220 |
415 | 488 |
416 // Press Enter to accept the autofill suggestions. | 489 // Press Enter to accept the autofill suggestions. |
417 LOG(WARNING) << "Simulating Return press to fill the form."; | 490 LOG(WARNING) << "Simulating Return press to fill the form."; |
418 SendKeyAndWait( | 491 SendKeyToPopupAndWait( |
419 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 492 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
420 | 493 |
421 // The form should be filled. | 494 // The form should be filled. |
422 ExpectFilledTestForm(); | 495 ExpectFilledTestForm(); |
423 } | 496 } |
424 | 497 |
| 498 TestAutofillExternalDelegate* external_delegate() { |
| 499 return external_delegate_.get(); |
| 500 } |
| 501 |
425 private: | 502 private: |
426 net::TestURLFetcherFactory url_fetcher_factory_; | 503 net::TestURLFetcherFactory url_fetcher_factory_; |
| 504 scoped_ptr<TestAutofillExternalDelegate> external_delegate_; |
427 }; | 505 }; |
428 | 506 |
429 // http://crbug.com/150084 | 507 // http://crbug.com/150084 |
430 #if defined(OS_MACOSX) | 508 #if defined(OS_MACOSX) |
431 #define MAYBE_BasicFormFill BasicFormFill | 509 #define MAYBE_BasicFormFill BasicFormFill |
432 #else | 510 #else |
433 #define MAYBE_BasicFormFill DISABLED_BasicFormFill | 511 #define MAYBE_BasicFormFill DISABLED_BasicFormFill |
434 #endif | 512 #endif |
435 // Test that basic form fill is working. | 513 // Test that basic form fill is working. |
436 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_BasicFormFill) { | 514 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_BasicFormFill) { |
(...skipping 19 matching lines...) Expand all Loading... |
456 | 534 |
457 // Load the test page. | 535 // Load the test page. |
458 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 536 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
459 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 537 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
460 | 538 |
461 // Focus a fillable field. | 539 // Focus a fillable field. |
462 FocusFirstNameField(); | 540 FocusFirstNameField(); |
463 | 541 |
464 // Press the down arrow to initiate Autofill and wait for the popup to be | 542 // Press the down arrow to initiate Autofill and wait for the popup to be |
465 // shown. | 543 // shown. |
466 SendKeyAndWait( | 544 SendKeyToPageAndWait( |
467 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 545 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
468 | 546 |
469 // Press the down arrow to select the suggestion and preview the autofilled | 547 // Press the down arrow to select the suggestion and preview the autofilled |
470 // form. | 548 // form. |
471 SendKeyAndWait( | 549 SendKeyToPopupAndWait( |
472 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 550 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
473 | 551 |
474 // Press Enter to accept the autofill suggestions. | 552 // Press Enter to accept the autofill suggestions. |
475 SendKeyAndWait( | 553 SendKeyToPopupAndWait( |
476 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 554 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
477 | 555 |
478 // The form should be filled. | 556 // The form should be filled. |
479 ExpectFilledTestForm(); | 557 ExpectFilledTestForm(); |
480 } | 558 } |
481 | 559 |
482 // http://crbug.com/150084 | 560 // http://crbug.com/150084 |
483 #if defined(OS_MACOSX) | 561 #if defined(OS_MACOSX) |
484 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill | 562 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill |
485 #else | 563 #else |
(...skipping 26 matching lines...) Expand all Loading... |
512 | 590 |
513 // Load the test page. | 591 // Load the test page. |
514 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 592 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
515 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); | 593 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); |
516 | 594 |
517 // Invoke Autofill. | 595 // Invoke Autofill. |
518 FocusFirstNameField(); | 596 FocusFirstNameField(); |
519 | 597 |
520 // Start filling the first name field with "M" and wait for the popup to be | 598 // Start filling the first name field with "M" and wait for the popup to be |
521 // shown. | 599 // shown. |
522 SendKeyAndWait( | 600 SendKeyToPageAndWait( |
523 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 601 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
524 | 602 |
525 // Press the down arrow to select the suggestion and preview the autofilled | 603 // Press the down arrow to select the suggestion and preview the autofilled |
526 // form. | 604 // form. |
527 SendKeyAndWait( | 605 SendKeyToPopupAndWait( |
528 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 606 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
529 | 607 |
530 // Press Enter to accept the autofill suggestions. | 608 // Press Enter to accept the autofill suggestions. |
531 SendKeyAndWait( | 609 SendKeyToPopupAndWait( |
532 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 610 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
533 | 611 |
534 // The form should be filled. | 612 // The form should be filled. |
535 ExpectFilledTestForm(); | 613 ExpectFilledTestForm(); |
536 | 614 |
537 // The change event should have already fired for unfocused fields, both of | 615 // The change event should have already fired for unfocused fields, both of |
538 // <input> and of <select> type. However, it should not yet have fired for the | 616 // <input> and of <select> type. However, it should not yet have fired for the |
539 // focused field. | 617 // focused field. |
540 bool focused_fired = false; | 618 bool focused_fired = false; |
541 bool unfocused_fired = false; | 619 bool unfocused_fired = false; |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) { | 1618 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) { |
1541 CreateTestProfile(); | 1619 CreateTestProfile(); |
1542 | 1620 |
1543 // Load the test page. | 1621 // Load the test page. |
1544 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1622 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1545 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 1623 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
1546 | 1624 |
1547 // Invoke Autofill: Start filling the first name field with "M" and wait for | 1625 // Invoke Autofill: Start filling the first name field with "M" and wait for |
1548 // the popup to be shown. | 1626 // the popup to be shown. |
1549 FocusFirstNameField(); | 1627 FocusFirstNameField(); |
1550 SendKeyAndWait( | 1628 SendKeyToPageAndWait( |
1551 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 1629 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
1552 | 1630 |
1553 // Now that the popup with suggestions is showing, disable autocomplete for | 1631 // Now that the popup with suggestions is showing, disable autocomplete for |
1554 // the active field. | 1632 // the active field. |
1555 ASSERT_TRUE(content::ExecuteScript( | 1633 ASSERT_TRUE(content::ExecuteScript( |
1556 render_view_host(), | 1634 render_view_host(), |
1557 "document.querySelector('input').autocomplete = 'off';")); | 1635 "document.querySelector('input').autocomplete = 'off';")); |
1558 | 1636 |
1559 // Press the down arrow to select the suggestion and attempt to preview the | 1637 // Press the down arrow to select the suggestion and attempt to preview the |
1560 // autofilled form. | 1638 // autofilled form. |
1561 content::SimulateKeyPress( | 1639 if (!external_delegate()) { |
1562 browser()->tab_strip_model()->GetActiveWebContents(), | 1640 content::SimulateKeyPress( |
1563 ui::VKEY_DOWN, false, false, false, false); | 1641 browser()->tab_strip_model()->GetActiveWebContents(), |
| 1642 ui::VKEY_DOWN, false, false, false, false); |
| 1643 } else { |
| 1644 content::NativeWebKeyboardEvent event; |
| 1645 event.windowsKeyCode = ui::VKEY_DOWN; |
| 1646 external_delegate()->keyboard_listener()->HandleKeyPressEvent(event); |
| 1647 } |
1564 | 1648 |
1565 // Wait for any IPCs to complete by performing an action that generates an | 1649 // Wait for any IPCs to complete by performing an action that generates an |
1566 // IPC that's easy to wait for. Chrome shouldn't crash. | 1650 // IPC that's easy to wait for. Chrome shouldn't crash. |
1567 bool result = false; | 1651 bool result = false; |
1568 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1652 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1569 render_view_host(), | 1653 render_view_host(), |
1570 "var city = document.getElementById('city');" | 1654 "var city = document.getElementById('city');" |
1571 "city.onfocus = function() { domAutomationController.send(true); };" | 1655 "city.onfocus = function() { domAutomationController.send(true); };" |
1572 "city.focus()", | 1656 "city.focus()", |
1573 &result)); | 1657 &result)); |
1574 ASSERT_TRUE(result); | 1658 ASSERT_TRUE(result); |
1575 SendKeyAndWait( | 1659 SendKeyToPageAndWait( |
1576 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 1660 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
1577 } | 1661 } |
1578 | 1662 |
1579 // Test that profiles merge for aggregated data with same address. | 1663 // Test that profiles merge for aggregated data with same address. |
1580 // The criterion for when two profiles are expected to be merged is when their | 1664 // The criterion for when two profiles are expected to be merged is when their |
1581 // 'Address Line 1' and 'City' data match. When two profiles are merged, any | 1665 // 'Address Line 1' and 'City' data match. When two profiles are merged, any |
1582 // remaining address fields are expected to be overwritten. Any non-address | 1666 // remaining address fields are expected to be overwritten. Any non-address |
1583 // fields should accumulate multi-valued data. | 1667 // fields should accumulate multi-valued data. |
1584 // DISABLED: http://crbug.com/150084 | 1668 // DISABLED: http://crbug.com/150084 |
1585 IN_PROC_BROWSER_TEST_F(AutofillTest, | 1669 IN_PROC_BROWSER_TEST_F(AutofillTest, |
(...skipping 19 matching lines...) Expand all Loading... |
1605 // TODO(isherman): this looks redundant, consider removing. | 1689 // TODO(isherman): this looks redundant, consider removing. |
1606 // DISABLED: http://crbug.com/150084 | 1690 // DISABLED: http://crbug.com/150084 |
1607 IN_PROC_BROWSER_TEST_F(AutofillTest, | 1691 IN_PROC_BROWSER_TEST_F(AutofillTest, |
1608 DISABLED_MergeAggregatedDuplicatedProfiles) { | 1692 DISABLED_MergeAggregatedDuplicatedProfiles) { |
1609 int num_of_profiles = | 1693 int num_of_profiles = |
1610 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); | 1694 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); |
1611 | 1695 |
1612 ASSERT_GT(num_of_profiles, | 1696 ASSERT_GT(num_of_profiles, |
1613 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 1697 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
1614 } | 1698 } |
OLD | NEW |