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

Side by Side Diff: chrome/test/automation/javascript_execution_controller.cc

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 years, 8 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 unified diff | Download patch
OLDNEW
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 "base/json/string_escape.h" 7 #include "base/json/string_escape.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/json_value_serializer.h" 10 #include "chrome/common/json_value_serializer.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 "domAutomation.evaluateJavaScript("; 65 "domAutomation.evaluateJavaScript(";
66 script.append(GetDoubleQuotedJson(UTF8ToUTF16(original_script))); 66 script.append(GetDoubleQuotedJson(UTF8ToUTF16(original_script)));
67 script.append(");"); 67 script.append(");");
68 return ExecuteJavaScriptAndGetJSON(script, json); 68 return ExecuteJavaScriptAndGetJSON(script, json);
69 } 69 }
70 70
71 bool JavaScriptExecutionController::ParseJSON(const std::string& json, 71 bool JavaScriptExecutionController::ParseJSON(const std::string& json,
72 scoped_ptr<Value>* result) { 72 scoped_ptr<Value>* result) {
73 JSONStringValueSerializer parse(json); 73 JSONStringValueSerializer parse(json);
74 std::string parsing_error; 74 std::string parsing_error;
75 scoped_ptr<Value> root_value(parse.Deserialize(&parsing_error)); 75 scoped_ptr<Value> root_value(parse.Deserialize(NULL, &parsing_error));
76 76
77 if (!root_value.get()) { 77 if (!root_value.get()) {
78 if (parsing_error.length()) 78 if (parsing_error.length())
79 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error; 79 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error;
80 else 80 else
81 LOG(ERROR) << "JSON response is empty"; 81 LOG(ERROR) << "JSON response is empty";
82 return false; 82 return false;
83 } 83 }
84 84
85 // The response must be a list of 3 components: 85 // The response must be a list of 3 components:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 bool JavaScriptExecutionController::ConvertResponse(Value* value, 119 bool JavaScriptExecutionController::ConvertResponse(Value* value,
120 int* result) { 120 int* result) {
121 return value->GetAsInteger(result); 121 return value->GetAsInteger(result);
122 } 122 }
123 123
124 bool JavaScriptExecutionController::ConvertResponse(Value* value, 124 bool JavaScriptExecutionController::ConvertResponse(Value* value,
125 std::string* result) { 125 std::string* result) {
126 return value->GetAsString(result); 126 return value->GetAsString(result);
127 } 127 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_api_json_validity_unittest.cc ('k') | chrome/test/automation/tab_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698