Chromium Code Reviews| Index: Source/bindings/core/v8/V8ErrorHandler.cpp |
| diff --git a/Source/bindings/core/v8/V8ErrorHandler.cpp b/Source/bindings/core/v8/V8ErrorHandler.cpp |
| index a1239c174752f8a8ba484563a0310db1e7fcd324..56fa8e2bc5e61610435e756f0a2246d4c80b58c9 100644 |
| --- a/Source/bindings/core/v8/V8ErrorHandler.cpp |
| +++ b/Source/bindings/core/v8/V8ErrorHandler.cpp |
| @@ -58,25 +58,30 @@ v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta |
| v8::Local<v8::Object> listener = getListenerObject(scriptState->executionContext()); |
| v8::Local<v8::Value> returnValue; |
|
Yuki
2015/04/17 09:59:23
Move this line just before you really need returnV
bashi
2015/04/21 00:15:40
Done.
|
| - if (!listener.IsEmpty() && listener->IsFunction()) { |
| - v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener); |
| - v8::Local<v8::Object> thisValue = scriptState->context()->Global(); |
| + if (listener.IsEmpty() || !listener->IsFunction()) |
| + return v8::Null(isolate()); |
| - v8::Local<v8::Object> eventObject; |
| - if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) |
| - return v8::Null(isolate()); |
| - v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventObject, V8HiddenValue::error(isolate())); |
| - if (error.IsEmpty()) |
| - error = v8::Null(isolate()); |
| + v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener); |
| + v8::Local<v8::Object> thisValue = scriptState->context()->Global(); |
| + |
| + v8::Local<v8::Object> eventObject; |
| + if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) |
| + return v8::Null(isolate()); |
| + v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventObject, V8HiddenValue::error(isolate())); |
| + if (error.IsEmpty()) |
| + error = v8::Null(isolate()); |
| + |
| + v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error }; |
| + v8::TryCatch tryCatch; |
| + tryCatch.SetVerbose(true); |
| + v8::MaybeLocal<v8::Value> result; |
| + if (scriptState->executionContext()->isWorkerGlobalScope()) |
|
haraken
2015/04/18 23:10:47
Nit: I'd add { } since the clause is long.
bashi
2015/04/21 00:15:40
Done.
|
| + result = V8ScriptRunner::callFunction(callFunction, scriptState->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| + else |
| + result = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| + if (!result.ToLocal(&returnValue)) |
| + return v8::Null(isolate()); |
| - v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error }; |
| - v8::TryCatch tryCatch; |
| - tryCatch.SetVerbose(true); |
| - if (scriptState->executionContext()->isWorkerGlobalScope()) |
| - returnValue = V8ScriptRunner::callFunction(callFunction, scriptState->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| - else |
| - returnValue = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| - } |
| return returnValue; |
| } |