OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/webdriver/commands/execute_command.h" | 5 #include "chrome/test/webdriver/commands/execute_command.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/test/webdriver/commands/response.h" | 10 #include "chrome/test/webdriver/commands/response.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 return true; | 23 return true; |
24 } | 24 } |
25 | 25 |
26 void ExecuteCommand::ExecutePost(Response* const response) { | 26 void ExecuteCommand::ExecutePost(Response* const response) { |
27 std::string script; | 27 std::string script; |
28 if (!GetStringParameter("script", &script)) { | 28 if (!GetStringParameter("script", &script)) { |
29 response->SetError(new Error(kBadRequest, "No script specified")); | 29 response->SetError(new Error(kBadRequest, "No script specified")); |
30 return; | 30 return; |
31 } | 31 } |
32 | 32 |
33 ListValue* args; | 33 const ListValue* args; |
34 if (!GetListParameter("args", &args)) { | 34 if (!GetListParameter("args", &args)) { |
35 response->SetError(new Error( | 35 response->SetError(new Error( |
36 kBadRequest, "No script arguments specified")); | 36 kBadRequest, "No script arguments specified")); |
37 return; | 37 return; |
38 } | 38 } |
39 | 39 |
40 Value* result = NULL; | 40 Value* result = NULL; |
41 Error* error = session_->ExecuteScript(script, args, &result); | 41 Error* error = session_->ExecuteScript(script, args, &result); |
42 if (error) { | 42 if (error) { |
43 error->AddDetails("Script execution failed. Script: " + script); | 43 error->AddDetails("Script execution failed. Script: " + script); |
44 response->SetError(error); | 44 response->SetError(error); |
45 return; | 45 return; |
46 } | 46 } |
47 response->SetValue(result); | 47 response->SetValue(result); |
48 } | 48 } |
49 | 49 |
50 } // namspace webdriver | 50 } // namspace webdriver |
OLD | NEW |