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

Unified Diff: extensions/renderer/api_binding_test_util.cc

Issue 2657613005: [Extensions Bindings] Add chrome.runtime.lastError support (Closed)
Patch Set: . Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/api_binding_test_util.h ('k') | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding_test_util.cc
diff --git a/extensions/renderer/api_binding_test_util.cc b/extensions/renderer/api_binding_test_util.cc
index 66cd2c358714f60bbb5cc3220733cae96384debc..262ae6a7cd28a58eb0e7cfebf92689dcbb72266b 100644
--- a/extensions/renderer/api_binding_test_util.cc
+++ b/extensions/renderer/api_binding_test_util.cc
@@ -74,6 +74,22 @@ std::string ValueToString(const base::Value& value) {
return json;
}
+std::string V8ToString(v8::Local<v8::Value> value,
+ v8::Local<v8::Context> context) {
+ if (value.IsEmpty())
+ return "empty";
+ if (value->IsNull())
+ return "null";
+ if (value->IsUndefined())
+ return "undefined";
+ if (value->IsFunction())
+ return "function";
+ std::unique_ptr<base::Value> json = V8ToBaseValue(value, context);
+ if (!json)
+ return "unserializable";
+ return ValueToString(*json);
+}
+
v8::Local<v8::Value> V8ValueFromScriptSource(v8::Local<v8::Context> context,
base::StringPiece source) {
v8::MaybeLocal<v8::Script> maybe_script = v8::Script::Compile(
@@ -188,18 +204,7 @@ std::unique_ptr<base::Value> GetBaseValuePropertyFromObject(
std::string GetStringPropertyFromObject(v8::Local<v8::Object> object,
v8::Local<v8::Context> context,
base::StringPiece key) {
- v8::Local<v8::Value> v8_val = GetPropertyFromObject(object, context, key);
- if (v8_val.IsEmpty())
- return "empty";
- if (v8_val->IsNull())
- return "null";
- if (v8_val->IsUndefined())
- return "undefined";
- if (v8_val->IsFunction())
- return "function";
- std::unique_ptr<base::Value> json_prop = V8ToBaseValue(v8_val, context);
- DCHECK(json_prop) << key;
- return ValueToString(*json_prop);
+ return V8ToString(GetPropertyFromObject(object, context, key), context);
}
} // namespace extensions
« no previous file with comments | « extensions/renderer/api_binding_test_util.h ('k') | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698