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

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
« no previous file with comments | « no previous file | Source/bindings/core/v8/custom/V8JavaScriptCallFrameCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "bindings/core/v8/custom/V8Int8ArrayCustom.h" 51 #include "bindings/core/v8/custom/V8Int8ArrayCustom.h"
52 #include "bindings/core/v8/custom/V8Uint16ArrayCustom.h" 52 #include "bindings/core/v8/custom/V8Uint16ArrayCustom.h"
53 #include "bindings/core/v8/custom/V8Uint32ArrayCustom.h" 53 #include "bindings/core/v8/custom/V8Uint32ArrayCustom.h"
54 #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" 54 #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h"
55 #include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h" 55 #include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h"
56 #include "core/events/EventTarget.h" 56 #include "core/events/EventTarget.h"
57 #include "core/frame/LocalDOMWindow.h" 57 #include "core/frame/LocalDOMWindow.h"
58 #include "core/inspector/InjectedScript.h" 58 #include "core/inspector/InjectedScript.h"
59 #include "core/inspector/InjectedScriptHost.h" 59 #include "core/inspector/InjectedScriptHost.h"
60 #include "core/inspector/InspectorDOMAgent.h" 60 #include "core/inspector/InspectorDOMAgent.h"
61 #include "core/inspector/JavaScriptCallFrame.h"
61 #include "platform/JSONValues.h" 62 #include "platform/JSONValues.h"
62 63
63 namespace WebCore { 64 namespace WebCore {
64 65
65 Node* InjectedScriptHost::scriptValueAsNode(ScriptState* scriptState, ScriptValu e value) 66 Node* InjectedScriptHost::scriptValueAsNode(ScriptState* scriptState, ScriptValu e value)
66 { 67 {
67 ScriptState::Scope scope(scriptState); 68 ScriptState::Scope scope(scriptState);
68 if (!value.isObject() || value.isNull()) 69 if (!value.isObject() || value.isNull())
69 return 0; 70 return 0;
70 return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value())); 71 return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value()));
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (info.Length() < 2) 329 if (info.Length() < 2)
329 return; 330 return;
330 331
331 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); 332 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder());
332 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 333 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
333 ScriptValue object(scriptState, info[0]); 334 ScriptValue object(scriptState, info[0]);
334 ScriptValue hints(scriptState, info[1]); 335 ScriptValue hints(scriptState, info[1]);
335 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS tate)); 336 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS tate));
336 } 337 }
337 338
338 void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v 8::Value>& info) 339 void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::V alue>& info)
339 { 340 {
340 v8::Isolate* isolate = info.GetIsolate(); 341 v8::Isolate* isolate = info.GetIsolate();
341 if (info.Length() < 1) { 342 if (info.Length() < 1) {
342 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected."))); 343 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected.")));
343 return; 344 return;
344 } 345 }
345 346
346 v8::Handle<v8::String> expression = info[0]->ToString(); 347 v8::Handle<v8::String> expression = info[0]->ToString();
347 if (expression.IsEmpty()) { 348 if (expression.IsEmpty()) {
348 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string."))); 349 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string.")));
349 return; 350 return;
350 } 351 }
351 352
352 ASSERT(isolate->InContext()); 353 ASSERT(isolate->InContext());
353 v8::TryCatch tryCatch; 354 v8::TryCatch tryCatch;
354 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e xpression, info.GetIsolate()); 355 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e xpression, info.GetIsolate());
355 if (tryCatch.HasCaught()) { 356 if (tryCatch.HasCaught()) {
356 v8SetReturnValue(info, tryCatch.ReThrow()); 357 v8SetReturnValue(info, tryCatch.ReThrow());
357 return; 358 return;
358 } 359 }
359 v8SetReturnValue(info, result); 360 v8SetReturnValue(info, result);
360 } 361 }
361 362
363 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu nctionCallbackInfo<v8::Value>& info)
364 {
365 v8::Isolate* isolate = info.GetIsolate();
366 if (info.Length() < 1) {
367 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected.")));
368 return;
369 }
370
371 v8::Handle<v8::String> expression = info[0]->ToString();
372 if (expression.IsEmpty()) {
373 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string.")));
374 return;
375 }
376
377 ASSERT(isolate->InContext());
378 v8::TryCatch tryCatch;
379 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e xpression, info.GetIsolate());
380
381 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
382 if (tryCatch.HasCaught()) {
383 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch. Exception());
384 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), JavaScriptCallFrame::createExceptionDetails(tryCatch.Message(), isolate));
385 } else {
386 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result);
387 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8::Undefined(isolate));
388 }
389 v8SetReturnValue(info, wrappedResult);
390 }
391
362 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi onCallbackInfo<v8::Value>& info) 392 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi onCallbackInfo<v8::Value>& info)
363 { 393 {
364 v8::Handle<v8::Value> functionValue = info[0]; 394 v8::Handle<v8::Value> functionValue = info[0];
365 int scopeIndex = info[1]->Int32Value(); 395 int scopeIndex = info[1]->Int32Value();
366 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); 396 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]);
367 v8::Handle<v8::Value> newValue = info[3]; 397 v8::Handle<v8::Value> newValue = info[3];
368 398
369 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); 399 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder());
370 ScriptDebugServer& debugServer = host->scriptDebugServer(); 400 ScriptDebugServer& debugServer = host->scriptDebugServer();
371 v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, s copeIndex, variableName, newValue)); 401 v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, s copeIndex, variableName, newValue));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu e>[argc]); 488 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu e>[argc]);
459 for (size_t i = 0; i < argc; ++i) 489 for (size_t i = 0; i < argc; ++i)
460 argv[i] = info[i + 2]; 490 argv[i] = info[i + 2];
461 491
462 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); 492 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get());
463 debugServer.unmuteWarningsAndDeprecations(); 493 debugServer.unmuteWarningsAndDeprecations();
464 v8SetReturnValue(info, result); 494 v8SetReturnValue(info, result);
465 } 495 }
466 496
467 } // namespace WebCore 497 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/custom/V8JavaScriptCallFrameCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698