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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_interactive_uitest.cc
diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc
index a641fa6bb9ca09f5de82504045c2b5e2d20c840d..bb649a7e239bfc15fea1c4321516ecd9b1677353 100644
--- a/chrome/browser/autofill/autofill_interactive_uitest.cc
+++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
@@ -294,6 +294,16 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
EXPECT_EQ(expected_value, value);
}
+ void GetFieldBackgroundColor(const std::string& field_name,
+ std::string* color) {
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ GetWebContents(),
+ "window.domAutomationController.send("
+ " document.defaultView.getComputedStyle(document.getElementById('" +
+ field_name + "')).backgroundColor);",
+ color));
+ }
+
void SimulateURLFetch(bool success) {
net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
@@ -423,6 +433,20 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_);
}
+ // Datalist does not support autofill preview. There is no need to start
+ // message loop for Datalist.
+ void SendKeyToDataListPopup(ui::KeyboardCode key) {
+ // Route popup-targeted key presses via the render view host.
+ content::NativeWebKeyboardEvent event;
+ event.windowsKeyCode = key;
+ event.type = blink::WebKeyboardEvent::RawKeyDown;
+ // Install the key press event sink to ensure that any events that are not
+ // handled by the installed callbacks do not end up crashing the test.
+ GetRenderViewHost()->AddKeyPressEventCallback(key_press_event_sink_);
+ GetRenderViewHost()->ForwardKeyboardEvent(event);
+ GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_);
+ }
+
void TryBasicFormFill() {
FocusFirstNameField();
@@ -634,6 +658,35 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnDeleteValueAfterAutofill) {
ExpectFieldValue("firstname", "Milton");
}
+// Test that an input field is not rendered with the yellow autofilled
+// background color when choosing an option from the datalist suggestion list.
+IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnSelectOptionFromDatalist) {
+ // Load the test page.
+ ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
+ browser(),
+ GURL(std::string(kDataURIPrefix) +
+ "<form action=\"http://www.example.com/\" method=\"POST\">"
+ " <input list=\"dl\" type=\"search\" id=\"firstname\""
+ " onfocus=\"domAutomationController.send(true)\"><br>"
+ " <datalist id=\"dl\">"
+ " <option value=\"Adam\"></option>"
+ " <option value=\"Bob\"></option>"
+ " <option value=\"Carl\"></option>"
+ " </datalist>"
+ "</form>")));
+ std::string orginalcolor;
+ GetFieldBackgroundColor("firstname", &orginalcolor);
+
+ FocusFirstNameField();
+ SendKeyToPageAndWait(ui::VKEY_DOWN);
+ SendKeyToDataListPopup(ui::VKEY_DOWN);
+ SendKeyToDataListPopup(ui::VKEY_RETURN);
+ ExpectFieldValue("firstname", "Adam");
+ std::string color;
+ GetFieldBackgroundColor("firstname", &color);
+ EXPECT_EQ(color, orginalcolor);
+}
+
// Test that a JavaScript oninput event is fired after auto-filling a form.
IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) {
CreateTestProfile();
« 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