| Index: chrome/renderer/extensions/chrome_v8_context.cc
|
| ===================================================================
|
| --- chrome/renderer/extensions/chrome_v8_context.cc (revision 112544)
|
| +++ chrome/renderer/extensions/chrome_v8_context.cc (working copy)
|
| @@ -44,6 +44,7 @@
|
| v8::Handle<v8::Value>* argv,
|
| v8::Handle<v8::Value>* result) const {
|
| v8::Context::Scope context_scope(v8_context_);
|
| + v8::TryCatch try_catch;
|
|
|
| // Look up the function name, which may be a sub-property like
|
| // "Port.dispatchOnMessage" in the hidden global variable.
|
| @@ -52,15 +53,16 @@
|
| std::vector<std::string> components;
|
| base::SplitStringDontTrim(function_name, '.', &components);
|
| for (size_t i = 0; i < components.size(); ++i) {
|
| - if (!value.IsEmpty()) {
|
| + if (!value.IsEmpty() && value->IsObject()) {
|
| value = v8::Local<v8::Object>::Cast(value)->Get(
|
| v8::String::New(components[i].c_str()));
|
| + if (try_catch.HasCaught()) {
|
| + NOTREACHED() << *v8::String::AsciiValue(try_catch.Exception());
|
| + return false;
|
| + }
|
| }
|
| }
|
|
|
| - // TODO(aa): CHECK that this succeeds. Can't do this now because not all
|
| - // callers know if the method they are calling exists. Should be able to fix
|
| - // this when all the bindings are converted to the new framework.
|
| if (value.IsEmpty() || !value->IsFunction()) {
|
| VLOG(1) << "Could not execute chrome hidden method: " << function_name;
|
| return false;
|
| @@ -68,6 +70,10 @@
|
|
|
| v8::Handle<v8::Value> result_temp =
|
| v8::Local<v8::Function>::Cast(value)->Call(v8::Object::New(), argc, argv);
|
| + if (try_catch.HasCaught()) {
|
| + NOTREACHED() << *v8::String::AsciiValue(try_catch.Exception());
|
| + return false;
|
| + }
|
| if (result)
|
| *result = result_temp;
|
| return true;
|
|
|