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 #ifndef EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 std::unique_ptr<base::ListValue> ListValueFromString(base::StringPiece str); | 30 std::unique_ptr<base::ListValue> ListValueFromString(base::StringPiece str); |
31 | 31 |
32 // As above, but returning a DictionaryValue. | 32 // As above, but returning a DictionaryValue. |
33 std::unique_ptr<base::DictionaryValue> DictionaryValueFromString( | 33 std::unique_ptr<base::DictionaryValue> DictionaryValueFromString( |
34 base::StringPiece str); | 34 base::StringPiece str); |
35 | 35 |
36 // Converts the given |value| to a JSON string. EXPECTs the conversion to | 36 // Converts the given |value| to a JSON string. EXPECTs the conversion to |
37 // succeed. | 37 // succeed. |
38 std::string ValueToString(const base::Value& value); | 38 std::string ValueToString(const base::Value& value); |
39 | 39 |
| 40 // Converts the given |value| to a string. Returns "empty", "undefined", "null", |
| 41 // or "function" for unserializable values. Note this differs from |
| 42 // gin::V8ToString, which only accepts v8::String values. |
| 43 std::string V8ToString(v8::Local<v8::Value> value, |
| 44 v8::Local<v8::Context> context); |
| 45 |
40 // Returns a v8::Value result from compiling and running |source|, or an empty | 46 // Returns a v8::Value result from compiling and running |source|, or an empty |
41 // local on failure. | 47 // local on failure. |
42 v8::Local<v8::Value> V8ValueFromScriptSource(v8::Local<v8::Context> context, | 48 v8::Local<v8::Value> V8ValueFromScriptSource(v8::Local<v8::Context> context, |
43 base::StringPiece source); | 49 base::StringPiece source); |
44 | 50 |
45 // Returns a v8::Function parsed from the given |source|. EXPECTs the conversion | 51 // Returns a v8::Function parsed from the given |source|. EXPECTs the conversion |
46 // to succeed. | 52 // to succeed. |
47 v8::Local<v8::Function> FunctionFromString(v8::Local<v8::Context> context, | 53 v8::Local<v8::Function> FunctionFromString(v8::Local<v8::Context> context, |
48 base::StringPiece source); | 54 base::StringPiece source); |
49 | 55 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 121 |
116 // As above, but returns a JSON-serialized version of the value, or | 122 // As above, but returns a JSON-serialized version of the value, or |
117 // "undefined", "null", "function", or "empty". | 123 // "undefined", "null", "function", or "empty". |
118 std::string GetStringPropertyFromObject(v8::Local<v8::Object> object, | 124 std::string GetStringPropertyFromObject(v8::Local<v8::Object> object, |
119 v8::Local<v8::Context> context, | 125 v8::Local<v8::Context> context, |
120 base::StringPiece key); | 126 base::StringPiece key); |
121 | 127 |
122 } // extensions | 128 } // extensions |
123 | 129 |
124 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ | 130 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ |
OLD | NEW |