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

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: Add test file. 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..3a3c37bd6d7945b87242be9ea7580371e478a196 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) {
Ilya Sherman 2014/08/22 23:49:17 nit: Please pass a pointer. We pretty much never
ziran.sun 2014/08/26 13:32:15 Done.
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ GetWebContents(),
+ "window.domAutomationController.send("
+ " document.defaultView.getComputedStyle(document.getElementById('" +
+ field_name + "')).backgroundColor);",
Ilya Sherman 2014/08/22 23:49:17 nit: The current indentation looks really odd. I'
ziran.sun 2014/08/26 13:32:15 I tried both suggestions, "git cl format" doesn't
Ilya Sherman 2014/08/27 00:37:47 I understand that this is the format that "git cl
+ &color));
+ }
+
void SimulateURLFetch(bool success) {
net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
@@ -423,6 +433,19 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
GetRenderViewHost()->RemoveKeyPressEventCallback(key_press_event_sink_);
}
+ // There is no need to start message loop for Datalist.
Ilya Sherman 2014/08/22 23:49:17 Hmm, why not? Doesn't it use the same UI? Even i
ziran.sun 2014/08/26 13:32:15 Existing test cases in this test file assume that
Ilya Sherman 2014/08/27 00:37:47 I see. That makes sense; thanks for the explanati
+ 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 +657,35 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnDeleteValueAfterAutofill) {
ExpectFieldValue("firstname", "Milton");
}
+// Test that an input field should not be autofilled when choose an option from
+// its datalist option list.
Ilya Sherman 2014/08/22 23:49:17 nit: Perhaps something like "Test that an input fi
ziran.sun 2014/08/26 13:32:15 Done.
+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\""
Ilya Sherman 2014/08/22 23:49:17 nit: Please indent this line, and the ones below,
ziran.sun 2014/08/26 13:32:15 Done.
+ " onfocus=\"domAutomationController.send(true)\"><br>"
+ " <datalist id=\"dl\">"
Ilya Sherman 2014/08/22 23:49:17 nit: Why does the datalist need an id? Would the
ziran.sun 2014/08/26 13:32:15 I think the minimum argument for datalist tag is t
+ " <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