OLD | NEW |
1 // Copyright (c) 2011 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/test/automation/javascript_message_utils.h" | 7 #include "chrome/test/automation/javascript_message_utils.h" |
8 #include "content/common/json_value_serializer.h" | 8 #include "content/common/json_value_serializer.h" |
9 | 9 |
10 using javascript_utils::JavaScriptPrintf; | 10 using javascript_utils::JavaScriptPrintf; |
11 | 11 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error; | 82 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error; |
83 } else { | 83 } else { |
84 LOG(ERROR) << "JSON response is empty"; | 84 LOG(ERROR) << "JSON response is empty"; |
85 } | 85 } |
86 return false; | 86 return false; |
87 } | 87 } |
88 | 88 |
89 bool success; | 89 bool success; |
90 std::string evaluation_error; | 90 std::string evaluation_error; |
91 Value* evaluation_result_value; | 91 Value* evaluation_result_value; |
92 ListValue* list = root_value->AsList(); | 92 if (!root_value->IsType(Value::TYPE_LIST)) { |
93 if (!list) { | |
94 LOG(ERROR) << "JSON response was not in correct format"; | 93 LOG(ERROR) << "JSON response was not in correct format"; |
95 return false; | 94 return false; |
96 } | 95 } |
| 96 ListValue* list = static_cast<ListValue*>(root_value.get()); |
97 if (!list->GetBoolean(0, &success) || | 97 if (!list->GetBoolean(0, &success) || |
98 !list->GetString(1, &evaluation_error) || | 98 !list->GetString(1, &evaluation_error) || |
99 !list->Remove(2, &evaluation_result_value)) { | 99 !list->Remove(2, &evaluation_result_value)) { |
100 LOG(ERROR) << "JSON response was not in correct format"; | 100 LOG(ERROR) << "JSON response was not in correct format"; |
101 return false; | 101 return false; |
102 } | 102 } |
103 if (!success) { | 103 if (!success) { |
104 LOG(WARNING) << "JavaScript evaluation did not complete successfully: " | 104 LOG(WARNING) << "JavaScript evaluation did not complete successfully: " |
105 << evaluation_error; | 105 << evaluation_error; |
106 return false; | 106 return false; |
107 } | 107 } |
108 result->reset(evaluation_result_value); | 108 result->reset(evaluation_result_value); |
109 return true; | 109 return true; |
110 } | 110 } |
OLD | NEW |