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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/custom/V8JavaScriptCallFrameCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
index 5a234e9b988feb8a15b057b6ba4069d0d6363857..1c2fa5cbcdf3bf4c6d85319b965b7e2b2e86b30b 100644
--- a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -58,6 +58,7 @@
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptHost.h"
#include "core/inspector/InspectorDOMAgent.h"
+#include "core/inspector/JavaScriptCallFrame.h"
#include "platform/JSONValues.h"
namespace WebCore {
@@ -335,7 +336,7 @@ void V8InjectedScriptHost::inspectMethodCustom(const v8::FunctionCallbackInfo<v8
host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptState));
}
-void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
if (info.Length() < 1) {
@@ -359,6 +360,35 @@ void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v
v8SetReturnValue(info, result);
}
+void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ v8::Isolate* isolate = info.GetIsolate();
+ if (info.Length() < 1) {
+ isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "One argument expected.")));
+ return;
+ }
+
+ v8::Handle<v8::String> expression = info[0]->ToString();
+ if (expression.IsEmpty()) {
+ isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "The argument must be a string.")));
+ return;
+ }
+
+ ASSERT(isolate->InContext());
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(expression, info.GetIsolate());
+
+ v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
+ if (tryCatch.HasCaught()) {
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.Exception());
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), JavaScriptCallFrame::createExceptionDetails(tryCatch.Message(), isolate));
+ } else {
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result);
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8::Undefined(isolate));
+ }
+ v8SetReturnValue(info, wrappedResult);
+}
+
void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Value> functionValue = info[0];
« 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