summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-04 18:30:43 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-04 18:30:43 +0000
commitb6987e0e556a5f72e5e783aae0e30e883cf66f91 (patch)
treefb07c2c5803510285ef0d030d42eb6ced5a8d2b7 /chrome/browser/autofill
parent53bc1a4364a3a75344e20f94aedff2eca2f6f9af (diff)
downloadchromium_src-b6987e0e556a5f72e5e783aae0e30e883cf66f91.zip
chromium_src-b6987e0e556a5f72e5e783aae0e30e883cf66f91.tar.gz
chromium_src-b6987e0e556a5f72e5e783aae0e30e883cf66f91.tar.bz2
Simplify ExecuteJavaScript* functions.
Remove the "Java" and rename to ExecuteScript*. This better matches conventions elsewhere in the codebase. Introduce ExecuteScriptInFrame* variants for the less common case where script execution in a subframe is desired. Make it possible to pass the ExecuteScript* family of functions either a WebContents pointer or a RenderViewHost pointer to further simplify callsites. R=jam@chromium.org BUG=none Review URL: https://chromiumcodereview.appspot.com/11753009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc52
1 files changed, 18 insertions, 34 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index ab3cc2c..0c045d8 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -217,8 +217,7 @@ class AutofillTest : public InProcessBrowserTest {
js += "document.getElementById('testform').submit();";
WindowedPersonalDataManagerObserver observer(browser());
- ASSERT_TRUE(
- content::ExecuteJavaScript(render_view_host(), "", js));
+ ASSERT_TRUE(content::ExecuteScript(render_view_host(), js));
observer.Wait();
}
@@ -239,8 +238,7 @@ class AutofillTest : public InProcessBrowserTest {
// sends keypress events to the tab to cause the form to be populated.
void PopulateForm(const std::string& field_id) {
std::string js("document.getElementById('" + field_id + "').focus();");
- ASSERT_TRUE(
- content::ExecuteJavaScript(render_view_host(), "", js));
+ ASSERT_TRUE(content::ExecuteScript(render_view_host(), js));
SendKeyAndWait(ui::VKEY_DOWN,
chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
@@ -292,9 +290,8 @@ class AutofillTest : public InProcessBrowserTest {
void ExpectFieldValue(const std::string& field_name,
const std::string& expected_value) {
std::string value;
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
- chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
- "",
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ chrome::GetActiveWebContents(browser()),
"window.domAutomationController.send("
" document.getElementById('" + field_name + "').value);",
&value));
@@ -352,9 +349,8 @@ class AutofillTest : public InProcessBrowserTest {
LOG(WARNING) << "Focusing the first name field.";
bool result = false;
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"if (document.readyState === 'complete')"
" document.getElementById('firstname').focus();"
"else"
@@ -539,24 +535,20 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_OnChangeAfterAutofill) {
bool unfocused_fired = false;
bool changed_select_fired = false;
bool unchanged_select_fired = false;
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"domAutomationController.send(focused_fired);",
&focused_fired));
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"domAutomationController.send(unfocused_fired);",
&unfocused_fired));
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"domAutomationController.send(changed_select_fired);",
&changed_select_fired));
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"domAutomationController.send(unchanged_select_fired);",
&unchanged_select_fired));
EXPECT_FALSE(focused_fired);
@@ -565,9 +557,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_OnChangeAfterAutofill) {
EXPECT_FALSE(unchanged_select_fired);
// Unfocus the first name field. Its change event should fire.
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"document.getElementById('firstname').blur();"
"domAutomationController.send(focused_fired);", &focused_fired));
EXPECT_TRUE(focused_fired);
@@ -780,8 +771,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_DynamicFormFill) {
"</script>")));
// Dynamically construct the form.
- ASSERT_TRUE(content::ExecuteJavaScript(render_view_host(), "",
- "BuildForm();"));
+ ASSERT_TRUE(content::ExecuteScript(render_view_host(), "BuildForm();"));
// Invoke Autofill.
TryBasicFormFill();
@@ -879,10 +869,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) {
// Simulate translation to kick onTranslateElementLoad.
// But right now, the call stucks here.
// Once click the text field, it starts again.
- ASSERT_TRUE(content::ExecuteJavaScript(
- render_view_host(),
- "",
- "cr.googleTranslate.onTranslateElementLoad();"));
+ ASSERT_TRUE(content::ExecuteScript(
+ render_view_host(), "cr.googleTranslate.onTranslateElementLoad();"));
// Simulate the render notifying the translation has been done.
translation_observer.Wait();
@@ -1370,9 +1358,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillableOnReset) {
ui_test_utils::NavigateToURL(browser(), url);
PopulateForm("NAME_FIRST");
- ASSERT_TRUE(content::ExecuteJavaScript(
- chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
- "",
+ ASSERT_TRUE(content::ExecuteScript(
+ chrome::GetActiveWebContents(browser()),
"document.getElementById('testform').reset()"));
PopulateForm("NAME_FIRST");
@@ -1522,9 +1509,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillLatencyAfterSubmit) {
content::Source<content::NavigationController>(
&chrome::GetActiveWebContents(browser())->GetController()));
- ASSERT_TRUE(content::ExecuteJavaScript(
+ ASSERT_TRUE(content::ExecuteScript(
render_view_host(),
- "",
"document.getElementById('testform').submit();"));
// This will ensure the test didn't hang.
load_stop_observer.Wait();
@@ -1555,9 +1541,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) {
// Now that the popup with suggestions is showing, disable autocomplete for
// the active field.
- ASSERT_TRUE(content::ExecuteJavaScript(
+ ASSERT_TRUE(content::ExecuteScript(
render_view_host(),
- "",
"document.querySelector('input').autocomplete = 'off';"));
// Press the down arrow to select the suggestion and attempt to preview the
@@ -1568,9 +1553,8 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) {
// Wait for any IPCs to complete by performing an action that generates an
// IPC that's easy to wait for. Chrome shouldn't crash.
bool result = false;
- ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
render_view_host(),
- "",
"var city = document.getElementById('city');"
"city.onfocus = function() { domAutomationController.send(true); };"
"city.focus()",