Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp

Issue 289423002: DevTools: added injectedScript.evaluateWithDetails, that return exception details if it occured (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 v8::Handle<v8::String> expression = info[0]->ToString(); 324 v8::Handle<v8::String> expression = info[0]->ToString();
325 if (expression.IsEmpty()) { 325 if (expression.IsEmpty()) {
326 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string."))); 326 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string.")));
327 return; 327 return;
328 } 328 }
329 329
330 ASSERT(isolate->InContext()); 330 ASSERT(isolate->InContext());
331 v8::TryCatch tryCatch; 331 v8::TryCatch tryCatch;
332 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e xpression, info.GetIsolate()); 332 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e xpression, info.GetIsolate());
333
334 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
333 if (tryCatch.HasCaught()) { 335 if (tryCatch.HasCaught()) {
334 v8SetReturnValue(info, tryCatch.ReThrow()); 336 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch. Exception());
335 return; 337
338 v8::Local<v8::Object> exceptionDetails = v8::Object::New(isolate);
339 v8::Local<v8::Message> message = tryCatch.Message();
340 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "text"), message- >Get());
341 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "url"), message-> GetScriptOrigin().ResourceName());
342 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Inte ger::New(isolate, message->GetLineNumber()));
343 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::In teger::New(isolate, message->GetStartColumn()));
344 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me ssage->GetStackTrace()->AsArray());
345 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), exceptionDetails);
346 } else {
347 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result);
348 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8::Undefined(isolate));
336 } 349 }
337 v8SetReturnValue(info, result); 350 v8SetReturnValue(info, wrappedResult);
338 } 351 }
339 352
340 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi onCallbackInfo<v8::Value>& info) 353 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi onCallbackInfo<v8::Value>& info)
341 { 354 {
342 v8::Handle<v8::Value> functionValue = info[0]; 355 v8::Handle<v8::Value> functionValue = info[0];
343 int scopeIndex = info[1]->Int32Value(); 356 int scopeIndex = info[1]->Int32Value();
344 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); 357 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]);
345 v8::Handle<v8::Value> newValue = info[3]; 358 v8::Handle<v8::Value> newValue = info[3];
346 359
347 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); 360 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu e>[argc]); 449 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu e>[argc]);
437 for (size_t i = 0; i < argc; ++i) 450 for (size_t i = 0; i < argc; ++i)
438 argv[i] = info[i + 2]; 451 argv[i] = info[i + 2];
439 452
440 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); 453 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get());
441 debugServer.unmuteWarningsAndDeprecations(); 454 debugServer.unmuteWarningsAndDeprecations();
442 v8SetReturnValue(info, result); 455 v8SetReturnValue(info, result);
443 } 456 }
444 457
445 } // namespace WebCore 458 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/InjectedScriptSource.js » ('j') | Source/core/inspector/InjectedScriptSource.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698