Chromium Code Reviews| Index: chrome/renderer/extensions/chrome_v8_context.cc |
| diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc |
| index 322cd98516fe6ef79a99cf8424b064e4f196edc1..d5cbe7d7364da491004180cc933a804ec5c464fb 100644 |
| --- a/chrome/renderer/extensions/chrome_v8_context.cc |
| +++ b/chrome/renderer/extensions/chrome_v8_context.cc |
| @@ -44,6 +44,7 @@ bool ChromeV8Context::CallChromeHiddenMethod( |
| v8::Handle<v8::Value>* argv, |
| v8::Handle<v8::Value>* result) const { |
| v8::Context::Scope context_scope(v8_context_); |
| + v8::TryCatch try_catch; |
|
Matt Perry
2011/12/01 18:57:29
Meh, this seems like overkill given that:
- we now
|
| // Look up the function name, which may be a sub-property like |
| // "Port.dispatchOnMessage" in the hidden global variable. |
| @@ -52,15 +53,16 @@ bool ChromeV8Context::CallChromeHiddenMethod( |
| 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()) { |
|
Aaron Boodman
2011/12/01 05:58:32
FYI: This is the part that actually fixes the bug,
|
| 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 @@ bool ChromeV8Context::CallChromeHiddenMethod( |
| 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; |