summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:02:33 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:02:33 +0000
commit2937a8c72bfd28188ccd0b3f3b54bc3303b5f537 (patch)
tree384b91fec1c7736bee9ce5e61055e84febe2fcd5 /chrome/test/automation
parentcdca989154d270a6553c1c8e2df0122b521b49eb (diff)
downloadchromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.zip
chromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.tar.gz
chromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.tar.bz2
Refactor error handling in chromedriver. Introduce new error class containing a webdriver error code, possible error details, and a stack trace.
Also some minor cleanup of the command files. BUG=none TEST=none Review URL: http://codereview.chromium.org/7042018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_json_requests.cc165
-rw-r--r--chrome/test/automation/automation_json_requests.h87
-rw-r--r--chrome/test/automation/tab_proxy.cc5
3 files changed, 163 insertions, 94 deletions
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index fe664ec..b679691 100644
--- a/chrome/test/automation/automation_json_requests.cc
+++ b/chrome/test/automation/automation_json_requests.cc
@@ -18,7 +18,8 @@ namespace {
bool SendAutomationJSONRequest(AutomationMessageSender* sender,
const DictionaryValue& request_dict,
- DictionaryValue* reply_dict) {
+ DictionaryValue* reply_dict,
+ std::string* error_msg) {
std::string request, reply;
base::JSONWriter::Write(&request_dict, false, &request);
bool success = false;
@@ -37,6 +38,7 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender,
std::string command, error;
request_dict.GetString("command", &command);
dict->GetString("error", &error);
+ *error_msg = error;
LOG(ERROR) << "JSON request failed: " << command << "\n"
<< " with error: " << error;
return false;
@@ -71,12 +73,13 @@ bool SendGetIndicesFromTabIdJSONRequest(
AutomationMessageSender* sender,
int tab_id,
int* browser_index,
- int* tab_index) {
+ int* tab_index,
+ std::string* error_msg) {
DictionaryValue request_dict;
request_dict.SetString("command", "GetIndicesFromTab");
request_dict.SetInteger("tab_id", tab_id);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, request_dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, request_dict, &reply_dict, error_msg))
return false;
if (!reply_dict.GetInteger("windex", browser_index))
return false;
@@ -89,12 +92,13 @@ bool SendGetIndicesFromTabHandleJSONRequest(
AutomationMessageSender* sender,
int tab_handle,
int* browser_index,
- int* tab_index) {
+ int* tab_index,
+ std::string* error_msg) {
DictionaryValue request_dict;
request_dict.SetString("command", "GetIndicesFromTab");
request_dict.SetInteger("tab_handle", tab_handle);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, request_dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, request_dict, &reply_dict, error_msg))
return false;
if (!reply_dict.GetInteger("windex", browser_index))
return false;
@@ -109,7 +113,8 @@ bool SendNavigateToURLJSONRequest(
int tab_index,
const GURL& url,
int navigation_count,
- AutomationMsg_NavigationResponseValues* nav_response) {
+ AutomationMsg_NavigationResponseValues* nav_response,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "NavigateToURL");
dict.SetInteger("windex", browser_index);
@@ -117,7 +122,7 @@ bool SendNavigateToURLJSONRequest(
dict.SetString("url", url.possibly_invalid_spec());
dict.SetInteger("navigation_count", navigation_count);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
int response = 0;
if (!reply_dict.GetInteger("result", &response))
@@ -132,7 +137,8 @@ bool SendExecuteJavascriptJSONRequest(
int tab_index,
const std::string& frame_xpath,
const std::string& javascript,
- Value** result) {
+ Value** result,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "ExecuteJavascript");
dict.SetInteger("windex", browser_index);
@@ -140,7 +146,7 @@ bool SendExecuteJavascriptJSONRequest(
dict.SetString("frame_xpath", frame_xpath);
dict.SetString("javascript", javascript);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
std::string json;
@@ -166,44 +172,48 @@ bool SendExecuteJavascriptJSONRequest(
bool SendGoForwardJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) {
+ int tab_index,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GoForward");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendGoBackJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) {
+ int tab_index,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GoBack");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendReloadJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) {
+ int tab_index,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "Reload");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendCaptureEntirePageJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- const FilePath& path) {
+ const FilePath& path,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "CaptureEntirePage");
dict.SetInteger("windex", browser_index);
@@ -211,20 +221,21 @@ bool SendCaptureEntirePageJSONRequest(
dict.SetString("path", path.value());
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendGetTabURLJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- std::string* url) {
+ std::string* url,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetTabURL");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
return reply_dict.GetString("url", url);
}
@@ -233,13 +244,14 @@ bool SendGetTabTitleJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- std::string* tab_title) {
+ std::string* tab_title,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetTabTitle");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
return reply_dict.GetString("title", tab_title);
}
@@ -247,12 +259,13 @@ bool SendGetTabTitleJSONRequest(
bool SendGetCookiesJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- ListValue** cookies) {
+ ListValue** cookies,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetCookies");
dict.SetString("url", url);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
Value* cookies_unscoped_value;
if (!reply_dict.Remove("cookies", &cookies_unscoped_value))
@@ -274,7 +287,8 @@ bool SendGetCookiesJSONRequestDeprecated(
dict.SetInteger("windex", browser_index);
dict.SetString("url", url);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ std::string error_msg;
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg))
return false;
return reply_dict.GetString("cookies", cookies);
}
@@ -282,13 +296,14 @@ bool SendGetCookiesJSONRequestDeprecated(
bool SendDeleteCookieJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- const std::string& cookie_name) {
+ const std::string& cookie_name,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "DeleteCookie");
dict.SetString("url", url);
dict.SetString("name", cookie_name);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendDeleteCookieJSONRequestDeprecated(
@@ -302,19 +317,21 @@ bool SendDeleteCookieJSONRequestDeprecated(
dict.SetString("url", url);
dict.SetString("name", cookie_name);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ std::string error_msg;
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg);
}
bool SendSetCookieJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- DictionaryValue* cookie_dict) {
+ DictionaryValue* cookie_dict,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "SetCookie");
dict.SetString("url", url);
dict.Set("cookie", cookie_dict->DeepCopy());
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendSetCookieJSONRequestDeprecated(
@@ -328,15 +345,18 @@ bool SendSetCookieJSONRequestDeprecated(
dict.SetString("url", url);
dict.SetString("cookie", cookie);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ std::string error_msg;
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, &error_msg);
}
bool SendGetTabIdsJSONRequest(
- AutomationMessageSender* sender, std::vector<int>* tab_ids) {
+ AutomationMessageSender* sender,
+ std::vector<int>* tab_ids,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetTabIds");
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
ListValue* id_list;
if (!reply_dict.GetList("ids", &id_list)) {
@@ -357,24 +377,30 @@ bool SendGetTabIdsJSONRequest(
}
bool SendIsTabIdValidJSONRequest(
- AutomationMessageSender* sender, int tab_id, bool* is_valid) {
+ AutomationMessageSender* sender,
+ int tab_id,
+ bool* is_valid,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "IsTabIdValid");
dict.SetInteger("id", tab_id);
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
return reply_dict.GetBoolean("is_valid", is_valid);
}
bool SendCloseTabJSONRequest(
- AutomationMessageSender* sender, int browser_index, int tab_index) {
+ AutomationMessageSender* sender,
+ int browser_index,
+ int tab_index,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "CloseTab");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseMoveJSONRequest(
@@ -382,7 +408,8 @@ bool SendMouseMoveJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) {
+ int y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseMove");
dict.SetInteger("windex", browser_index);
@@ -390,7 +417,7 @@ bool SendMouseMoveJSONRequest(
dict.SetInteger("x", x);
dict.SetInteger("y", y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseClickJSONRequest(
@@ -399,8 +426,8 @@ bool SendMouseClickJSONRequest(
int tab_index,
automation::MouseButton button,
int x,
- int y) {
- // TODO get rid of the evil flags.
+ int y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseClick");
dict.SetInteger("windex", browser_index);
@@ -409,7 +436,7 @@ bool SendMouseClickJSONRequest(
dict.SetInteger("x", x);
dict.SetInteger("y", y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseDragJSONRequest(
@@ -419,7 +446,8 @@ bool SendMouseDragJSONRequest(
int start_x,
int start_y,
int end_x,
- int end_y) {
+ int end_y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseDrag");
dict.SetInteger("windex", browser_index);
@@ -429,7 +457,7 @@ bool SendMouseDragJSONRequest(
dict.SetInteger("end_x", end_x);
dict.SetInteger("end_y", end_y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseButtonDownJSONRequest(
@@ -437,7 +465,8 @@ bool SendMouseButtonDownJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) {
+ int y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseButtonDown");
dict.SetInteger("windex", browser_index);
@@ -445,7 +474,7 @@ bool SendMouseButtonDownJSONRequest(
dict.SetInteger("x", x);
dict.SetInteger("y", y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseButtonUpJSONRequest(
@@ -453,7 +482,8 @@ bool SendMouseButtonUpJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) {
+ int y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseButtonUp");
dict.SetInteger("windex", browser_index);
@@ -461,7 +491,7 @@ bool SendMouseButtonUpJSONRequest(
dict.SetInteger("x", x);
dict.SetInteger("y", y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendMouseDoubleClickJSONRequest(
@@ -469,7 +499,8 @@ bool SendMouseDoubleClickJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) {
+ int y,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseDoubleClick");
dict.SetInteger("windex", browser_index);
@@ -477,14 +508,15 @@ bool SendMouseDoubleClickJSONRequest(
dict.SetInteger("x", x);
dict.SetInteger("y", y);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendWebKeyEventJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- const WebKeyEvent& key_event) {
+ const WebKeyEvent& key_event,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "SendWebkitKeyEvent");
dict.SetInteger("windex", browser_index);
@@ -497,7 +529,7 @@ bool SendWebKeyEventJSONRequest(
dict.SetInteger("modifiers", key_event.modifiers);
dict.SetBoolean("isSystemKey", false);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendNativeKeyEventJSONRequest(
@@ -505,7 +537,8 @@ bool SendNativeKeyEventJSONRequest(
int browser_index,
int tab_index,
ui::KeyboardCode key_code,
- int modifiers) {
+ int modifiers,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "SendOSLevelKeyEventToTab");
dict.SetInteger("windex", browser_index);
@@ -513,55 +546,61 @@ bool SendNativeKeyEventJSONRequest(
dict.SetInteger("keyCode", key_code);
dict.SetInteger("modifiers", modifiers);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendGetAppModalDialogMessageJSONRequest(
AutomationMessageSender* sender,
- std::string* message) {
+ std::string* message,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetAppModalDialogMessage");
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
return reply_dict.GetString("message", message);
}
bool SendAcceptOrDismissAppModalDialogJSONRequest(
AutomationMessageSender* sender,
- bool accept) {
+ bool accept,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "AcceptOrDismissAppModalDialog");
dict.SetBoolean("accept", accept);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendAcceptPromptAppModalDialogJSONRequest(
AutomationMessageSender* sender,
- const std::string& prompt_text) {
+ const std::string& prompt_text,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "AcceptOrDismissAppModalDialog");
dict.SetBoolean("accept", true);
dict.SetString("prompt_text", prompt_text);
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendWaitForAllTabsToStopLoadingJSONRequest(
- AutomationMessageSender* sender) {
+ AutomationMessageSender* sender,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WaitForAllTabsToStopLoading");
DictionaryValue reply_dict;
- return SendAutomationJSONRequest(sender, dict, &reply_dict);
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
bool SendGetChromeDriverAutomationVersion(
- AutomationMessageSender* sender, int* version) {
+ AutomationMessageSender* sender,
+ int* version,
+ std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "GetChromeDriverAutomationVersion");
DictionaryValue reply_dict;
- if (!SendAutomationJSONRequest(sender, dict, &reply_dict))
+ if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
return false;
return reply_dict.GetInteger("version", version);
}
diff --git a/chrome/test/automation/automation_json_requests.h b/chrome/test/automation/automation_json_requests.h
index 816445b..afa1937 100644
--- a/chrome/test/automation/automation_json_requests.h
+++ b/chrome/test/automation/automation_json_requests.h
@@ -50,7 +50,8 @@ bool SendGetIndicesFromTabIdJSONRequest(
AutomationMessageSender* sender,
int tab_id,
int* browser_index,
- int* tab_index) WARN_UNUSED_RESULT;
+ int* tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the current browser and tab indices for the given |TabProxy|
// handle. Returns true on success.
@@ -58,7 +59,8 @@ bool SendGetIndicesFromTabHandleJSONRequest(
AutomationMessageSender* sender,
int tab_proxy_handle,
int* browser_index,
- int* tab_index) WARN_UNUSED_RESULT;
+ int* tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to navigate to the given url and wait for the given number of
// navigations to complete. Returns true on success.
@@ -68,7 +70,8 @@ bool SendNavigateToURLJSONRequest(
int tab_index,
const GURL& url,
int navigation_count,
- AutomationMsg_NavigationResponseValues* nav_response) WARN_UNUSED_RESULT;
+ AutomationMsg_NavigationResponseValues* nav_response,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the given javascript to be executed in the frame specified by the
// given xpath. Returns true on success. If true, |result| will be set to the
@@ -79,28 +82,32 @@ bool SendExecuteJavascriptJSONRequest(
int tab_index,
const std::string& frame_xpath,
const std::string& javascript,
- Value** result) WARN_UNUSED_RESULT;
+ Value** result,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the specified tab to go forward. Waits for the load to complete.
// Returns true on success.
bool SendGoForwardJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) WARN_UNUSED_RESULT;
+ int tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the specified tab to go back. Waits for the load to complete.
// Returns true on success.
bool SendGoBackJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) WARN_UNUSED_RESULT;
+ int tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the specified tab to reload. Waits for the load to complete.
// Returns true on success.
bool SendReloadJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) WARN_UNUSED_RESULT;
+ int tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests a snapshot of the entire page to be saved to the given path
// in PNG format.
@@ -109,21 +116,24 @@ bool SendCaptureEntirePageJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- const FilePath& path) WARN_UNUSED_RESULT;
+ const FilePath& path,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the url of the specified tab. Returns true on success.
bool SendGetTabURLJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- std::string* url) WARN_UNUSED_RESULT;
+ std::string* url,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the title of the specified tab. Returns true on success.
bool SendGetTabTitleJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- std::string* tab_title) WARN_UNUSED_RESULT;
+ std::string* tab_title,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests all the cookies for the given URL. On success returns true and
// caller takes ownership of |cookies|, which is a list of all the cookies in
@@ -131,7 +141,8 @@ bool SendGetTabTitleJSONRequest(
bool SendGetCookiesJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- ListValue** cookies) WARN_UNUSED_RESULT;
+ ListValue** cookies,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests all the cookies for the given URL. Returns true on success.
// Use |SendGetCookiesJSONRequest| for chrome versions greater than 11.
@@ -147,7 +158,8 @@ bool SendGetCookiesJSONRequestDeprecated(
bool SendDeleteCookieJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- const std::string& cookie_name) WARN_UNUSED_RESULT;
+ const std::string& cookie_name,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests deletion of the cookie with the given name and URL. Returns true
// on success. Use |SendDeleteCookieJSONRequest| for chrome versions greater
@@ -164,7 +176,8 @@ bool SendDeleteCookieJSONRequestDeprecated(
bool SendSetCookieJSONRequest(
AutomationMessageSender* sender,
const std::string& url,
- DictionaryValue* cookie_dict) WARN_UNUSED_RESULT;
+ DictionaryValue* cookie_dict,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests setting the given cookie for the given URL. Returns true on
// success. Use |SendSetCookieJSONRequest| instead for chrome versions greater
@@ -179,19 +192,22 @@ bool SendSetCookieJSONRequestDeprecated(
// Requests the IDs for all open tabs. Returns true on success.
bool SendGetTabIdsJSONRequest(
AutomationMessageSender* sender,
- std::vector<int>* tab_ids) WARN_UNUSED_RESULT;
+ std::vector<int>* tab_ids,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests whether the given tab ID is valid. Returns true on success.
bool SendIsTabIdValidJSONRequest(
AutomationMessageSender* sender,
int tab_id,
- bool* is_valid) WARN_UNUSED_RESULT;
+ bool* is_valid,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to close the given tab. Returns true on success.
bool SendCloseTabJSONRequest(
AutomationMessageSender* sender,
int browser_index,
- int tab_index) WARN_UNUSED_RESULT;
+ int tab_index,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit event for a mouse move to the given
// coordinate in the specified tab. Returns true on success.
@@ -200,7 +216,8 @@ bool SendMouseMoveJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) WARN_UNUSED_RESULT;
+ int y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit events for a mouse click at the given
// coordinate in the specified tab. Returns true on success.
@@ -210,7 +227,8 @@ bool SendMouseClickJSONRequest(
int tab_index,
automation::MouseButton button,
int x,
- int y) WARN_UNUSED_RESULT;
+ int y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit events for a mouse drag from the start to end
// coordinates given in the specified tab. Returns true on success.
@@ -221,7 +239,8 @@ bool SendMouseDragJSONRequest(
int start_x,
int start_y,
int end_x,
- int end_y) WARN_UNUSED_RESULT;
+ int end_y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit event for a mouse button down at the given
// coordinate in the specified tab. Returns true on success.
@@ -230,7 +249,8 @@ bool SendMouseButtonDownJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) WARN_UNUSED_RESULT;
+ int y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit event for a mouse button up at the given
// coordinate in the specified tab. Returns true on success.
@@ -239,7 +259,8 @@ bool SendMouseButtonUpJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) WARN_UNUSED_RESULT;
+ int y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit event for a mouse double click at the given
// coordinate in the specified tab. Returns true on success.
@@ -248,7 +269,8 @@ bool SendMouseDoubleClickJSONRequest(
int browser_index,
int tab_index,
int x,
- int y) WARN_UNUSED_RESULT;
+ int y,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the WebKit event for the given |WebKeyEvent| in a
// specified tab. Returns true on success.
@@ -256,7 +278,8 @@ bool SendWebKeyEventJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
- const WebKeyEvent& key_event) WARN_UNUSED_RESULT;
+ const WebKeyEvent& key_event,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to send the key event for the given keycode+modifiers to a
// browser window containing the specified tab. Returns true on success.
@@ -265,34 +288,40 @@ bool SendNativeKeyEventJSONRequest(
int browser_index,
int tab_index,
ui::KeyboardCode key_code,
- int modifiers) WARN_UNUSED_RESULT;
+ int modifiers,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to get the active JavaScript modal dialog's message. Returns true
// on success.
bool SendGetAppModalDialogMessageJSONRequest(
AutomationMessageSender* sender,
- std::string* message) WARN_UNUSED_RESULT;
+ std::string* message,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to accept or dismiss the active JavaScript modal dialog.
// Returns true on success.
bool SendAcceptOrDismissAppModalDialogJSONRequest(
AutomationMessageSender* sender,
- bool accept) WARN_UNUSED_RESULT;
+ bool accept,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to accept the active JavaScript modal dialog with the given prompt
// text. Returns true on success.
bool SendAcceptPromptAppModalDialogJSONRequest(
AutomationMessageSender* sender,
- const std::string& prompt_text) WARN_UNUSED_RESULT;
+ const std::string& prompt_text,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests to wait for all tabs to stop loading. Returns true on success.
bool SendWaitForAllTabsToStopLoadingJSONRequest(
- AutomationMessageSender* sender) WARN_UNUSED_RESULT;
+ AutomationMessageSender* sender,
+ std::string* error_msg) WARN_UNUSED_RESULT;
// Requests the version of ChromeDriver automation supported by the automation
// server. Returns true on success.
bool SendGetChromeDriverAutomationVersion(
AutomationMessageSender* sender,
- int* version) WARN_UNUSED_RESULT;
+ int* version,
+ std::string* error_msg) WARN_UNUSED_RESULT;
#endif // CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index ffc6db2..49cd00c 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -739,13 +739,14 @@ bool TabProxy::CaptureEntirePageAsPNG(const FilePath& path) {
return false;
int browser_index, tab_index;
+ std::string error_msg;
if (!SendGetIndicesFromTabHandleJSONRequest(
- sender_, handle_, &browser_index, &tab_index)) {
+ sender_, handle_, &browser_index, &tab_index, &error_msg)) {
return false;
}
return SendCaptureEntirePageJSONRequest(sender_, browser_index,
- tab_index, path);
+ tab_index, path, &error_msg);
}
#if defined(OS_WIN)