| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta
te, v8::Local<v8::Value> jsEvent, Event* event) | 50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta
te, v8::Local<v8::Value> jsEvent, Event* event) |
| 51 { | 51 { |
| 52 if (!event->hasInterface(EventNames::ErrorEvent)) | 52 if (!event->hasInterface(EventNames::ErrorEvent)) |
| 53 return V8EventListener::callListenerFunction(scriptState, jsEvent, event
); | 53 return V8EventListener::callListenerFunction(scriptState, jsEvent, event
); |
| 54 | 54 |
| 55 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); | 55 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); |
| 56 if (errorEvent->world() && errorEvent->world() != &world()) | 56 if (errorEvent->world() && errorEvent->world() != &world()) |
| 57 return v8::Null(isolate()); | 57 return v8::Null(isolate()); |
| 58 | 58 |
| 59 v8::Local<v8::Object> listener = getListenerObject(scriptState->executionCon
text()); | 59 v8::Local<v8::Object> listener = getListenerObject(scriptState->executionCon
text()); |
| 60 if (listener.IsEmpty() || !listener->IsFunction()) |
| 61 return v8::Null(isolate()); |
| 62 |
| 63 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listene
r); |
| 64 v8::Local<v8::Object> thisValue = scriptState->context()->Global(); |
| 65 |
| 66 v8::Local<v8::Object> eventObject; |
| 67 if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) |
| 68 return v8::Null(isolate()); |
| 69 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventO
bject, V8HiddenValue::error(isolate())); |
| 70 if (error.IsEmpty()) |
| 71 error = v8::Null(isolate()); |
| 72 |
| 73 v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->messa
ge()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(),
errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error }
; |
| 74 v8::TryCatch tryCatch; |
| 75 tryCatch.SetVerbose(true); |
| 76 v8::MaybeLocal<v8::Value> result; |
| 77 if (scriptState->executionContext()->isWorkerGlobalScope()) { |
| 78 result = V8ScriptRunner::callFunction(callFunction, scriptState->executi
onContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| 79 } else { |
| 80 result = ScriptController::callFunction(scriptState->executionContext(),
callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); |
| 81 } |
| 60 v8::Local<v8::Value> returnValue; | 82 v8::Local<v8::Value> returnValue; |
| 61 if (!listener.IsEmpty() && listener->IsFunction()) { | 83 if (!result.ToLocal(&returnValue)) |
| 62 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis
tener); | 84 return v8::Null(isolate()); |
| 63 v8::Local<v8::Object> thisValue = scriptState->context()->Global(); | |
| 64 | 85 |
| 65 v8::Local<v8::Object> eventObject; | |
| 66 if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) | |
| 67 return v8::Null(isolate()); | |
| 68 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), ev
entObject, V8HiddenValue::error(isolate())); | |
| 69 if (error.IsEmpty()) | |
| 70 error = v8::Null(isolate()); | |
| 71 | |
| 72 v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->m
essage()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate
(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), err
or }; | |
| 73 v8::TryCatch tryCatch; | |
| 74 tryCatch.SetVerbose(true); | |
| 75 if (scriptState->executionContext()->isWorkerGlobalScope()) | |
| 76 returnValue = V8ScriptRunner::callFunction(callFunction, scriptState
->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isola
te()); | |
| 77 else | |
| 78 returnValue = ScriptController::callFunction(scriptState->executionC
ontext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, iso
late()); | |
| 79 } | |
| 80 return returnValue; | 86 return returnValue; |
| 81 } | 87 } |
| 82 | 88 |
| 83 // static | 89 // static |
| 84 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err
orEvent* event, v8::Local<v8::Value> data, v8::Local<v8::Object> creationContext
) | 90 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err
orEvent* event, v8::Local<v8::Value> data, v8::Local<v8::Object> creationContext
) |
| 85 { | 91 { |
| 86 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); | 92 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); |
| 87 if (!wrappedEvent.IsEmpty()) { | 93 if (!wrappedEvent.IsEmpty()) { |
| 88 ASSERT(wrappedEvent->IsObject()); | 94 ASSERT(wrappedEvent->IsObject()); |
| 89 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp
edEvent), V8HiddenValue::error(isolate), data); | 95 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp
edEvent), V8HiddenValue::error(isolate), data); |
| 90 } | 96 } |
| 91 } | 97 } |
| 92 | 98 |
| 93 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) | 99 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) |
| 94 { | 100 { |
| 95 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); | 101 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); |
| 96 } | 102 } |
| 97 | 103 |
| 98 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |