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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 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 19 matching lines...) Expand all
30 30
31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
32 32
33 #include "platform/inspector_protocol/Values.h" 33 #include "platform/inspector_protocol/Values.h"
34 #include "platform/v8_inspector/IgnoreExceptionsScope.h" 34 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
35 #include "platform/v8_inspector/InjectedScript.h" 35 #include "platform/v8_inspector/InjectedScript.h"
36 #include "platform/v8_inspector/InjectedScriptHost.h" 36 #include "platform/v8_inspector/InjectedScriptHost.h"
37 #include "platform/v8_inspector/InjectedScriptManager.h" 37 #include "platform/v8_inspector/InjectedScriptManager.h"
38 #include "platform/v8_inspector/RemoteObjectId.h" 38 #include "platform/v8_inspector/RemoteObjectId.h"
39 #include "platform/v8_inspector/V8DebuggerImpl.h" 39 #include "platform/v8_inspector/V8DebuggerImpl.h"
40 #include "platform/v8_inspector/V8StackTraceImpl.h"
41 #include "platform/v8_inspector/V8StringUtil.h" 40 #include "platform/v8_inspector/V8StringUtil.h"
42 #include "platform/v8_inspector/public/V8DebuggerClient.h" 41 #include "platform/v8_inspector/public/V8DebuggerClient.h"
43 42
44 namespace blink { 43 namespace blink {
45 44
46 namespace V8RuntimeAgentImplState { 45 namespace V8RuntimeAgentImplState {
47 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled "; 46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled ";
48 }; 47 };
49 48
50 using protocol::Runtime::ExceptionDetails; 49 using protocol::Runtime::ExceptionDetails;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 203 }
205 204
206 v8::Isolate* isolate = injectedScript->isolate(); 205 v8::Isolate* isolate = injectedScript->isolate();
207 v8::HandleScope handles(isolate); 206 v8::HandleScope handles(isolate);
208 v8::Context::Scope scope(injectedScript->context()); 207 v8::Context::Scope scope(injectedScript->context());
209 v8::TryCatch tryCatch(isolate); 208 v8::TryCatch tryCatch(isolate);
210 v8::Local<v8::Script> script = m_debugger->compileInternalScript(injectedScr ipt->context(), toV8String(isolate, expression), sourceURL); 209 v8::Local<v8::Script> script = m_debugger->compileInternalScript(injectedScr ipt->context(), toV8String(isolate, expression), sourceURL);
211 if (script.IsEmpty()) { 210 if (script.IsEmpty()) {
212 v8::Local<v8::Message> message = tryCatch.Message(); 211 v8::Local<v8::Message> message = tryCatch.Message();
213 if (!message.IsEmpty()) 212 if (!message.IsEmpty())
214 *exceptionDetails = createExceptionDetails(isolate, message); 213 *exceptionDetails = injectedScript->createExceptionDetails(message);
215 else 214 else
216 *errorString = "Script compilation failed"; 215 *errorString = "Script compilation failed";
217 return; 216 return;
218 } 217 }
219 218
220 if (!persistScript) 219 if (!persistScript)
221 return; 220 return;
222 221
223 String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId( )); 222 String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId( ));
224 OwnPtr<v8::Global<v8::Script>> global = adoptPtr(new v8::Global<v8::Script>( isolate, script)); 223 OwnPtr<v8::Global<v8::Script>> global = adoptPtr(new v8::Global<v8::Script>( isolate, script));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 v8::Context::Scope scope(context); 257 v8::Context::Scope scope(context);
259 OwnPtr<v8::Global<v8::Script>> scriptWrapper = m_compiledScripts.take(script Id); 258 OwnPtr<v8::Global<v8::Script>> scriptWrapper = m_compiledScripts.take(script Id);
260 v8::Local<v8::Script> script = scriptWrapper->Get(isolate); 259 v8::Local<v8::Script> script = scriptWrapper->Get(isolate);
261 260
262 if (script.IsEmpty()) { 261 if (script.IsEmpty()) {
263 *errorString = "Script execution failed"; 262 *errorString = "Script execution failed";
264 return; 263 return;
265 } 264 }
266 v8::TryCatch tryCatch(isolate); 265 v8::TryCatch tryCatch(isolate);
267 266
267 v8::Local<v8::Object> commandLineAPI;
dgozman 2016/03/17 20:56:12 ditto
kozy 2016/03/17 21:05:22 Done.
268 if (includeCommandLineAPI.fromMaybe(false) && !injectedScript->commandLineAP I(errorString).ToLocal(&commandLineAPI))
269 return;
270
271 InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedSc ript, nullptr, commandLineAPI);
272
268 v8::Local<v8::Value> value; 273 v8::Local<v8::Value> value;
269 v8::MaybeLocal<v8::Value> maybeValue = injectedScript->runCompiledScript(scr ipt, includeCommandLineAPI.fromMaybe(false)); 274 v8::MaybeLocal<v8::Value> maybeValue = m_debugger->runCompiledScript(context , script);
270 if (maybeValue.IsEmpty()) { 275 if (maybeValue.IsEmpty()) {
271 value = tryCatch.Exception(); 276 value = tryCatch.Exception();
272 v8::Local<v8::Message> message = tryCatch.Message(); 277 v8::Local<v8::Message> message = tryCatch.Message();
273 if (!message.IsEmpty()) 278 if (!message.IsEmpty())
274 *exceptionDetails = createExceptionDetails(isolate, message); 279 *exceptionDetails = injectedScript->createExceptionDetails(message);
275 } else { 280 } else {
276 value = maybeValue.ToLocalChecked(); 281 value = maybeValue.ToLocalChecked();
277 } 282 }
278 283
279 if (value.IsEmpty()) { 284 if (value.IsEmpty()) {
280 *errorString = "Script execution failed"; 285 *errorString = "Script execution failed";
281 return; 286 return;
282 } 287 }
283 288
284 *result = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); 289 // InjectedScript may be gone after any evaluate call - find it again.
290 injectedScript = m_injectedScriptManager->findInjectedScript(executionContex tId);
291 if (!injectedScript) {
292 *errorString = "Inspected frame has gone during script running";
293 return;
294 }
295
296 *result = injectedScript->wrapObject(errorString, value, objectGroup.fromMay be(""));
285 } 297 }
286 298
287 void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state) 299 void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state)
288 { 300 {
289 m_state = state; 301 m_state = state;
290 } 302 }
291 303
292 void V8RuntimeAgentImpl::setFrontend(protocol::Frontend::Runtime* frontend) 304 void V8RuntimeAgentImpl::setFrontend(protocol::Frontend::Runtime* frontend)
293 { 305 {
294 m_frontend = frontend; 306 m_frontend = frontend;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void V8RuntimeAgentImpl::setInspectObjectCallback(PassOwnPtr<V8RuntimeAgent::Ins pectCallback> callback) 357 void V8RuntimeAgentImpl::setInspectObjectCallback(PassOwnPtr<V8RuntimeAgent::Ins pectCallback> callback)
346 { 358 {
347 m_injectedScriptManager->injectedScriptHost()->setInspectObjectCallback(call back); 359 m_injectedScriptManager->injectedScriptHost()->setInspectObjectCallback(call back);
348 } 360 }
349 361
350 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapObject(v8::Local<v8::Context> c ontext, v8::Local<v8::Value> value, const String16& groupName, bool generatePrev iew) 362 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapObject(v8::Local<v8::Context> c ontext, v8::Local<v8::Value> value, const String16& groupName, bool generatePrev iew)
351 { 363 {
352 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( context); 364 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( context);
353 if (!injectedScript) 365 if (!injectedScript)
354 return nullptr; 366 return nullptr;
355 return injectedScript->wrapObject(value, groupName, generatePreview); 367 ErrorString errorString;
368 return injectedScript->wrapObject(&errorString, value, groupName, false, gen eratePreview);
356 } 369 }
357 370
358 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapTable(v8::Local<v8::Context> co ntext, v8::Local<v8::Value> table, v8::Local<v8::Value> columns) 371 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapTable(v8::Local<v8::Context> co ntext, v8::Local<v8::Value> table, v8::Local<v8::Value> columns)
359 { 372 {
360 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( context); 373 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( context);
361 if (!injectedScript) 374 if (!injectedScript)
362 return nullptr; 375 return nullptr;
363 return injectedScript->wrapTable(table, columns); 376 return injectedScript->wrapTable(table, columns);
364 } 377 }
365 378
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 425 }
413 426
414 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context> context) 427 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context> context)
415 { 428 {
416 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); 429 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context);
417 if (!m_enabled) 430 if (!m_enabled)
418 return; 431 return;
419 m_frontend->executionContextDestroyed(contextId); 432 m_frontend->executionContextDestroyed(contextId);
420 } 433 }
421 434
422 PassOwnPtr<ExceptionDetails> V8RuntimeAgentImpl::createExceptionDetails(v8::Isol ate* isolate, v8::Local<v8::Message> message)
423 {
424 OwnPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe xt(toProtocolStringWithTypeCheck(message->Get())).build();
425 exceptionDetails->setLine(message->GetLineNumber());
426 exceptionDetails->setColumn(message->GetStartColumn());
427 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace();
428 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0)
429 exceptionDetails->setStack(m_debugger->createStackTrace(messageStackTrac e, messageStackTrace->GetFrameCount())->buildInspectorObject());
430 return exceptionDetails.release();
431 }
432
433 } // namespace blink 435 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698