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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/JavaScriptCallFrame.cpp

Issue 1811853002: [DevTools] Move evaluateOnCallFrame to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (result.IsEmpty() || !result->IsBoolean()) 184 if (result.IsEmpty() || !result->IsBoolean())
185 return false; 185 return false;
186 return result->BooleanValue(); 186 return result->BooleanValue();
187 } 187 }
188 188
189 v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const 189 v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const
190 { 190 {
191 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt ernalized(m_isolate, "returnValue")); 191 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt ernalized(m_isolate, "returnValue"));
192 } 192 }
193 193
194 v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local <v8::Value> expression, v8::Local<v8::Value> scopeExtension) 194 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(v8::Local<v8::Value> exp ression)
195 { 195 {
196 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask s); 196 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask s);
197 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); 197 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame);
198 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(toV8StringInternalized(m_isolate, "evaluate"))); 198 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(toV8StringInternalized(m_isolate, "evaluate")));
199 v8::Local<v8::Value> argv[] = { 199 return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, 1, &exp ression);
200 expression,
201 scopeExtension
202 };
203 v8::TryCatch tryCatch(m_isolate);
204 v8::Local<v8::Object> wrappedResult = v8::Object::New(m_isolate);
205 v8::Local<v8::Value> result;
206 if (evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, WTF_ARRAY_ LENGTH(argv), argv).ToLocal(&result)) {
207 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result) ;
208 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), v8::Undefined(m_isolate));
209 } else {
210 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc h.Exception());
211 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), createExceptionDetails(m_isolate, tryCatch.Message()));
212 }
213 return wrappedResult;
214 } 200 }
215 201
216 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() 202 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart()
217 { 203 {
218 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); 204 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks);
219 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); 205 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame);
220 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(toV8StringInternalized(m_isolate, "restart"))); 206 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(toV8StringInternalized(m_isolate, "restart")));
221 v8::Debug::SetLiveEditEnabled(m_isolate, true); 207 v8::Debug::SetLiveEditEnabled(m_isolate, true);
222 v8::MaybeLocal<v8::Value> result = restartFunction->Call(m_isolate->GetCurre ntContext(), callFrame, 0, nullptr); 208 v8::MaybeLocal<v8::Value> result = restartFunction->Call(m_isolate->GetCurre ntContext(), callFrame, 0, nullptr);
223 v8::Debug::SetLiveEditEnabled(m_isolate, false); 209 v8::Debug::SetLiveEditEnabled(m_isolate, false);
(...skipping 22 matching lines...) Expand all
246 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer: :New(isolate, message->GetLineNumber())); 232 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer: :New(isolate, message->GetLineNumber()));
247 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Intege r::New(isolate, message->GetStartColumn())); 233 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Intege r::New(isolate, message->GetStartColumn()));
248 if (!message->GetStackTrace().IsEmpty()) 234 if (!message->GetStackTrace().IsEmpty())
249 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me ssage->GetStackTrace()->AsArray()); 235 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me ssage->GetStackTrace()->AsArray());
250 else 236 else
251 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); 237 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate));
252 return exceptionDetails; 238 return exceptionDetails;
253 } 239 }
254 240
255 } // namespace blink 241 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698