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

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

Issue 498653003: Do not set autofill property for datalist options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust format. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const std::string& expected_value) { 287 const std::string& expected_value) {
288 std::string value; 288 std::string value;
289 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 289 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
290 GetWebContents(), 290 GetWebContents(),
291 "window.domAutomationController.send(" 291 "window.domAutomationController.send("
292 " document.getElementById('" + field_name + "').value);", 292 " document.getElementById('" + field_name + "').value);",
293 &value)); 293 &value));
294 EXPECT_EQ(expected_value, value); 294 EXPECT_EQ(expected_value, value);
295 } 295 }
296 296
297 void GetFieldBackgroundColor(const std::string& field_name,
298 std::string* color) {
299 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
300 GetWebContents(),
301 "window.domAutomationController.send("
302 " document.defaultView.getComputedStyle(document.getElementById('" +
303 field_name + "')).backgroundColor);",
304 color));
305 }
306
297 void SimulateURLFetch(bool success) { 307 void SimulateURLFetch(bool success) {
298 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 308 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
299 ASSERT_TRUE(fetcher); 309 ASSERT_TRUE(fetcher);
300 net::URLRequestStatus status; 310 net::URLRequestStatus status;
301 status.set_status(success ? net::URLRequestStatus::SUCCESS : 311 status.set_status(success ? net::URLRequestStatus::SUCCESS :
302 net::URLRequestStatus::FAILED); 312 net::URLRequestStatus::FAILED);
303 313
304 std::string script = " var google = {};" 314 std::string script = " var google = {};"
305 "google.translate = (function() {" 315 "google.translate = (function() {"
306 " return {" 316 " return {"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 event.type = blink::WebKeyboardEvent::RawKeyDown; 426 event.type = blink::WebKeyboardEvent::RawKeyDown;
417 test_delegate_.Reset(); 427 test_delegate_.Reset();
418 // Install the key press event sink to ensure that any events that are not 428 // Install the key press event sink to ensure that any events that are not
419 // handled by the installed callbacks do not end up crashing the test. 429 // handled by the installed callbacks do not end up crashing the test.
420 GetRenderViewHost()->AddKeyPressEventCallback(key_press_event_sink_); 430 GetRenderViewHost()->AddKeyPressEventCallback(key_press_event_sink_);
421 GetRenderViewHost()->ForwardKeyboardEvent(event); 431 GetRenderViewHost()->ForwardKeyboardEvent(event);
422 test_delegate_.Wait(); 432 test_delegate_.Wait();
423 GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_); 433 GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_);
424 } 434 }
425 435
436 // Datalist does not support autofill preview. There is no need to start
437 // message loop for Datalist.
438 void SendKeyToDataListPopup(ui::KeyboardCode key) {
439 // Route popup-targeted key presses via the render view host.
440 content::NativeWebKeyboardEvent event;
441 event.windowsKeyCode = key;
442 event.type = blink::WebKeyboardEvent::RawKeyDown;
443 // Install the key press event sink to ensure that any events that are not
444 // handled by the installed callbacks do not end up crashing the test.
445 GetRenderViewHost()->AddKeyPressEventCallback(key_press_event_sink_);
446 GetRenderViewHost()->ForwardKeyboardEvent(event);
447 GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_);
448 }
449
426 void TryBasicFormFill() { 450 void TryBasicFormFill() {
427 FocusFirstNameField(); 451 FocusFirstNameField();
428 452
429 // Start filling the first name field with "M" and wait for the popup to be 453 // Start filling the first name field with "M" and wait for the popup to be
430 // shown. 454 // shown.
431 SendKeyToPageAndWait(ui::VKEY_M); 455 SendKeyToPageAndWait(ui::VKEY_M);
432 456
433 // Press the down arrow to select the suggestion and preview the autofilled 457 // Press the down arrow to select the suggestion and preview the autofilled
434 // form. 458 // form.
435 SendKeyToPopupAndWait(ui::VKEY_DOWN); 459 SendKeyToPopupAndWait(ui::VKEY_DOWN);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 "document.getElementById('firstname').value = '';")); 651 "document.getElementById('firstname').value = '';"));
628 ExpectFieldValue("firstname", ""); 652 ExpectFieldValue("firstname", "");
629 653
630 // Invoke and accept the Autofill popup and verify the field was filled. 654 // Invoke and accept the Autofill popup and verify the field was filled.
631 SendKeyToPageAndWait(ui::VKEY_M); 655 SendKeyToPageAndWait(ui::VKEY_M);
632 SendKeyToPopupAndWait(ui::VKEY_DOWN); 656 SendKeyToPopupAndWait(ui::VKEY_DOWN);
633 SendKeyToPopupAndWait(ui::VKEY_RETURN); 657 SendKeyToPopupAndWait(ui::VKEY_RETURN);
634 ExpectFieldValue("firstname", "Milton"); 658 ExpectFieldValue("firstname", "Milton");
635 } 659 }
636 660
661 // Test that an input field is not rendered with the yellow autofilled
662 // background color when choosing an option from the datalist suggestion list.
663 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnSelectOptionFromDatalist) {
664 // Load the test page.
665 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
666 browser(),
667 GURL(std::string(kDataURIPrefix) +
668 "<form action=\"http://www.example.com/\" method=\"POST\">"
669 " <input list=\"dl\" type=\"search\" id=\"firstname\""
670 " onfocus=\"domAutomationController.send(true)\"><br>"
671 " <datalist id=\"dl\">"
672 " <option value=\"Adam\"></option>"
673 " <option value=\"Bob\"></option>"
674 " <option value=\"Carl\"></option>"
675 " </datalist>"
676 "</form>")));
677 std::string orginalcolor;
678 GetFieldBackgroundColor("firstname", &orginalcolor);
679
680 FocusFirstNameField();
681 SendKeyToPageAndWait(ui::VKEY_DOWN);
682 SendKeyToDataListPopup(ui::VKEY_DOWN);
683 SendKeyToDataListPopup(ui::VKEY_RETURN);
684 ExpectFieldValue("firstname", "Adam");
685 std::string color;
686 GetFieldBackgroundColor("firstname", &color);
687 EXPECT_EQ(color, orginalcolor);
688 }
689
637 // Test that a JavaScript oninput event is fired after auto-filling a form. 690 // Test that a JavaScript oninput event is fired after auto-filling a form.
638 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) { 691 IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) {
639 CreateTestProfile(); 692 CreateTestProfile();
640 693
641 const char kOnInputScript[] = 694 const char kOnInputScript[] =
642 "<script>" 695 "<script>"
643 "focused_fired = false;" 696 "focused_fired = false;"
644 "unfocused_fired = false;" 697 "unfocused_fired = false;"
645 "changed_select_fired = false;" 698 "changed_select_fired = false;"
646 "unchanged_select_fired = false;" 699 "unchanged_select_fired = false;"
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 ASSERT_TRUE(content::ExecuteScript( 1441 ASSERT_TRUE(content::ExecuteScript(
1389 GetRenderViewHost(), 1442 GetRenderViewHost(),
1390 "document.querySelector('input').autocomplete = 'off';")); 1443 "document.querySelector('input').autocomplete = 'off';"));
1391 1444
1392 // Press the down arrow to select the suggestion and attempt to preview the 1445 // Press the down arrow to select the suggestion and attempt to preview the
1393 // autofilled form. 1446 // autofilled form.
1394 SendKeyToPopupAndWait(ui::VKEY_DOWN); 1447 SendKeyToPopupAndWait(ui::VKEY_DOWN);
1395 } 1448 }
1396 1449
1397 } // namespace autofill 1450 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698