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

Unified Diff: chrome/test/webdriver/commands/execute_command.cc

Issue 6544003: The command handler for /session/:sessionId/execute (execute_script) was... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 10 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 | « chrome/test/webdriver/commands/execute_command.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/commands/execute_command.cc
===================================================================
--- chrome/test/webdriver/commands/execute_command.cc (revision 75288)
+++ chrome/test/webdriver/commands/execute_command.cc (working copy)
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/test/webdriver/commands/execute_command.h"
+
#include <string>
-#include "base/json/json_reader.h"
+#include "base/values.h"
kkania 2011/02/17 23:37:47 since you're fixing up headers, how about add one
Jason Leyba 2011/02/18 00:08:00 Done.
-#include "chrome/test/webdriver/commands/execute_command.h"
-
namespace webdriver {
const char kArgs[] = "args";
@@ -19,7 +19,6 @@
ExecuteCommand::~ExecuteCommand() {}
-
bool ExecuteCommand::Init(Response* const response) {
if (!WebDriverCommand::Init(response)) {
SET_WEBDRIVER_ERROR(response, "Failure on Init for execute command",
@@ -33,7 +32,12 @@
return false;
}
- has_args_= GetStringASCIIParameter(kArgs, &args_);
+ if (!GetListParameter(kArgs, &args_)) {
+ SET_WEBDRIVER_ERROR(response, "No script arguments specified",
+ kBadRequest);
+ return false;
+ }
+
return true;
}
@@ -42,46 +46,10 @@
}
void ExecuteCommand::ExecutePost(Response* const response) {
- int error_code = 0;
- std::string error_msg;
- Value* params = NULL;
Value* result = NULL;
-
- if (has_args_) {
- params = base::JSONReader::ReadAndReturnError(args_, true,
- &error_code, &error_msg);
- if (error_code != 0) {
- LOG(INFO) << "Could not parse the JSON arguments passed in "
- << "got error code: " << error_code << ", " << error_msg;
- SET_WEBDRIVER_ERROR(response, "Arguments are not valid json objects",
- kBadRequest);
- return;
- }
- } else {
- LOG(INFO) << "No args for this script";
- // If there are no args required just use an empty list.
- params = new ListValue();
- }
-
- if (params->GetType() != Value::TYPE_LIST) {
- LOG(INFO) << "Data passed in to script must be a json list";
- SET_WEBDRIVER_ERROR(response, "Arguments are not in list format",
- kBadRequest);
- return;
- }
-
- ListValue* script_args = static_cast<ListValue*>(params);
- ErrorCode error = session_->ExecuteScript(script_,
- script_args, &result);
-
- if (error != kSuccess) {
- SET_WEBDRIVER_ERROR(response, "Failed to execute script",
- kInternalServerError);
- return;
- }
-
+ ErrorCode status = session_->ExecuteScript(script_, args_, &result);
+ response->set_status(status);
response->set_value(result);
- response->set_status(kSuccess);
}
bool ExecuteCommand::RequiresValidTab() {
« no previous file with comments | « chrome/test/webdriver/commands/execute_command.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698