| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 371 } |
| 372 | 372 |
| 373 v8::Handle<v8::String> expression = info[0]->ToString(isolate); | 373 v8::Handle<v8::String> expression = info[0]->ToString(isolate); |
| 374 if (expression.IsEmpty()) { | 374 if (expression.IsEmpty()) { |
| 375 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | 375 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 | 378 |
| 379 ASSERT(isolate->InContext()); | 379 ASSERT(isolate->InContext()); |
| 380 v8::TryCatch tryCatch; | 380 v8::TryCatch tryCatch; |
| 381 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); | 381 v8::Local<v8::Value> result; |
| 382 if (tryCatch.HasCaught()) { | 382 if (!V8ScriptRunner::compileAndRunInternalScript(expression, info.GetIsolate
()).ToLocal(&result)) { |
| 383 v8SetReturnValue(info, tryCatch.ReThrow()); | 383 if (tryCatch.HasCaught()) |
| 384 v8SetReturnValue(info, tryCatch.ReThrow()); |
| 384 return; | 385 return; |
| 385 } | 386 } |
| 386 v8SetReturnValue(info, result); | 387 v8SetReturnValue(info, result); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu
nctionCallbackInfo<v8::Value>& info) | 390 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu
nctionCallbackInfo<v8::Value>& info) |
| 390 { | 391 { |
| 391 v8::Isolate* isolate = info.GetIsolate(); | 392 v8::Isolate* isolate = info.GetIsolate(); |
| 392 if (info.Length() < 1) { | 393 if (info.Length() < 1) { |
| 393 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "One argument expected."))); | 394 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "One argument expected."))); |
| 394 return; | 395 return; |
| 395 } | 396 } |
| 396 | 397 |
| 397 v8::Handle<v8::String> expression = info[0]->ToString(isolate); | 398 v8::Handle<v8::String> expression = info[0]->ToString(isolate); |
| 398 if (expression.IsEmpty()) { | 399 if (expression.IsEmpty()) { |
| 399 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | 400 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); |
| 400 return; | 401 return; |
| 401 } | 402 } |
| 402 | 403 |
| 403 ASSERT(isolate->InContext()); | 404 ASSERT(isolate->InContext()); |
| 404 v8::TryCatch tryCatch; | 405 v8::TryCatch tryCatch; |
| 405 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(expression, St
ring(), String(), TextPosition(), isolate); | 406 v8::Local<v8::Script> script; |
| 406 v8::Handle<v8::Value> result = V8ScriptRunner::runCompiledScript(isolate, sc
ript, currentExecutionContext(isolate)); | 407 v8::MaybeLocal<v8::Value> result; |
| 408 if (v8Call(V8ScriptRunner::compileScript(expression, String(), String(), Tex
tPosition(), isolate), script, tryCatch)) |
| 409 result = V8ScriptRunner::runCompiledScript(isolate, script, currentExecu
tionContext(isolate)); |
| 407 | 410 |
| 411 if (!tryCatch.CanContinue()) |
| 412 return; |
| 408 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate); | 413 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate); |
| 409 if (tryCatch.HasCaught()) { | 414 if (tryCatch.HasCaught()) { |
| 410 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.
Exception()); | 415 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.
Exception()); |
| 411 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
JavaScriptCallFrame::createExceptionDetails(isolate, tryCatch.Message())); | 416 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
JavaScriptCallFrame::createExceptionDetails(isolate, tryCatch.Message())); |
| 412 } else { | 417 } else { |
| 413 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result); | 418 ASSERT(!result.IsEmpty()); |
| 419 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result.To
LocalChecked()); |
| 414 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
v8::Undefined(isolate)); | 420 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
v8::Undefined(isolate)); |
| 415 } | 421 } |
| 416 v8SetReturnValue(info, wrappedResult); | 422 v8SetReturnValue(info, wrappedResult); |
| 417 } | 423 } |
| 418 | 424 |
| 419 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) | 425 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) |
| 420 { | 426 { |
| 421 if (info.Length() < 4 || !info[0]->IsFunction() || !info[1]->IsInt32() || !i
nfo[2]->IsString()) | 427 if (info.Length() < 4 || !info[0]->IsFunction() || !info[1]->IsInt32() || !i
nfo[2]->IsString()) |
| 422 return; | 428 return; |
| 423 | 429 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); | 591 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); |
| 586 if (!injectedScriptNative) | 592 if (!injectedScriptNative) |
| 587 return; | 593 return; |
| 588 int id = info[0]->ToInt32(info.GetIsolate())->Value(); | 594 int id = info[0]->ToInt32(info.GetIsolate())->Value(); |
| 589 String groupName = injectedScriptNative->groupName(id); | 595 String groupName = injectedScriptNative->groupName(id); |
| 590 if (!groupName.isEmpty()) | 596 if (!groupName.isEmpty()) |
| 591 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); | 597 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); |
| 592 } | 598 } |
| 593 | 599 |
| 594 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |