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 13 matching lines...) Expand all Loading... | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/v8/V8ErrorHandler.h" | 32 #include "bindings/v8/V8ErrorHandler.h" |
33 | 33 |
34 #include "bindings/v8/DOMWrapperWorld.h" | |
34 #include "bindings/v8/ScriptController.h" | 35 #include "bindings/v8/ScriptController.h" |
35 #include "bindings/v8/V8Binding.h" | 36 #include "bindings/v8/V8Binding.h" |
37 #include "bindings/v8/V8HiddenPropertyName.h" | |
36 #include "bindings/v8/V8ScriptRunner.h" | 38 #include "bindings/v8/V8ScriptRunner.h" |
37 #include "core/dom/ErrorEvent.h" | 39 #include "core/dom/ErrorEvent.h" |
38 #include "core/dom/EventNames.h" | 40 #include "core/dom/EventNames.h" |
39 | 41 |
40 namespace WebCore { | 42 namespace WebCore { |
41 | 43 |
42 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline) | 44 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline) |
43 : V8EventListener(listener, isInline) | 45 : V8EventListener(listener, isInline) |
44 { | 46 { |
45 } | 47 } |
46 | 48 |
47 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptExecutionContext * context, v8::Handle<v8::Value> jsEvent, Event* event) | 49 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptExecutionContext * context, v8::Handle<v8::Value> jsEvent, Event* event) |
48 { | 50 { |
49 if (!event->hasInterface(eventNames().interfaceForErrorEvent)) | 51 if (!event->hasInterface(eventNames().interfaceForErrorEvent)) |
50 return V8EventListener::callListenerFunction(context, jsEvent, event); | 52 return V8EventListener::callListenerFunction(context, jsEvent, event); |
51 | 53 |
52 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); | 54 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); |
53 v8::Local<v8::Object> listener = getListenerObject(context); | 55 v8::Local<v8::Object> listener = getListenerObject(context); |
54 v8::Isolate* isolate = toV8Context(context, world())->GetIsolate(); | 56 v8::Isolate* isolate = toV8Context(context, world())->GetIsolate(); |
55 v8::Local<v8::Value> returnValue; | 57 v8::Local<v8::Value> returnValue; |
56 if (!listener.IsEmpty() && listener->IsFunction()) { | 58 if (!listener.IsEmpty() && listener->IsFunction()) { |
57 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis tener); | 59 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis tener); |
58 v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global(); | 60 v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global(); |
59 v8::Handle<v8::Value> parameters[4] = { v8String(errorEvent->message(), isolate), v8String(errorEvent->filename(), isolate), v8::Integer::New(errorEvent ->lineno(), isolate), v8::Integer::New(errorEvent->colno(), isolate) }; | 61 |
62 v8::Local<v8::Value> error = jsEvent->ToObject()->GetHiddenValue(V8Hidde nPropertyName::error()); | |
63 if (error.IsEmpty()) | |
64 error = v8::Local<v8::Value>(v8::Undefined(isolate)); | |
dcarney
2013/07/30 18:51:58
nit: shouldn't need the extra Local wrapper
Mike West
2013/08/01 07:52:15
Done.
| |
65 | |
66 v8::Handle<v8::Value> parameters[5] = { v8String(errorEvent->message(), isolate), v8String(errorEvent->filename(), isolate), v8::Integer::New(errorEvent ->lineno(), isolate), v8::Integer::New(errorEvent->colno(), isolate), error }; | |
60 v8::TryCatch tryCatch; | 67 v8::TryCatch tryCatch; |
61 tryCatch.SetVerbose(true); | 68 tryCatch.SetVerbose(true); |
62 if (worldType(isolate) == WorkerWorld) | 69 if (worldType(isolate) == WorkerWorld) |
63 returnValue = V8ScriptRunner::callFunction(callFunction, context, th isValue, WTF_ARRAY_LENGTH(parameters), parameters); | 70 returnValue = V8ScriptRunner::callFunction(callFunction, context, th isValue, WTF_ARRAY_LENGTH(parameters), parameters); |
64 else | 71 else |
65 returnValue = ScriptController::callFunctionWithInstrumentation(0, c allFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters); | 72 returnValue = ScriptController::callFunctionWithInstrumentation(0, c allFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters); |
66 } | 73 } |
67 return returnValue; | 74 return returnValue; |
68 } | 75 } |
69 | 76 |
70 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) | 77 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) |
71 { | 78 { |
72 return returnValue->IsBoolean() && returnValue->BooleanValue(); | 79 return returnValue->IsBoolean() && returnValue->BooleanValue(); |
73 } | 80 } |
74 | 81 |
75 } // namespace WebCore | 82 } // namespace WebCore |
OLD | NEW |