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

Side by Side Diff: extensions/renderer/api_binding_test_util.h

Issue 2445223003: [Extensions Bindings] Add more utility functions (Closed)
Patch Set: lazyboy's Created 4 years, 1 month 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
« no previous file with comments | « no previous file | extensions/renderer/api_binding_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Returns a v8::Function parsed from the given |source|. EXPECTs the conversion 45 // Returns a v8::Function parsed from the given |source|. EXPECTs the conversion
46 // to succeed. 46 // to succeed.
47 v8::Local<v8::Function> FunctionFromString(v8::Local<v8::Context> context, 47 v8::Local<v8::Function> FunctionFromString(v8::Local<v8::Context> context,
48 base::StringPiece source); 48 base::StringPiece source);
49 49
50 // Converts the given |value| to a base::Value and returns the result. 50 // Converts the given |value| to a base::Value and returns the result.
51 std::unique_ptr<base::Value> V8ToBaseValue(v8::Local<v8::Value> value, 51 std::unique_ptr<base::Value> V8ToBaseValue(v8::Local<v8::Value> value,
52 v8::Local<v8::Context> context); 52 v8::Local<v8::Context> context);
53 53
54 // Calls the given |function| with the specified |receiver| and arguments, and
55 // returns the result. EXPECTs no errors to be thrown.
56 v8::Local<v8::Value> RunFunction(v8::Local<v8::Function> function,
57 v8::Local<v8::Context> context,
58 v8::Local<v8::Value> receiver,
59 int argc,
60 v8::Local<v8::Value> argv[]);
61
62 // Like RunFunction(), but uses v8::Undefined for the receiver.
63 v8::Local<v8::Value> RunFunction(v8::Local<v8::Function> function,
64 v8::Local<v8::Context> context,
65 int argc,
66 v8::Local<v8::Value> argv[]);
67
68 // Like RunFunction(), but uses the |context|'s Global for the receiver.
69 v8::Local<v8::Value> RunFunctionOnGlobal(v8::Local<v8::Function> function,
70 v8::Local<v8::Context> context,
71 int argc,
72 v8::Local<v8::Value> argv[]);
73
74 // Like RunFunctionOnGlobal(), but doesn't return the result. This is useful
75 // for binding in places a result isn't expected.
76 void RunFunctionOnGlobalAndIgnoreResult(v8::Local<v8::Function> function,
77 v8::Local<v8::Context> context,
78 int argc,
79 v8::Local<v8::Value> argv[]);
80
81 // Calls the given |function| with the specified |receiver| and arguments, but
82 // EXPECTs the function to throw the |expected_error|.
83 void RunFunctionAndExpectError(v8::Local<v8::Function> function,
84 v8::Local<v8::Context> context,
85 v8::Local<v8::Value> receiver,
86 int argc,
87 v8::Local<v8::Value> argv[],
88 const std::string& expected_error);
89
90 // Like RunFunctionAndExpectError(), but uses v8::Undefined for the receiver.
91 void RunFunctionAndExpectError(v8::Local<v8::Function> function,
92 v8::Local<v8::Context> context,
93 int argc,
94 v8::Local<v8::Value> argv[],
95 const std::string& expected_error);
96
97 // Returns the property with the given |key| from the |object|. EXPECTs the
98 // operation not throw an error, but doesn't assume the key is present.
99 v8::Local<v8::Value> GetPropertyFromObject(v8::Local<v8::Object> object,
100 v8::Local<v8::Context> context,
101 base::StringPiece key);
102
103 // As above, but converts the result to a base::Value.
104 std::unique_ptr<base::Value> GetBaseValuePropertyFromObject(
105 v8::Local<v8::Object> object,
106 v8::Local<v8::Context> context,
107 base::StringPiece key);
108
54 } // extensions 109 } // extensions
55 110
56 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_ 111 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/api_binding_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698