| Index: net/proxy/proxy_resolver_v8.cc
|
| diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
|
| index 2bb858c46ead631ed73d9cdedd77756b9501f0f5..57d68b5d8f9af105ff66644307665e74b9dffe31 100644
|
| --- a/net/proxy/proxy_resolver_v8.cc
|
| +++ b/net/proxy/proxy_resolver_v8.cc
|
| @@ -431,11 +431,9 @@ class ProxyResolverV8::Context {
|
| v8::Context::Scope function_scope(context);
|
|
|
| v8::Local<v8::Value> function;
|
| - if (!GetFindProxyForURL(&function)) {
|
| - js_bindings()->OnError(
|
| - -1, base::ASCIIToUTF16("FindProxyForURL() is undefined."));
|
| - return ERR_PAC_SCRIPT_FAILED;
|
| - }
|
| + int rv = GetFindProxyForURL(&function);
|
| + if (rv != OK)
|
| + return rv;
|
|
|
| v8::Local<v8::Value> argv[] = {
|
| ASCIIStringToV8String(isolate_, query_url.spec()),
|
| @@ -561,23 +559,41 @@ class ProxyResolverV8::Context {
|
| // At a minimum, the FindProxyForURL() function must be defined for this
|
| // to be a legitimiate PAC script.
|
| v8::Local<v8::Value> function;
|
| - if (!GetFindProxyForURL(&function)) {
|
| - js_bindings()->OnError(
|
| - -1, base::ASCIIToUTF16("FindProxyForURL() is undefined."));
|
| - return ERR_PAC_SCRIPT_FAILED;
|
| - }
|
| -
|
| - return OK;
|
| + return GetFindProxyForURL(&function);
|
| }
|
|
|
| private:
|
| - bool GetFindProxyForURL(v8::Local<v8::Value>* function) {
|
| + int GetFindProxyForURL(v8::Local<v8::Value>* function) {
|
| v8::Local<v8::Context> context =
|
| v8::Local<v8::Context>::New(isolate_, v8_context_);
|
| +
|
| + v8::TryCatch try_catch;
|
| +
|
| *function =
|
| context->Global()->Get(
|
| ASCIILiteralToV8String(isolate_, "FindProxyForURL"));
|
| - return (*function)->IsFunction();
|
| +
|
| + if (try_catch.HasCaught())
|
| + HandleError(try_catch.Message());
|
| +
|
| + // The value should only be empty if an exception was thrown. Code
|
| + // defensively just in case.
|
| + DCHECK_EQ(function->IsEmpty(), try_catch.HasCaught());
|
| + if (function->IsEmpty() || try_catch.HasCaught()) {
|
| + js_bindings()->OnError(
|
| + -1,
|
| + base::ASCIIToUTF16("Accessing FindProxyForURL threw an exception."));
|
| + return ERR_PAC_SCRIPT_FAILED;
|
| + }
|
| +
|
| + if (!(*function)->IsFunction()) {
|
| + js_bindings()->OnError(
|
| + -1, base::ASCIIToUTF16(
|
| + "FindProxyForURL is undefined or not a function."));
|
| + return ERR_PAC_SCRIPT_FAILED;
|
| + }
|
| +
|
| + return OK;
|
| }
|
|
|
| // Handle an exception thrown by V8.
|
|
|