OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2011 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 14 matching lines...) Expand all Loading... |
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/core/v8/V8InjectedScriptHost.h" | 32 #include "bindings/core/v8/V8InjectedScriptHost.h" |
33 | 33 |
34 #include "bindings/core/v8/BindingSecurity.h" | 34 #include "bindings/core/v8/BindingSecurity.h" |
| 35 #include "bindings/core/v8/EvaluateExceptionDetailsFactory.h" |
35 #include "bindings/core/v8/ExceptionState.h" | 36 #include "bindings/core/v8/ExceptionState.h" |
36 #include "bindings/core/v8/ScriptDebugServer.h" | 37 #include "bindings/core/v8/ScriptDebugServer.h" |
37 #include "bindings/core/v8/ScriptValue.h" | 38 #include "bindings/core/v8/ScriptValue.h" |
38 #include "bindings/core/v8/V8AbstractEventListener.h" | 39 #include "bindings/core/v8/V8AbstractEventListener.h" |
39 #include "bindings/core/v8/V8Binding.h" | 40 #include "bindings/core/v8/V8Binding.h" |
40 #include "bindings/core/v8/V8EventTarget.h" | 41 #include "bindings/core/v8/V8EventTarget.h" |
41 #include "bindings/core/v8/V8HTMLAllCollection.h" | 42 #include "bindings/core/v8/V8HTMLAllCollection.h" |
42 #include "bindings/core/v8/V8HTMLCollection.h" | 43 #include "bindings/core/v8/V8HTMLCollection.h" |
43 #include "bindings/core/v8/V8Node.h" | 44 #include "bindings/core/v8/V8Node.h" |
44 #include "bindings/core/v8/V8NodeList.h" | 45 #include "bindings/core/v8/V8NodeList.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 324 |
324 v8::Handle<v8::String> expression = info[0]->ToString(); | 325 v8::Handle<v8::String> expression = info[0]->ToString(); |
325 if (expression.IsEmpty()) { | 326 if (expression.IsEmpty()) { |
326 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | 327 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); |
327 return; | 328 return; |
328 } | 329 } |
329 | 330 |
330 ASSERT(isolate->InContext()); | 331 ASSERT(isolate->InContext()); |
331 v8::TryCatch tryCatch; | 332 v8::TryCatch tryCatch; |
332 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); | 333 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); |
| 334 |
| 335 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate); |
333 if (tryCatch.HasCaught()) { | 336 if (tryCatch.HasCaught()) { |
334 v8SetReturnValue(info, tryCatch.ReThrow()); | 337 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.
Exception()); |
335 return; | 338 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
createEvaluateExceptionDetails(tryCatch.Message(), isolate)); |
| 339 } else { |
| 340 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result); |
| 341 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
v8::Undefined(isolate)); |
336 } | 342 } |
337 v8SetReturnValue(info, result); | 343 v8SetReturnValue(info, wrappedResult); |
338 } | 344 } |
339 | 345 |
340 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) | 346 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) |
341 { | 347 { |
342 v8::Handle<v8::Value> functionValue = info[0]; | 348 v8::Handle<v8::Value> functionValue = info[0]; |
343 int scopeIndex = info[1]->Int32Value(); | 349 int scopeIndex = info[1]->Int32Value(); |
344 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); | 350 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); |
345 v8::Handle<v8::Value> newValue = info[3]; | 351 v8::Handle<v8::Value> newValue = info[3]; |
346 | 352 |
347 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); | 353 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argc]); | 442 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argc]); |
437 for (size_t i = 0; i < argc; ++i) | 443 for (size_t i = 0; i < argc; ++i) |
438 argv[i] = info[i + 2]; | 444 argv[i] = info[i + 2]; |
439 | 445 |
440 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); | 446 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); |
441 debugServer.unmuteWarningsAndDeprecations(); | 447 debugServer.unmuteWarningsAndDeprecations(); |
442 v8SetReturnValue(info, result); | 448 v8SetReturnValue(info, result); |
443 } | 449 } |
444 | 450 |
445 } // namespace WebCore | 451 } // namespace WebCore |
OLD | NEW |