OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/renderer/api_binding_test_util.h" | 5 #include "extensions/renderer/api_binding_test_util.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return RunFunction(function, context, context->Global(), argc, argv); | 128 return RunFunction(function, context, context->Global(), argc, argv); |
129 } | 129 } |
130 | 130 |
131 void RunFunctionOnGlobalAndIgnoreResult(v8::Local<v8::Function> function, | 131 void RunFunctionOnGlobalAndIgnoreResult(v8::Local<v8::Function> function, |
132 v8::Local<v8::Context> context, | 132 v8::Local<v8::Context> context, |
133 int argc, | 133 int argc, |
134 v8::Local<v8::Value> argv[]) { | 134 v8::Local<v8::Value> argv[]) { |
135 RunFunction(function, context, context->Global(), argc, argv); | 135 RunFunction(function, context, context->Global(), argc, argv); |
136 } | 136 } |
137 | 137 |
| 138 v8::Global<v8::Value> RunFunctionOnGlobalAndReturnHandle( |
| 139 v8::Local<v8::Function> function, |
| 140 v8::Local<v8::Context> context, |
| 141 int argc, |
| 142 v8::Local<v8::Value> argv[]) { |
| 143 return v8::Global<v8::Value>( |
| 144 context->GetIsolate(), |
| 145 RunFunction(function, context, context->Global(), argc, argv)); |
| 146 } |
| 147 |
138 void RunFunctionAndExpectError(v8::Local<v8::Function> function, | 148 void RunFunctionAndExpectError(v8::Local<v8::Function> function, |
139 v8::Local<v8::Context> context, | 149 v8::Local<v8::Context> context, |
140 v8::Local<v8::Value> receiver, | 150 v8::Local<v8::Value> receiver, |
141 int argc, | 151 int argc, |
142 v8::Local<v8::Value> argv[], | 152 v8::Local<v8::Value> argv[], |
143 const std::string& expected_error) { | 153 const std::string& expected_error) { |
144 std::string error; | 154 std::string error; |
145 v8::Local<v8::Value> result; | 155 v8::Local<v8::Value> result; |
146 EXPECT_FALSE(RunFunctionImpl(function, context, receiver, argc, argv, &result, | 156 EXPECT_FALSE(RunFunctionImpl(function, context, receiver, argc, argv, &result, |
147 &error)); | 157 &error)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (v8_val->IsUndefined()) | 196 if (v8_val->IsUndefined()) |
187 return "undefined"; | 197 return "undefined"; |
188 if (v8_val->IsFunction()) | 198 if (v8_val->IsFunction()) |
189 return "function"; | 199 return "function"; |
190 std::unique_ptr<base::Value> json_prop = V8ToBaseValue(v8_val, context); | 200 std::unique_ptr<base::Value> json_prop = V8ToBaseValue(v8_val, context); |
191 DCHECK(json_prop) << key; | 201 DCHECK(json_prop) << key; |
192 return ValueToString(*json_prop); | 202 return ValueToString(*json_prop); |
193 } | 203 } |
194 | 204 |
195 } // namespace extensions | 205 } // namespace extensions |
OLD | NEW |