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, |
csharp
2013/03/07 14:11:21
Is this suppose to be different from the other 2?
Ilya Sherman
2013/03/07 22:32:16
Yep, this is before the popup is showing.
| |
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 if (!external_delegate_) { | |
csharp
2013/03/07 14:11:21
Add a comment to remove this once the WebKit code
Ilya Sherman
2013/03/07 22:32:16
Done.
| |
444 // When testing the WebKit-based UI, route all keys to the page. | |
445 SendKeyToPageAndWait(key, notification_type); | |
446 return; | |
447 } | |
448 | |
449 // When testing the native UI, route popup-targetted key presses via the | |
csharp
2013/03/07 14:11:21
nit: targetted -> targeted
Ilya Sherman
2013/03/07 22:32:16
Done.
| |
450 // external delegate. | |
451 content::WindowedNotificationObserver observer( | |
452 notification_type, content::Source<RenderViewHost>(render_view_host())); | |
453 content::NativeWebKeyboardEvent event; | |
454 event.windowsKeyCode = key; | |
455 external_delegate_->keyboard_listener()->HandleKeyPressEvent(event); | |
456 observer.Wait(); | |
457 } | |
458 | |
388 void TryBasicFormFill() { | 459 void TryBasicFormFill() { |
389 FocusFirstNameField(); | 460 FocusFirstNameField(); |
390 | 461 |
391 // Start filling the first name field with "M" and wait for the popup to be | 462 // Start filling the first name field with "M" and wait for the popup to be |
392 // shown. | 463 // shown. |
393 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; | 464 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; |
394 SendKeyAndWait( | 465 SendKeyToPageAndWait( |
csharp
2013/03/07 14:11:21
Should these be SendKeyToPopupAndWait?
Ilya Sherman
2013/03/07 22:32:16
No, there's no popup showing prior to this keypres
| |
395 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 466 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
396 | 467 |
397 // Press the down arrow to select the suggestion and preview the autofilled | 468 // Press the down arrow to select the suggestion and preview the autofilled |
398 // form. | 469 // form. |
399 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; | 470 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; |
400 SendKeyAndWait( | 471 SendKeyToPopupAndWait( |
401 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 472 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
402 | 473 |
403 // The previewed values should not be accessible to JavaScript. | 474 // The previewed values should not be accessible to JavaScript. |
404 ExpectFieldValue("firstname", "M"); | 475 ExpectFieldValue("firstname", "M"); |
405 ExpectFieldValue("lastname", ""); | 476 ExpectFieldValue("lastname", ""); |
406 ExpectFieldValue("address1", ""); | 477 ExpectFieldValue("address1", ""); |
407 ExpectFieldValue("address2", ""); | 478 ExpectFieldValue("address2", ""); |
408 ExpectFieldValue("city", ""); | 479 ExpectFieldValue("city", ""); |
409 ExpectFieldValue("state", ""); | 480 ExpectFieldValue("state", ""); |
410 ExpectFieldValue("zip", ""); | 481 ExpectFieldValue("zip", ""); |
411 ExpectFieldValue("country", ""); | 482 ExpectFieldValue("country", ""); |
412 ExpectFieldValue("phone", ""); | 483 ExpectFieldValue("phone", ""); |
413 // TODO(isherman): It would be nice to test that the previewed values are | 484 // TODO(isherman): It would be nice to test that the previewed values are |
414 // displayed: http://crbug.com/57220 | 485 // displayed: http://crbug.com/57220 |
415 | 486 |
416 // Press Enter to accept the autofill suggestions. | 487 // Press Enter to accept the autofill suggestions. |
417 LOG(WARNING) << "Simulating Return press to fill the form."; | 488 LOG(WARNING) << "Simulating Return press to fill the form."; |
418 SendKeyAndWait( | 489 SendKeyToPopupAndWait( |
419 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 490 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
420 | 491 |
421 // The form should be filled. | 492 // The form should be filled. |
422 ExpectFilledTestForm(); | 493 ExpectFilledTestForm(); |
423 } | 494 } |
424 | 495 |
496 TestAutofillExternalDelegate* external_delegate() { | |
497 return external_delegate_.get(); | |
498 } | |
499 | |
425 private: | 500 private: |
426 net::TestURLFetcherFactory url_fetcher_factory_; | 501 net::TestURLFetcherFactory url_fetcher_factory_; |
502 scoped_ptr<TestAutofillExternalDelegate> external_delegate_; | |
427 }; | 503 }; |
428 | 504 |
429 // http://crbug.com/150084 | 505 // http://crbug.com/150084 |
430 #if defined(OS_MACOSX) | 506 #if defined(OS_MACOSX) |
431 #define MAYBE_BasicFormFill BasicFormFill | 507 #define MAYBE_BasicFormFill BasicFormFill |
432 #else | 508 #else |
433 #define MAYBE_BasicFormFill DISABLED_BasicFormFill | 509 #define MAYBE_BasicFormFill DISABLED_BasicFormFill |
434 #endif | 510 #endif |
435 // Test that basic form fill is working. | 511 // Test that basic form fill is working. |
436 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_BasicFormFill) { | 512 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_BasicFormFill) { |
(...skipping 19 matching lines...) Expand all Loading... | |
456 | 532 |
457 // Load the test page. | 533 // Load the test page. |
458 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 534 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
459 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 535 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
460 | 536 |
461 // Focus a fillable field. | 537 // Focus a fillable field. |
462 FocusFirstNameField(); | 538 FocusFirstNameField(); |
463 | 539 |
464 // Press the down arrow to initiate Autofill and wait for the popup to be | 540 // Press the down arrow to initiate Autofill and wait for the popup to be |
465 // shown. | 541 // shown. |
466 SendKeyAndWait( | 542 SendKeyToPageAndWait( |
467 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 543 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
468 | 544 |
469 // Press the down arrow to select the suggestion and preview the autofilled | 545 // Press the down arrow to select the suggestion and preview the autofilled |
470 // form. | 546 // form. |
471 SendKeyAndWait( | 547 SendKeyToPopupAndWait( |
472 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 548 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
473 | 549 |
474 // Press Enter to accept the autofill suggestions. | 550 // Press Enter to accept the autofill suggestions. |
475 SendKeyAndWait( | 551 SendKeyToPopupAndWait( |
476 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 552 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
477 | 553 |
478 // The form should be filled. | 554 // The form should be filled. |
479 ExpectFilledTestForm(); | 555 ExpectFilledTestForm(); |
480 } | 556 } |
481 | 557 |
482 // http://crbug.com/150084 | 558 // http://crbug.com/150084 |
483 #if defined(OS_MACOSX) | 559 #if defined(OS_MACOSX) |
484 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill | 560 #define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill |
485 #else | 561 #else |
(...skipping 26 matching lines...) Expand all Loading... | |
512 | 588 |
513 // Load the test page. | 589 // Load the test page. |
514 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 590 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
515 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); | 591 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); |
516 | 592 |
517 // Invoke Autofill. | 593 // Invoke Autofill. |
518 FocusFirstNameField(); | 594 FocusFirstNameField(); |
519 | 595 |
520 // Start filling the first name field with "M" and wait for the popup to be | 596 // Start filling the first name field with "M" and wait for the popup to be |
521 // shown. | 597 // shown. |
522 SendKeyAndWait( | 598 SendKeyToPageAndWait( |
523 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 599 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
524 | 600 |
525 // Press the down arrow to select the suggestion and preview the autofilled | 601 // Press the down arrow to select the suggestion and preview the autofilled |
526 // form. | 602 // form. |
527 SendKeyAndWait( | 603 SendKeyToPopupAndWait( |
528 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 604 ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
529 | 605 |
530 // Press Enter to accept the autofill suggestions. | 606 // Press Enter to accept the autofill suggestions. |
531 SendKeyAndWait( | 607 SendKeyToPopupAndWait( |
532 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); | 608 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); |
533 | 609 |
534 // The form should be filled. | 610 // The form should be filled. |
535 ExpectFilledTestForm(); | 611 ExpectFilledTestForm(); |
536 | 612 |
537 // The change event should have already fired for unfocused fields, both of | 613 // 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 | 614 // <input> and of <select> type. However, it should not yet have fired for the |
539 // focused field. | 615 // focused field. |
540 bool focused_fired = false; | 616 bool focused_fired = false; |
541 bool unfocused_fired = false; | 617 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) { | 1616 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) { |
1541 CreateTestProfile(); | 1617 CreateTestProfile(); |
1542 | 1618 |
1543 // Load the test page. | 1619 // Load the test page. |
1544 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1620 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1545 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 1621 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
1546 | 1622 |
1547 // Invoke Autofill: Start filling the first name field with "M" and wait for | 1623 // Invoke Autofill: Start filling the first name field with "M" and wait for |
1548 // the popup to be shown. | 1624 // the popup to be shown. |
1549 FocusFirstNameField(); | 1625 FocusFirstNameField(); |
1550 SendKeyAndWait( | 1626 SendKeyToPageAndWait( |
1551 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 1627 ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
1552 | 1628 |
1553 // Now that the popup with suggestions is showing, disable autocomplete for | 1629 // Now that the popup with suggestions is showing, disable autocomplete for |
1554 // the active field. | 1630 // the active field. |
1555 ASSERT_TRUE(content::ExecuteScript( | 1631 ASSERT_TRUE(content::ExecuteScript( |
1556 render_view_host(), | 1632 render_view_host(), |
1557 "document.querySelector('input').autocomplete = 'off';")); | 1633 "document.querySelector('input').autocomplete = 'off';")); |
1558 | 1634 |
1559 // Press the down arrow to select the suggestion and attempt to preview the | 1635 // Press the down arrow to select the suggestion and attempt to preview the |
1560 // autofilled form. | 1636 // autofilled form. |
1561 content::SimulateKeyPress( | 1637 if (!external_delegate()) { |
csharp
2013/03/07 14:11:21
Is there a reason this can't use SendKeyToPopupAnd
Ilya Sherman
2013/03/07 22:32:16
There's no event to wait for.
| |
1562 browser()->tab_strip_model()->GetActiveWebContents(), | 1638 content::SimulateKeyPress( |
1563 ui::VKEY_DOWN, false, false, false, false); | 1639 browser()->tab_strip_model()->GetActiveWebContents(), |
1640 ui::VKEY_DOWN, false, false, false, false); | |
1641 } else { | |
1642 content::NativeWebKeyboardEvent event; | |
1643 event.windowsKeyCode = ui::VKEY_DOWN; | |
1644 external_delegate()->keyboard_listener()->HandleKeyPressEvent(event); | |
1645 } | |
1564 | 1646 |
1565 // Wait for any IPCs to complete by performing an action that generates an | 1647 // 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. | 1648 // IPC that's easy to wait for. Chrome shouldn't crash. |
1567 bool result = false; | 1649 bool result = false; |
1568 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1650 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1569 render_view_host(), | 1651 render_view_host(), |
1570 "var city = document.getElementById('city');" | 1652 "var city = document.getElementById('city');" |
1571 "city.onfocus = function() { domAutomationController.send(true); };" | 1653 "city.onfocus = function() { domAutomationController.send(true); };" |
1572 "city.focus()", | 1654 "city.focus()", |
1573 &result)); | 1655 &result)); |
1574 ASSERT_TRUE(result); | 1656 ASSERT_TRUE(result); |
1575 SendKeyAndWait( | 1657 SendKeyToPageAndWait( |
1576 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); | 1658 ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); |
1577 } | 1659 } |
1578 | 1660 |
1579 // Test that profiles merge for aggregated data with same address. | 1661 // 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 | 1662 // 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 | 1663 // '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 | 1664 // remaining address fields are expected to be overwritten. Any non-address |
1583 // fields should accumulate multi-valued data. | 1665 // fields should accumulate multi-valued data. |
1584 // DISABLED: http://crbug.com/150084 | 1666 // DISABLED: http://crbug.com/150084 |
1585 IN_PROC_BROWSER_TEST_F(AutofillTest, | 1667 IN_PROC_BROWSER_TEST_F(AutofillTest, |
(...skipping 19 matching lines...) Expand all Loading... | |
1605 // TODO(isherman): this looks redundant, consider removing. | 1687 // TODO(isherman): this looks redundant, consider removing. |
1606 // DISABLED: http://crbug.com/150084 | 1688 // DISABLED: http://crbug.com/150084 |
1607 IN_PROC_BROWSER_TEST_F(AutofillTest, | 1689 IN_PROC_BROWSER_TEST_F(AutofillTest, |
1608 DISABLED_MergeAggregatedDuplicatedProfiles) { | 1690 DISABLED_MergeAggregatedDuplicatedProfiles) { |
1609 int num_of_profiles = | 1691 int num_of_profiles = |
1610 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); | 1692 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); |
1611 | 1693 |
1612 ASSERT_GT(num_of_profiles, | 1694 ASSERT_GT(num_of_profiles, |
1613 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 1695 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
1614 } | 1696 } |
OLD | NEW |