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

Unified Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 2478803003: Remove DOMAutomationController::automation_id_ (Closed)
Patch Set: Rebasing... Created 3 years, 5 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 | chrome/browser/captive_portal/captive_portal_browsertest.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 d151972248d007b22205288c1c2148ccbc8a234e..44b3367e7134035e47a1cc2f2d86905b306374e6 100644
--- a/chrome/browser/autofill/autofill_interactive_uitest.cc
+++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
@@ -12,6 +12,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -69,8 +70,7 @@ static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,";
static const char kTestFormString[] =
"<form action=\"http://www.example.com/\" method=\"POST\">"
"<label for=\"firstname\">First name:</label>"
- " <input type=\"text\" id=\"firstname\""
- " onfocus=\"domAutomationController.send(true)\"><br>"
+ " <input type=\"text\" id=\"firstname\"><br>"
"<label for=\"lastname\">Last name:</label>"
" <input type=\"text\" id=\"lastname\"><br>"
"<label for=\"address1\">Address line 1:</label>"
@@ -120,8 +120,7 @@ static const char kTestEventFormString[] =
"</script>"
"<form action=\"http://www.example.com/\" method=\"POST\">"
"<label for=\"firstname\">First name:</label>"
- " <input type=\"text\" id=\"firstname\""
- " onfocus=\"domAutomationController.send(true)\"><br>"
+ " <input type=\"text\" id=\"firstname\"><br>"
"<label for=\"lastname\">Last name:</label>"
" <input type=\"text\" id=\"lastname\""
" onfocus=\"inputfocus = true\" onkeydown=\"inputkeydown = true\""
@@ -359,27 +358,25 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
void FocusFieldByName(const std::string& name) {
bool result = false;
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- GetRenderViewHost(),
- "if (document.readyState === 'complete')"
- " document.getElementById('" + name + "').focus();"
- "else"
- " domAutomationController.send(false);",
- &result));
+ std::string script = base::StringPrintf(
+ R"( function onFocusHandler(e) {
+ e.target.removeEventListener(e.type, arguments.callee);
+ domAutomationController.send(true);
+ }
+ if (document.readyState === 'complete') {
+ var target = document.getElementById('%s');
+ target.addEventListener('focus', onFocusHandler);
+ target.focus();
+ } else {
+ domAutomationController.send(false);
+ })",
+ name.c_str());
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(GetRenderViewHost(),
+ script, &result));
ASSERT_TRUE(result);
}
- void FocusFirstNameField() {
- bool result = false;
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- GetRenderViewHost(),
- "if (document.readyState === 'complete')"
- " document.getElementById('firstname').focus();"
- "else"
- " domAutomationController.send(false);",
- &result));
- ASSERT_TRUE(result);
- }
+ void FocusFirstNameField() { FocusFieldByName("firstname"); }
// Simulates a click on the middle of the DOM element with the given |id|.
void ClickElementWithId(const std::string& id) {
@@ -795,8 +792,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
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>"
+ " <input list=\"dl\" type=\"search\" id=\"firstname\"><br>"
" <datalist id=\"dl\">"
" <option value=\"Adam\"></option>"
" <option value=\"Bob\"></option>"
« no previous file with comments | « no previous file | chrome/browser/captive_portal/captive_portal_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698