OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation/javascript_execution_controller.h" | 5 #include "chrome/test/automation/javascript_execution_controller.h" |
6 | 6 |
7 #include "chrome/common/json_value_serializer.h" | 7 #include "chrome/common/json_value_serializer.h" |
8 #include "chrome/test/automation/javascript_message_utils.h" | 8 #include "chrome/test/automation/javascript_message_utils.h" |
9 | 9 |
10 using javascript_utils::JavaScriptPrintf; | 10 using javascript_utils::JavaScriptPrintf; |
11 | 11 |
12 // Initialize this timeout to an invalid value. Each test framework or test | 12 // Initialize this timeout to an invalid value. Each test framework or test |
13 // must set an appropriate timeout using set_timeout, or the | 13 // must set an appropriate timeout using set_timeout, or the |
14 // JavaScriptExecutionController will complain. | 14 // JavaScriptExecutionController will complain. |
15 int JavaScriptExecutionController::timeout_ms_ = -1; | 15 int JavaScriptExecutionController::timeout_ms_ = -1; |
16 | 16 |
| 17 JavaScriptExecutionController::JavaScriptExecutionController() {} |
| 18 |
| 19 JavaScriptExecutionController::~JavaScriptExecutionController() {} |
| 20 |
17 bool JavaScriptExecutionController::ExecuteJavaScript( | 21 bool JavaScriptExecutionController::ExecuteJavaScript( |
18 const std::string& script) { | 22 const std::string& script) { |
19 scoped_ptr<Value> return_value; | 23 scoped_ptr<Value> return_value; |
20 return ExecuteAndParseHelper(WrapJavaScript(script), &return_value); | 24 return ExecuteAndParseHelper(WrapJavaScript(script), &return_value); |
21 } | 25 } |
22 | 26 |
23 bool JavaScriptExecutionController::ExecuteAsyncJavaScript( | 27 bool JavaScriptExecutionController::ExecuteAsyncJavaScript( |
24 const std::string& script) { | 28 const std::string& script) { |
25 scoped_ptr<Value> return_value; | 29 scoped_ptr<Value> return_value; |
26 return ExecuteAndParseHelper(WrapAsyncJavaScript(script), &return_value); | 30 return ExecuteAndParseHelper(WrapAsyncJavaScript(script), &return_value); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return false; | 101 return false; |
98 } | 102 } |
99 if (!success) { | 103 if (!success) { |
100 LOG(WARNING) << "JavaScript evaluation did not complete successfully: " | 104 LOG(WARNING) << "JavaScript evaluation did not complete successfully: " |
101 << evaluation_error; | 105 << evaluation_error; |
102 return false; | 106 return false; |
103 } | 107 } |
104 result->reset(evaluation_result_value); | 108 result->reset(evaluation_result_value); |
105 return true; | 109 return true; |
106 } | 110 } |
OLD | NEW |