OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 18 #include "chrome/browser/autofill/autofill_uitest_util.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/infobars/infobar_service.h" | |
21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/translate/chrome_translate_client.h" | 21 #include "chrome/browser/translate/chrome_translate_client.h" |
23 #include "chrome/browser/translate/translate_service.h" | 22 #include "chrome/browser/translate/translate_service.h" |
24 #include "chrome/browser/ui/browser.h" | |
25 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
28 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
29 #include "chrome/test/base/interactive_test_utils.h" | 27 #include "chrome/test/base/interactive_test_utils.h" |
30 #include "chrome/test/base/test_switches.h" | 28 #include "chrome/test/base/test_switches.h" |
31 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
32 #include "components/autofill/content/browser/content_autofill_driver.h" | 30 #include "components/autofill/content/browser/content_autofill_driver.h" |
33 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 31 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
34 #include "components/autofill/core/browser/autofill_manager.h" | 32 #include "components/autofill/core/browser/autofill_manager.h" |
35 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" | 33 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" |
36 #include "components/autofill/core/browser/autofill_profile.h" | 34 #include "components/autofill/core/browser/autofill_profile.h" |
37 #include "components/autofill/core/browser/autofill_test_utils.h" | 35 #include "components/autofill/core/browser/autofill_test_utils.h" |
38 #include "components/autofill/core/browser/personal_data_manager.h" | |
39 #include "components/autofill/core/browser/personal_data_manager_observer.h" | |
40 #include "components/autofill/core/browser/validation.h" | 36 #include "components/autofill/core/browser/validation.h" |
41 #include "components/infobars/core/confirm_infobar_delegate.h" | |
42 #include "components/infobars/core/infobar.h" | |
43 #include "components/infobars/core/infobar_manager.h" | 37 #include "components/infobars/core/infobar_manager.h" |
44 #include "components/translate/core/browser/translate_infobar_delegate.h" | 38 #include "components/translate/core/browser/translate_infobar_delegate.h" |
45 #include "content/public/browser/navigation_controller.h" | 39 #include "content/public/browser/navigation_controller.h" |
46 #include "content/public/browser/notification_observer.h" | 40 #include "content/public/browser/notification_observer.h" |
47 #include "content/public/browser/notification_registrar.h" | 41 #include "content/public/browser/notification_registrar.h" |
48 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
49 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
50 #include "content/public/browser/render_widget_host.h" | 44 #include "content/public/browser/render_widget_host.h" |
51 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
52 #include "content/public/test/browser_test_utils.h" | 46 #include "content/public/test/browser_test_utils.h" |
53 #include "content/public/test/test_renderer_host.h" | 47 #include "content/public/test/test_renderer_host.h" |
54 #include "content/public/test/test_utils.h" | |
55 #include "net/url_request/test_url_fetcher_factory.h" | 48 #include "net/url_request/test_url_fetcher_factory.h" |
56 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
57 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
58 #include "ui/events/keycodes/keyboard_codes.h" | 51 #include "ui/events/keycodes/keyboard_codes.h" |
59 | 52 |
60 using base::ASCIIToUTF16; | 53 using base::ASCIIToUTF16; |
61 | 54 |
62 namespace autofill { | 55 namespace autofill { |
63 | 56 |
64 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; | 57 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void Wait() { | 118 void Wait() { |
126 loop_runner_->Run(); | 119 loop_runner_->Run(); |
127 } | 120 } |
128 | 121 |
129 private: | 122 private: |
130 scoped_refptr<content::MessageLoopRunner> loop_runner_; | 123 scoped_refptr<content::MessageLoopRunner> loop_runner_; |
131 | 124 |
132 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl); | 125 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl); |
133 }; | 126 }; |
134 | 127 |
135 | |
136 // WindowedPersonalDataManagerObserver ---------------------------------------- | |
137 | |
138 class WindowedPersonalDataManagerObserver | |
139 : public PersonalDataManagerObserver, | |
140 public infobars::InfoBarManager::Observer { | |
141 public: | |
142 explicit WindowedPersonalDataManagerObserver(Browser* browser) | |
143 : alerted_(false), | |
144 has_run_message_loop_(false), | |
145 browser_(browser), | |
146 infobar_service_(InfoBarService::FromWebContents( | |
147 browser_->tab_strip_model()->GetActiveWebContents())) { | |
148 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | |
149 AddObserver(this); | |
150 infobar_service_->AddObserver(this); | |
151 } | |
152 | |
153 ~WindowedPersonalDataManagerObserver() override { | |
154 while (infobar_service_->infobar_count() > 0) { | |
155 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); | |
156 } | |
157 infobar_service_->RemoveObserver(this); | |
158 } | |
159 | |
160 // PersonalDataManagerObserver: | |
161 void OnPersonalDataChanged() override { | |
162 if (has_run_message_loop_) { | |
163 base::MessageLoopForUI::current()->Quit(); | |
164 has_run_message_loop_ = false; | |
165 } | |
166 alerted_ = true; | |
167 } | |
168 | |
169 void OnInsufficientFormData() override { OnPersonalDataChanged(); } | |
170 | |
171 | |
172 void Wait() { | |
173 if (!alerted_) { | |
174 has_run_message_loop_ = true; | |
175 content::RunMessageLoop(); | |
176 } | |
177 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | |
178 RemoveObserver(this); | |
179 } | |
180 | |
181 private: | |
182 // infobars::InfoBarManager::Observer: | |
183 void OnInfoBarAdded(infobars::InfoBar* infobar) override { | |
184 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> | |
185 Accept(); | |
186 } | |
187 | |
188 bool alerted_; | |
189 bool has_run_message_loop_; | |
190 Browser* browser_; | |
191 InfoBarService* infobar_service_; | |
192 | |
193 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); | |
194 }; | |
195 | |
196 // AutofillInteractiveTest ---------------------------------------------------- | 128 // AutofillInteractiveTest ---------------------------------------------------- |
197 | 129 |
198 class AutofillInteractiveTest : public InProcessBrowserTest { | 130 class AutofillInteractiveTest : public InProcessBrowserTest { |
199 protected: | 131 protected: |
200 AutofillInteractiveTest() : | 132 AutofillInteractiveTest() : |
201 key_press_event_sink_( | 133 key_press_event_sink_( |
202 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, | 134 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, |
203 base::Unretained(this))) {} | 135 base::Unretained(this))) {} |
204 ~AutofillInteractiveTest() override {} | 136 ~AutofillInteractiveTest() override {} |
205 | 137 |
(...skipping 21 matching lines...) Expand all Loading... |
227 void TearDownOnMainThread() override { | 159 void TearDownOnMainThread() override { |
228 // Make sure to close any showing popups prior to tearing down the UI. | 160 // Make sure to close any showing popups prior to tearing down the UI. |
229 content::WebContents* web_contents = GetWebContents(); | 161 content::WebContents* web_contents = GetWebContents(); |
230 AutofillManager* autofill_manager = | 162 AutofillManager* autofill_manager = |
231 ContentAutofillDriverFactory::FromWebContents(web_contents) | 163 ContentAutofillDriverFactory::FromWebContents(web_contents) |
232 ->DriverForFrame(web_contents->GetMainFrame()) | 164 ->DriverForFrame(web_contents->GetMainFrame()) |
233 ->autofill_manager(); | 165 ->autofill_manager(); |
234 autofill_manager->client()->HideAutofillPopup(); | 166 autofill_manager->client()->HideAutofillPopup(); |
235 } | 167 } |
236 | 168 |
237 PersonalDataManager* GetPersonalDataManager() { | |
238 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); | |
239 } | |
240 | |
241 content::WebContents* GetWebContents() { | 169 content::WebContents* GetWebContents() { |
242 return browser()->tab_strip_model()->GetActiveWebContents(); | 170 return browser()->tab_strip_model()->GetActiveWebContents(); |
243 } | 171 } |
244 | 172 |
245 content::RenderViewHost* GetRenderViewHost() { | 173 content::RenderViewHost* GetRenderViewHost() { |
246 return GetWebContents()->GetRenderViewHost(); | 174 return GetWebContents()->GetRenderViewHost(); |
247 } | 175 } |
248 | 176 |
249 void CreateTestProfile() { | |
250 AutofillProfile profile; | |
251 test::SetProfileInfo( | |
252 &profile, "Milton", "C.", "Waddams", | |
253 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane", | |
254 "Basement", "Austin", "Texas", "78744", "US", "5125551234"); | |
255 | |
256 WindowedPersonalDataManagerObserver observer(browser()); | |
257 GetPersonalDataManager()->AddProfile(profile); | |
258 | |
259 // AddProfile is asynchronous. Wait for it to finish before continuing the | |
260 // tests. | |
261 observer.Wait(); | |
262 } | |
263 | |
264 void SetProfiles(std::vector<AutofillProfile>* profiles) { | 177 void SetProfiles(std::vector<AutofillProfile>* profiles) { |
265 WindowedPersonalDataManagerObserver observer(browser()); | 178 WindowedPersonalDataManagerObserver observer(browser()); |
266 GetPersonalDataManager()->SetProfiles(profiles); | 179 GetPersonalDataManager(browser())->SetProfiles(profiles); |
267 observer.Wait(); | 180 observer.Wait(); |
268 } | 181 } |
269 | 182 |
270 void SetProfile(const AutofillProfile& profile) { | 183 void SetProfile(const AutofillProfile& profile) { |
271 std::vector<AutofillProfile> profiles; | 184 std::vector<AutofillProfile> profiles; |
272 profiles.push_back(profile); | 185 profiles.push_back(profile); |
273 SetProfiles(&profiles); | 186 SetProfiles(&profiles); |
274 } | 187 } |
275 | 188 |
276 // Populates a webpage form using autofill data and keypress events. | 189 // Populates a webpage form using autofill data and keypress events. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // key press event callback handles the event (at least on Mac), a DCHECK | 406 // key press event callback handles the event (at least on Mac), a DCHECK |
494 // ends up going off that the |event| doesn't have an |os_event| associated | 407 // ends up going off that the |event| doesn't have an |os_event| associated |
495 // with it. | 408 // with it. |
496 content::RenderWidgetHost::KeyPressEventCallback key_press_event_sink_; | 409 content::RenderWidgetHost::KeyPressEventCallback key_press_event_sink_; |
497 | 410 |
498 DISALLOW_COPY_AND_ASSIGN(AutofillInteractiveTest); | 411 DISALLOW_COPY_AND_ASSIGN(AutofillInteractiveTest); |
499 }; | 412 }; |
500 | 413 |
501 // Test that basic form fill is working. | 414 // Test that basic form fill is working. |
502 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, BasicFormFill) { | 415 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, BasicFormFill) { |
503 CreateTestProfile(); | 416 CreateTestProfile(browser()); |
504 | 417 |
505 // Load the test page. | 418 // Load the test page. |
506 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 419 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
507 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 420 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
508 | 421 |
509 // Invoke Autofill. | 422 // Invoke Autofill. |
510 TryBasicFormFill(); | 423 TryBasicFormFill(); |
511 } | 424 } |
512 | 425 |
513 // Test that form filling can be initiated by pressing the down arrow. | 426 // Test that form filling can be initiated by pressing the down arrow. |
514 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaDownArrow) { | 427 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaDownArrow) { |
515 CreateTestProfile(); | 428 CreateTestProfile(browser()); |
516 | 429 |
517 // Load the test page. | 430 // Load the test page. |
518 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 431 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
519 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 432 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
520 | 433 |
521 // Focus a fillable field. | 434 // Focus a fillable field. |
522 FocusFirstNameField(); | 435 FocusFirstNameField(); |
523 | 436 |
524 // Press the down arrow to initiate Autofill and wait for the popup to be | 437 // Press the down arrow to initiate Autofill and wait for the popup to be |
525 // shown. | 438 // shown. |
526 SendKeyToPageAndWait(ui::VKEY_DOWN); | 439 SendKeyToPageAndWait(ui::VKEY_DOWN); |
527 | 440 |
528 // Press the down arrow to select the suggestion and preview the autofilled | 441 // Press the down arrow to select the suggestion and preview the autofilled |
529 // form. | 442 // form. |
530 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 443 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
531 | 444 |
532 // Press Enter to accept the autofill suggestions. | 445 // Press Enter to accept the autofill suggestions. |
533 SendKeyToPopupAndWait(ui::VKEY_RETURN); | 446 SendKeyToPopupAndWait(ui::VKEY_RETURN); |
534 | 447 |
535 // The form should be filled. | 448 // The form should be filled. |
536 ExpectFilledTestForm(); | 449 ExpectFilledTestForm(); |
537 } | 450 } |
538 | 451 |
539 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillSelectViaTab) { | 452 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillSelectViaTab) { |
540 CreateTestProfile(); | 453 CreateTestProfile(browser()); |
541 | 454 |
542 // Load the test page. | 455 // Load the test page. |
543 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 456 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
544 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 457 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
545 | 458 |
546 // Focus a fillable field. | 459 // Focus a fillable field. |
547 FocusFirstNameField(); | 460 FocusFirstNameField(); |
548 | 461 |
549 // Press the down arrow to initiate Autofill and wait for the popup to be | 462 // Press the down arrow to initiate Autofill and wait for the popup to be |
550 // shown. | 463 // shown. |
551 SendKeyToPageAndWait(ui::VKEY_DOWN); | 464 SendKeyToPageAndWait(ui::VKEY_DOWN); |
552 | 465 |
553 // Press the down arrow to select the suggestion and preview the autofilled | 466 // Press the down arrow to select the suggestion and preview the autofilled |
554 // form. | 467 // form. |
555 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 468 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
556 | 469 |
557 // Press tab to accept the autofill suggestions. | 470 // Press tab to accept the autofill suggestions. |
558 SendKeyToPopupAndWait(ui::VKEY_TAB); | 471 SendKeyToPopupAndWait(ui::VKEY_TAB); |
559 | 472 |
560 // The form should be filled. | 473 // The form should be filled. |
561 ExpectFilledTestForm(); | 474 ExpectFilledTestForm(); |
562 } | 475 } |
563 | 476 |
564 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaClick) { | 477 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaClick) { |
565 CreateTestProfile(); | 478 CreateTestProfile(browser()); |
566 | 479 |
567 // Load the test page. | 480 // Load the test page. |
568 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 481 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
569 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); | 482 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); |
570 // Focus a fillable field. | 483 // Focus a fillable field. |
571 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); | 484 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); |
572 | 485 |
573 // Now click it. | 486 // Now click it. |
574 test_delegate()->Reset(); | 487 test_delegate()->Reset(); |
575 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 488 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
576 test_delegate()->Wait(); | 489 test_delegate()->Wait(); |
577 | 490 |
578 // Press the down arrow to select the suggestion and preview the autofilled | 491 // Press the down arrow to select the suggestion and preview the autofilled |
579 // form. | 492 // form. |
580 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 493 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
581 | 494 |
582 // Press Enter to accept the autofill suggestions. | 495 // Press Enter to accept the autofill suggestions. |
583 SendKeyToPopupAndWait(ui::VKEY_RETURN); | 496 SendKeyToPopupAndWait(ui::VKEY_RETURN); |
584 | 497 |
585 // The form should be filled. | 498 // The form should be filled. |
586 ExpectFilledTestForm(); | 499 ExpectFilledTestForm(); |
587 } | 500 } |
588 | 501 |
589 // Makes sure that the first click does *not* activate the popup. | 502 // Makes sure that the first click does *not* activate the popup. |
590 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForFirstClick) { | 503 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForFirstClick) { |
591 CreateTestProfile(); | 504 CreateTestProfile(browser()); |
592 | 505 |
593 // Load the test page. | 506 // Load the test page. |
594 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 507 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
595 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); | 508 browser(), GURL(std::string(kDataURIPrefix) + kTestFormString))); |
596 | 509 |
597 // Click the first name field while it's out of focus, then twiddle our thumbs | 510 // Click the first name field while it's out of focus, then twiddle our thumbs |
598 // a bit. If a popup were to show, it would hit the asserts in | 511 // a bit. If a popup were to show, it would hit the asserts in |
599 // AutofillManagerTestDelegateImpl while we're wasting time. | 512 // AutofillManagerTestDelegateImpl while we're wasting time. |
600 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 513 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
601 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); | 514 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); |
602 | 515 |
603 // The second click should activate the popup since the first click focused | 516 // The second click should activate the popup since the first click focused |
604 // the field. | 517 // the field. |
605 test_delegate()->Reset(); | 518 test_delegate()->Reset(); |
606 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 519 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
607 test_delegate()->Wait(); | 520 test_delegate()->Wait(); |
608 } | 521 } |
609 | 522 |
610 // Makes sure that clicking outside the focused field doesn't activate | 523 // Makes sure that clicking outside the focused field doesn't activate |
611 // the popup. | 524 // the popup. |
612 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForOutsideClick) { | 525 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForOutsideClick) { |
613 CreateTestProfile(); | 526 CreateTestProfile(browser()); |
614 | 527 |
615 // Load the test page. | 528 // Load the test page. |
616 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( | 529 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL( |
617 browser(), | 530 browser(), |
618 GURL(std::string(kDataURIPrefix) + kTestFormString + | 531 GURL(std::string(kDataURIPrefix) + kTestFormString + |
619 "<button disabled id='disabled-button'>Cant click this</button>"))); | 532 "<button disabled id='disabled-button'>Cant click this</button>"))); |
620 | 533 |
621 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); | 534 ASSERT_NO_FATAL_FAILURE(FocusFirstNameField()); |
622 | 535 |
623 // Clicking a disabled button will generate a mouse event but focus doesn't | 536 // Clicking a disabled button will generate a mouse event but focus doesn't |
624 // change. This tests that autofill can handle a mouse event outside a focused | 537 // change. This tests that autofill can handle a mouse event outside a focused |
625 // input *without* showing the popup. | 538 // input *without* showing the popup. |
626 ASSERT_NO_FATAL_FAILURE(ClickElementWithId("disabled-button")); | 539 ASSERT_NO_FATAL_FAILURE(ClickElementWithId("disabled-button")); |
627 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); | 540 ASSERT_NO_FATAL_FAILURE(MakeSurePopupDoesntAppear()); |
628 | 541 |
629 test_delegate()->Reset(); | 542 test_delegate()->Reset(); |
630 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); | 543 ASSERT_NO_FATAL_FAILURE(ClickFirstNameField()); |
631 test_delegate()->Wait(); | 544 test_delegate()->Wait(); |
632 } | 545 } |
633 | 546 |
634 // Test that a field is still autofillable after the previously autofilled | 547 // Test that a field is still autofillable after the previously autofilled |
635 // value is deleted. | 548 // value is deleted. |
636 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnDeleteValueAfterAutofill) { | 549 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnDeleteValueAfterAutofill) { |
637 CreateTestProfile(); | 550 CreateTestProfile(browser()); |
638 | 551 |
639 // Load the test page. | 552 // Load the test page. |
640 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 553 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
641 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 554 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
642 | 555 |
643 // Invoke and accept the Autofill popup and verify the form was filled. | 556 // Invoke and accept the Autofill popup and verify the form was filled. |
644 FocusFirstNameField(); | 557 FocusFirstNameField(); |
645 SendKeyToPageAndWait(ui::VKEY_M); | 558 SendKeyToPageAndWait(ui::VKEY_M); |
646 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 559 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
647 SendKeyToPopupAndWait(ui::VKEY_RETURN); | 560 SendKeyToPopupAndWait(ui::VKEY_RETURN); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 SendKeyToDataListPopup(ui::VKEY_DOWN); | 605 SendKeyToDataListPopup(ui::VKEY_DOWN); |
693 SendKeyToDataListPopup(ui::VKEY_RETURN); | 606 SendKeyToDataListPopup(ui::VKEY_RETURN); |
694 ExpectFieldValue("firstname", "Adam"); | 607 ExpectFieldValue("firstname", "Adam"); |
695 std::string color; | 608 std::string color; |
696 GetFieldBackgroundColor("firstname", &color); | 609 GetFieldBackgroundColor("firstname", &color); |
697 EXPECT_EQ(color, orginalcolor); | 610 EXPECT_EQ(color, orginalcolor); |
698 } | 611 } |
699 | 612 |
700 // Test that a JavaScript oninput event is fired after auto-filling a form. | 613 // Test that a JavaScript oninput event is fired after auto-filling a form. |
701 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) { | 614 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) { |
702 CreateTestProfile(); | 615 CreateTestProfile(browser()); |
703 | 616 |
704 const char kOnInputScript[] = | 617 const char kOnInputScript[] = |
705 "<script>" | 618 "<script>" |
706 "focused_fired = false;" | 619 "focused_fired = false;" |
707 "unfocused_fired = false;" | 620 "unfocused_fired = false;" |
708 "changed_select_fired = false;" | 621 "changed_select_fired = false;" |
709 "unchanged_select_fired = false;" | 622 "unchanged_select_fired = false;" |
710 "document.getElementById('firstname').oninput = function() {" | 623 "document.getElementById('firstname').oninput = function() {" |
711 " focused_fired = true;" | 624 " focused_fired = true;" |
712 "};" | 625 "};" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 "domAutomationController.send(unchanged_select_fired);", | 677 "domAutomationController.send(unchanged_select_fired);", |
765 &unchanged_select_fired)); | 678 &unchanged_select_fired)); |
766 EXPECT_TRUE(focused_fired); | 679 EXPECT_TRUE(focused_fired); |
767 EXPECT_TRUE(unfocused_fired); | 680 EXPECT_TRUE(unfocused_fired); |
768 EXPECT_TRUE(changed_select_fired); | 681 EXPECT_TRUE(changed_select_fired); |
769 EXPECT_FALSE(unchanged_select_fired); | 682 EXPECT_FALSE(unchanged_select_fired); |
770 } | 683 } |
771 | 684 |
772 // Test that a JavaScript onchange event is fired after auto-filling a form. | 685 // Test that a JavaScript onchange event is fired after auto-filling a form. |
773 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnChangeAfterAutofill) { | 686 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnChangeAfterAutofill) { |
774 CreateTestProfile(); | 687 CreateTestProfile(browser()); |
775 | 688 |
776 const char kOnChangeScript[] = | 689 const char kOnChangeScript[] = |
777 "<script>" | 690 "<script>" |
778 "focused_fired = false;" | 691 "focused_fired = false;" |
779 "unfocused_fired = false;" | 692 "unfocused_fired = false;" |
780 "changed_select_fired = false;" | 693 "changed_select_fired = false;" |
781 "unchanged_select_fired = false;" | 694 "unchanged_select_fired = false;" |
782 "document.getElementById('firstname').onchange = function() {" | 695 "document.getElementById('firstname').onchange = function() {" |
783 " focused_fired = true;" | 696 " focused_fired = true;" |
784 "};" | 697 "};" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 GetRenderViewHost(), | 748 GetRenderViewHost(), |
836 "domAutomationController.send(unchanged_select_fired);", | 749 "domAutomationController.send(unchanged_select_fired);", |
837 &unchanged_select_fired)); | 750 &unchanged_select_fired)); |
838 EXPECT_TRUE(focused_fired); | 751 EXPECT_TRUE(focused_fired); |
839 EXPECT_TRUE(unfocused_fired); | 752 EXPECT_TRUE(unfocused_fired); |
840 EXPECT_TRUE(changed_select_fired); | 753 EXPECT_TRUE(changed_select_fired); |
841 EXPECT_FALSE(unchanged_select_fired); | 754 EXPECT_FALSE(unchanged_select_fired); |
842 } | 755 } |
843 | 756 |
844 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, InputFiresBeforeChange) { | 757 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, InputFiresBeforeChange) { |
845 CreateTestProfile(); | 758 CreateTestProfile(browser()); |
846 | 759 |
847 const char kInputFiresBeforeChangeScript[] = | 760 const char kInputFiresBeforeChangeScript[] = |
848 "<script>" | 761 "<script>" |
849 "inputElementEvents = [];" | 762 "inputElementEvents = [];" |
850 "function recordInputElementEvent(e) {" | 763 "function recordInputElementEvent(e) {" |
851 " if (e.target.tagName != 'INPUT') throw 'only <input> tags allowed';" | 764 " if (e.target.tagName != 'INPUT') throw 'only <input> tags allowed';" |
852 " inputElementEvents.push(e.type);" | 765 " inputElementEvents.push(e.type);" |
853 "}" | 766 "}" |
854 "selectElementEvents = [];" | 767 "selectElementEvents = [];" |
855 "function recordSelectElementEvent(e) {" | 768 "function recordSelectElementEvent(e) {" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 "domAutomationController.send(selectElementEvents[1]);", | 828 "domAutomationController.send(selectElementEvents[1]);", |
916 &select_element_events[1])); | 829 &select_element_events[1])); |
917 | 830 |
918 EXPECT_EQ("input", select_element_events[0]); | 831 EXPECT_EQ("input", select_element_events[0]); |
919 EXPECT_EQ("change", select_element_events[1]); | 832 EXPECT_EQ("change", select_element_events[1]); |
920 } | 833 } |
921 | 834 |
922 // Test that we can autofill forms distinguished only by their |id| attribute. | 835 // Test that we can autofill forms distinguished only by their |id| attribute. |
923 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 836 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
924 AutofillFormsDistinguishedById) { | 837 AutofillFormsDistinguishedById) { |
925 CreateTestProfile(); | 838 CreateTestProfile(browser()); |
926 | 839 |
927 // Load the test page. | 840 // Load the test page. |
928 const std::string kURL = | 841 const std::string kURL = |
929 std::string(kDataURIPrefix) + kTestFormString + | 842 std::string(kDataURIPrefix) + kTestFormString + |
930 "<script>" | 843 "<script>" |
931 "var mainForm = document.forms[0];" | 844 "var mainForm = document.forms[0];" |
932 "mainForm.id = 'mainForm';" | 845 "mainForm.id = 'mainForm';" |
933 "var newForm = document.createElement('form');" | 846 "var newForm = document.createElement('form');" |
934 "newForm.action = mainForm.action;" | 847 "newForm.action = mainForm.action;" |
935 "newForm.method = mainForm.method;" | 848 "newForm.method = mainForm.method;" |
936 "newForm.id = 'newForm';" | 849 "newForm.id = 'newForm';" |
937 "mainForm.parentNode.insertBefore(newForm, mainForm);" | 850 "mainForm.parentNode.insertBefore(newForm, mainForm);" |
938 "</script>"; | 851 "</script>"; |
939 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL))); | 852 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL))); |
940 | 853 |
941 // Invoke Autofill. | 854 // Invoke Autofill. |
942 TryBasicFormFill(); | 855 TryBasicFormFill(); |
943 } | 856 } |
944 | 857 |
945 // Test that we properly autofill forms with repeated fields. | 858 // Test that we properly autofill forms with repeated fields. |
946 // In the wild, the repeated fields are typically either email fields | 859 // In the wild, the repeated fields are typically either email fields |
947 // (duplicated for "confirmation"); or variants that are hot-swapped via | 860 // (duplicated for "confirmation"); or variants that are hot-swapped via |
948 // JavaScript, with only one actually visible at any given time. | 861 // JavaScript, with only one actually visible at any given time. |
949 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillFormWithRepeatedField) { | 862 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillFormWithRepeatedField) { |
950 CreateTestProfile(); | 863 CreateTestProfile(browser()); |
951 | 864 |
952 // Load the test page. | 865 // Load the test page. |
953 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 866 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
954 GURL(std::string(kDataURIPrefix) + | 867 GURL(std::string(kDataURIPrefix) + |
955 "<form action=\"http://www.example.com/\" method=\"POST\">" | 868 "<form action=\"http://www.example.com/\" method=\"POST\">" |
956 "<label for=\"firstname\">First name:</label>" | 869 "<label for=\"firstname\">First name:</label>" |
957 " <input type=\"text\" id=\"firstname\"" | 870 " <input type=\"text\" id=\"firstname\"" |
958 " onfocus=\"domAutomationController.send(true)\"><br>" | 871 " onfocus=\"domAutomationController.send(true)\"><br>" |
959 "<label for=\"lastname\">Last name:</label>" | 872 "<label for=\"lastname\">Last name:</label>" |
960 " <input type=\"text\" id=\"lastname\"><br>" | 873 " <input type=\"text\" id=\"lastname\"><br>" |
(...skipping 25 matching lines...) Expand all Loading... |
986 "</form>"))); | 899 "</form>"))); |
987 | 900 |
988 // Invoke Autofill. | 901 // Invoke Autofill. |
989 TryBasicFormFill(); | 902 TryBasicFormFill(); |
990 ExpectFieldValue("state_freeform", std::string()); | 903 ExpectFieldValue("state_freeform", std::string()); |
991 } | 904 } |
992 | 905 |
993 // Test that we properly autofill forms with non-autofillable fields. | 906 // Test that we properly autofill forms with non-autofillable fields. |
994 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 907 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
995 AutofillFormWithNonAutofillableField) { | 908 AutofillFormWithNonAutofillableField) { |
996 CreateTestProfile(); | 909 CreateTestProfile(browser()); |
997 | 910 |
998 // Load the test page. | 911 // Load the test page. |
999 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 912 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1000 GURL(std::string(kDataURIPrefix) + | 913 GURL(std::string(kDataURIPrefix) + |
1001 "<form action=\"http://www.example.com/\" method=\"POST\">" | 914 "<form action=\"http://www.example.com/\" method=\"POST\">" |
1002 "<label for=\"firstname\">First name:</label>" | 915 "<label for=\"firstname\">First name:</label>" |
1003 " <input type=\"text\" id=\"firstname\"" | 916 " <input type=\"text\" id=\"firstname\"" |
1004 " onfocus=\"domAutomationController.send(true)\"><br>" | 917 " onfocus=\"domAutomationController.send(true)\"><br>" |
1005 "<label for=\"middlename\">Middle name:</label>" | 918 "<label for=\"middlename\">Middle name:</label>" |
1006 " <input type=\"text\" id=\"middlename\" autocomplete=\"off\" /><br>" | 919 " <input type=\"text\" id=\"middlename\" autocomplete=\"off\" /><br>" |
(...skipping 22 matching lines...) Expand all Loading... |
1029 "<label for=\"phone\">Phone number:</label>" | 942 "<label for=\"phone\">Phone number:</label>" |
1030 " <input type=\"text\" id=\"phone\"><br>" | 943 " <input type=\"text\" id=\"phone\"><br>" |
1031 "</form>"))); | 944 "</form>"))); |
1032 | 945 |
1033 // Invoke Autofill. | 946 // Invoke Autofill. |
1034 TryBasicFormFill(); | 947 TryBasicFormFill(); |
1035 } | 948 } |
1036 | 949 |
1037 // Test that we can Autofill dynamically generated forms. | 950 // Test that we can Autofill dynamically generated forms. |
1038 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DynamicFormFill) { | 951 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DynamicFormFill) { |
1039 CreateTestProfile(); | 952 CreateTestProfile(browser()); |
1040 | 953 |
1041 // Load the test page. | 954 // Load the test page. |
1042 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 955 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1043 GURL(std::string(kDataURIPrefix) + | 956 GURL(std::string(kDataURIPrefix) + |
1044 "<form id=\"form\" action=\"http://www.example.com/\"" | 957 "<form id=\"form\" action=\"http://www.example.com/\"" |
1045 " method=\"POST\"></form>" | 958 " method=\"POST\"></form>" |
1046 "<script>" | 959 "<script>" |
1047 "function AddElement(name, label) {" | 960 "function AddElement(name, label) {" |
1048 " var form = document.getElementById('form');" | 961 " var form = document.getElementById('form');" |
1049 "" | 962 "" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 | 1030 |
1118 // Dynamically construct the form. | 1031 // Dynamically construct the form. |
1119 ASSERT_TRUE(content::ExecuteScript(GetRenderViewHost(), "BuildForm();")); | 1032 ASSERT_TRUE(content::ExecuteScript(GetRenderViewHost(), "BuildForm();")); |
1120 | 1033 |
1121 // Invoke Autofill. | 1034 // Invoke Autofill. |
1122 TryBasicFormFill(); | 1035 TryBasicFormFill(); |
1123 } | 1036 } |
1124 | 1037 |
1125 // Test that form filling works after reloading the current page. | 1038 // Test that form filling works after reloading the current page. |
1126 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterReload) { | 1039 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterReload) { |
1127 CreateTestProfile(); | 1040 CreateTestProfile(browser()); |
1128 | 1041 |
1129 // Load the test page. | 1042 // Load the test page. |
1130 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1043 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1131 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 1044 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
1132 | 1045 |
1133 // Reload the page. | 1046 // Reload the page. |
1134 content::WebContents* web_contents = GetWebContents(); | 1047 content::WebContents* web_contents = GetWebContents(); |
1135 web_contents->GetController().Reload(false); | 1048 web_contents->GetController().Reload(false); |
1136 content::WaitForLoadStop(web_contents); | 1049 content::WaitForLoadStop(web_contents); |
1137 | 1050 |
1138 // Invoke Autofill. | 1051 // Invoke Autofill. |
1139 TryBasicFormFill(); | 1052 TryBasicFormFill(); |
1140 } | 1053 } |
1141 | 1054 |
1142 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterTranslate) { | 1055 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterTranslate) { |
1143 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 1056 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
1144 if (TranslateService::IsTranslateBubbleEnabled()) | 1057 if (TranslateService::IsTranslateBubbleEnabled()) |
1145 return; | 1058 return; |
1146 | 1059 |
1147 CreateTestProfile(); | 1060 CreateTestProfile(browser()); |
1148 | 1061 |
1149 GURL url(std::string(kDataURIPrefix) + | 1062 GURL url(std::string(kDataURIPrefix) + |
1150 "<form action=\"http://www.example.com/\" method=\"POST\">" | 1063 "<form action=\"http://www.example.com/\" method=\"POST\">" |
1151 "<label for=\"fn\">なまえ</label>" | 1064 "<label for=\"fn\">なまえ</label>" |
1152 " <input type=\"text\" id=\"fn\"" | 1065 " <input type=\"text\" id=\"fn\"" |
1153 " onfocus=\"domAutomationController.send(true)\"" | 1066 " onfocus=\"domAutomationController.send(true)\"" |
1154 "><br>" | 1067 "><br>" |
1155 "<label for=\"ln\">みょうじ</label>" | 1068 "<label for=\"ln\">みょうじ</label>" |
1156 " <input type=\"text\" id=\"ln\"><br>" | 1069 " <input type=\"text\" id=\"ln\"><br>" |
1157 "<label for=\"a1\">Address line 1:</label>" | 1070 "<label for=\"a1\">Address line 1:</label>" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 | 1202 |
1290 // Test form is fillable from a profile after form was reset. | 1203 // Test form is fillable from a profile after form was reset. |
1291 // Steps: | 1204 // Steps: |
1292 // 1. Fill form using a saved profile. | 1205 // 1. Fill form using a saved profile. |
1293 // 2. Reset the form. | 1206 // 2. Reset the form. |
1294 // 3. Fill form using a saved profile. | 1207 // 3. Fill form using a saved profile. |
1295 // Flakily times out: http://crbug.com/270341 | 1208 // Flakily times out: http://crbug.com/270341 |
1296 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DISABLED_FormFillableOnReset) { | 1209 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DISABLED_FormFillableOnReset) { |
1297 ASSERT_TRUE(test_server()->Start()); | 1210 ASSERT_TRUE(test_server()->Start()); |
1298 | 1211 |
1299 CreateTestProfile(); | 1212 CreateTestProfile(browser()); |
1300 | 1213 |
1301 GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html"); | 1214 GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html"); |
1302 ui_test_utils::NavigateToURL(browser(), url); | 1215 ui_test_utils::NavigateToURL(browser(), url); |
1303 PopulateForm("NAME_FIRST"); | 1216 PopulateForm("NAME_FIRST"); |
1304 | 1217 |
1305 ASSERT_TRUE(content::ExecuteScript( | 1218 ASSERT_TRUE(content::ExecuteScript( |
1306 GetWebContents(), "document.getElementById('testform').reset()")); | 1219 GetWebContents(), "document.getElementById('testform').reset()")); |
1307 | 1220 |
1308 PopulateForm("NAME_FIRST"); | 1221 PopulateForm("NAME_FIRST"); |
1309 | 1222 |
1310 ExpectFieldValue("NAME_FIRST", "Milton"); | 1223 ExpectFieldValue("NAME_FIRST", "Milton"); |
1311 ExpectFieldValue("NAME_LAST", "Waddams"); | 1224 ExpectFieldValue("NAME_LAST", "Waddams"); |
1312 ExpectFieldValue("EMAIL_ADDRESS", "red.swingline@initech.com"); | 1225 ExpectFieldValue("EMAIL_ADDRESS", "red.swingline@initech.com"); |
1313 ExpectFieldValue("ADDRESS_HOME_LINE1", "4120 Freidrich Lane"); | 1226 ExpectFieldValue("ADDRESS_HOME_LINE1", "4120 Freidrich Lane"); |
1314 ExpectFieldValue("ADDRESS_HOME_CITY", "Austin"); | 1227 ExpectFieldValue("ADDRESS_HOME_CITY", "Austin"); |
1315 ExpectFieldValue("ADDRESS_HOME_STATE", "Texas"); | 1228 ExpectFieldValue("ADDRESS_HOME_STATE", "Texas"); |
1316 ExpectFieldValue("ADDRESS_HOME_ZIP", "78744"); | 1229 ExpectFieldValue("ADDRESS_HOME_ZIP", "78744"); |
1317 ExpectFieldValue("ADDRESS_HOME_COUNTRY", "United States"); | 1230 ExpectFieldValue("ADDRESS_HOME_COUNTRY", "United States"); |
1318 ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "5125551234"); | 1231 ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "5125551234"); |
1319 } | 1232 } |
1320 | 1233 |
1321 // Test Autofill distinguishes a middle initial in a name. | 1234 // Test Autofill distinguishes a middle initial in a name. |
1322 // Flakily times out: http://crbug.com/270341 | 1235 // Flakily times out: http://crbug.com/270341 |
1323 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1236 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
1324 DISABLED_DistinguishMiddleInitialWithinName) { | 1237 DISABLED_DistinguishMiddleInitialWithinName) { |
1325 ASSERT_TRUE(test_server()->Start()); | 1238 ASSERT_TRUE(test_server()->Start()); |
1326 | 1239 |
1327 CreateTestProfile(); | 1240 CreateTestProfile(browser()); |
1328 | 1241 |
1329 GURL url = test_server()->GetURL( | 1242 GURL url = test_server()->GetURL( |
1330 "files/autofill/autofill_middleinit_form.html"); | 1243 "files/autofill/autofill_middleinit_form.html"); |
1331 ui_test_utils::NavigateToURL(browser(), url); | 1244 ui_test_utils::NavigateToURL(browser(), url); |
1332 PopulateForm("NAME_FIRST"); | 1245 PopulateForm("NAME_FIRST"); |
1333 | 1246 |
1334 ExpectFieldValue("NAME_MIDDLE", "C"); | 1247 ExpectFieldValue("NAME_MIDDLE", "C"); |
1335 } | 1248 } |
1336 | 1249 |
1337 // Test forms with multiple email addresses are filled properly. | 1250 // Test forms with multiple email addresses are filled properly. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 "document.getElementById('testform').submit();")); | 1341 "document.getElementById('testform').submit();")); |
1429 // This will ensure the test didn't hang. | 1342 // This will ensure the test didn't hang. |
1430 load_stop_observer.Wait(); | 1343 load_stop_observer.Wait(); |
1431 } | 1344 } |
1432 | 1345 |
1433 // Test that Chrome doesn't crash when autocomplete is disabled while the user | 1346 // Test that Chrome doesn't crash when autocomplete is disabled while the user |
1434 // is interacting with the form. This is a regression test for | 1347 // is interacting with the form. This is a regression test for |
1435 // http://crbug.com/160476 | 1348 // http://crbug.com/160476 |
1436 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, | 1349 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, |
1437 DisableAutocompleteWhileFilling) { | 1350 DisableAutocompleteWhileFilling) { |
1438 CreateTestProfile(); | 1351 CreateTestProfile(browser()); |
1439 | 1352 |
1440 // Load the test page. | 1353 // Load the test page. |
1441 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1354 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
1442 GURL(std::string(kDataURIPrefix) + kTestFormString))); | 1355 GURL(std::string(kDataURIPrefix) + kTestFormString))); |
1443 | 1356 |
1444 // Invoke Autofill: Start filling the first name field with "M" and wait for | 1357 // Invoke Autofill: Start filling the first name field with "M" and wait for |
1445 // the popup to be shown. | 1358 // the popup to be shown. |
1446 FocusFirstNameField(); | 1359 FocusFirstNameField(); |
1447 SendKeyToPageAndWait(ui::VKEY_M); | 1360 SendKeyToPageAndWait(ui::VKEY_M); |
1448 | 1361 |
1449 // Now that the popup with suggestions is showing, disable autocomplete for | 1362 // Now that the popup with suggestions is showing, disable autocomplete for |
1450 // the active field. | 1363 // the active field. |
1451 ASSERT_TRUE(content::ExecuteScript( | 1364 ASSERT_TRUE(content::ExecuteScript( |
1452 GetRenderViewHost(), | 1365 GetRenderViewHost(), |
1453 "document.querySelector('input').autocomplete = 'off';")); | 1366 "document.querySelector('input').autocomplete = 'off';")); |
1454 | 1367 |
1455 // Press the down arrow to select the suggestion and attempt to preview the | 1368 // Press the down arrow to select the suggestion and attempt to preview the |
1456 // autofilled form. | 1369 // autofilled form. |
1457 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1370 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
1458 } | 1371 } |
1459 | 1372 |
1460 } // namespace autofill | 1373 } // namespace autofill |
OLD | NEW |