OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 V8FunctionCall function(m_context->inspector(), m_context->context(), v8Valu
e(), "getProperties"); | 110 V8FunctionCall function(m_context->inspector(), m_context->context(), v8Valu
e(), "getProperties"); |
111 function.appendArgument(object); | 111 function.appendArgument(object); |
112 function.appendArgument(groupName); | 112 function.appendArgument(groupName); |
113 function.appendArgument(ownProperties); | 113 function.appendArgument(ownProperties); |
114 function.appendArgument(accessorPropertiesOnly); | 114 function.appendArgument(accessorPropertiesOnly); |
115 function.appendArgument(generatePreview); | 115 function.appendArgument(generatePreview); |
116 | 116 |
117 v8::TryCatch tryCatch(m_context->isolate()); | 117 v8::TryCatch tryCatch(m_context->isolate()); |
118 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); | 118 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); |
119 if (tryCatch.HasCaught()) { | 119 if (tryCatch.HasCaught()) { |
120 *exceptionDetails = createExceptionDetails(tryCatch.Message()); | 120 *exceptionDetails = createExceptionDetails(errorString, tryCatch, groupN
ame, generatePreview); |
121 // FIXME: make properties optional | 121 // FIXME: make properties optional |
122 *properties = Array<PropertyDescriptor>::create(); | 122 *properties = Array<PropertyDescriptor>::create(); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(m_context->
context(), resultValue); | 126 std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(m_context->
context(), resultValue); |
127 if (hasInternalError(errorString, !protocolValue)) | 127 if (hasInternalError(errorString, !protocolValue)) |
128 return; | 128 return; |
129 protocol::ErrorSupport errors(errorString); | 129 protocol::ErrorSupport errors(errorString); |
130 std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor
>::parse(protocolValue.get(), &errors); | 130 std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor
>::parse(protocolValue.get(), &errors); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 v8::Local<v8::Value> object; | 293 v8::Local<v8::Value> object; |
294 if (!m_context->inspector()->compileAndRunInternalScript(m_context->cont
ext(), toV8String(m_context->isolate(), value)).ToLocal(&object)) { | 294 if (!m_context->inspector()->compileAndRunInternalScript(m_context->cont
ext(), toV8String(m_context->isolate(), value)).ToLocal(&object)) { |
295 *errorString = "Couldn't parse value object in call argument"; | 295 *errorString = "Couldn't parse value object in call argument"; |
296 return v8::MaybeLocal<v8::Value>(); | 296 return v8::MaybeLocal<v8::Value>(); |
297 } | 297 } |
298 return object; | 298 return object; |
299 } | 299 } |
300 return v8::Undefined(m_context->isolate()); | 300 return v8::Undefined(m_context->isolate()); |
301 } | 301 } |
302 | 302 |
303 std::unique_ptr<protocol::Runtime::ExceptionDetails> InjectedScript::createExcep
tionDetails(v8::Local<v8::Message> message) | 303 std::unique_ptr<protocol::Runtime::ExceptionDetails> InjectedScript::createExcep
tionDetails(ErrorString* errorString, const v8::TryCatch& tryCatch, const String
16& objectGroup, bool generatePreview) |
304 { | 304 { |
305 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetailsObject
= protocol::Runtime::ExceptionDetails::create() | 305 if (!tryCatch.HasCaught()) |
306 .setText(toProtocolString(message->Get())) | 306 return nullptr; |
307 .setScriptId(String16::fromInteger(message->GetScriptOrigin().ScriptID()
->Value())) | 307 v8::Local<v8::Message> message = tryCatch.Message(); |
308 .setLineNumber(message->GetLineNumber(m_context->context()).FromMaybe(1)
- 1) | 308 v8::Local<v8::Value> exception = tryCatch.Exception(); |
309 .setColumnNumber(message->GetStartColumn(m_context->context()).FromMaybe
(0)) | 309 String16 messageText = message.IsEmpty() ? String16() : toProtocolString(mes
sage->Get()); |
| 310 std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails = prot
ocol::Runtime::ExceptionDetails::create() |
| 311 .setExceptionId(m_context->inspector()->nextExceptionId()) |
| 312 .setText(exception.IsEmpty() ? messageText : String16("Uncaught")) |
| 313 .setLineNumber(message.IsEmpty() ? 0 : message->GetLineNumber(m_context-
>context()).FromMaybe(1) - 1) |
| 314 .setColumnNumber(message.IsEmpty() ? 0 : message->GetStartColumn(m_conte
xt->context()).FromMaybe(0)) |
310 .build(); | 315 .build(); |
311 | 316 if (!message.IsEmpty()) { |
312 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace(); | 317 exceptionDetails->setScriptId(String16::fromInteger(message->GetScriptOr
igin().ScriptID()->Value())); |
313 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 318 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace(); |
314 exceptionDetailsObject->setStackTrace(m_context->inspector()->debugger()
->createStackTrace(stackTrace)->buildInspectorObjectImpl()); | 319 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
315 return exceptionDetailsObject; | 320 exceptionDetails->setStackTrace(m_context->inspector()->debugger()->
createStackTrace(stackTrace)->buildInspectorObjectImpl()); |
| 321 } |
| 322 if (!exception.IsEmpty()) { |
| 323 std::unique_ptr<protocol::Runtime::RemoteObject> wrapped = wrapObject(er
rorString, exception, objectGroup, false /* forceValueType */, generatePreview &
& !exception->IsNativeError()); |
| 324 if (!wrapped) |
| 325 return nullptr; |
| 326 exceptionDetails->setException(std::move(wrapped)); |
| 327 } |
| 328 return exceptionDetails; |
316 } | 329 } |
317 | 330 |
318 void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal
<v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& obje
ctGroup, bool returnByValue, bool generatePreview, std::unique_ptr<protocol::Run
time::RemoteObject>* result, Maybe<protocol::Runtime::ExceptionDetails>* excepti
onDetails) | 331 void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal
<v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& obje
ctGroup, bool returnByValue, bool generatePreview, std::unique_ptr<protocol::Run
time::RemoteObject>* result, Maybe<protocol::Runtime::ExceptionDetails>* excepti
onDetails) |
319 { | 332 { |
320 v8::Local<v8::Value> resultValue; | 333 v8::Local<v8::Value> resultValue; |
321 if (!tryCatch.HasCaught()) { | 334 if (!tryCatch.HasCaught()) { |
322 if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue
))) | 335 if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue
))) |
323 return; | 336 return; |
324 std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, res
ultValue, objectGroup, returnByValue, generatePreview); | 337 std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, res
ultValue, objectGroup, returnByValue, generatePreview); |
325 if (!remoteObject) | 338 if (!remoteObject) |
326 return; | 339 return; |
327 if (objectGroup == "console") | 340 if (objectGroup == "console") |
328 m_lastEvaluationResult.Reset(m_context->isolate(), resultValue); | 341 m_lastEvaluationResult.Reset(m_context->isolate(), resultValue); |
329 *result = std::move(remoteObject); | 342 *result = std::move(remoteObject); |
330 } else { | 343 } else { |
331 v8::Local<v8::Value> exception = tryCatch.Exception(); | 344 v8::Local<v8::Value> exception = tryCatch.Exception(); |
332 std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, exc
eption, objectGroup, false, generatePreview && !exception->IsNativeError()); | 345 std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, exc
eption, objectGroup, false, generatePreview && !exception->IsNativeError()); |
333 if (!remoteObject) | 346 if (!remoteObject) |
334 return; | 347 return; |
| 348 // We send exception in result for compatibility reasons, even though it
's accessible through exceptionDetails.exception. |
335 *result = std::move(remoteObject); | 349 *result = std::move(remoteObject); |
336 *exceptionDetails = createExceptionDetails(tryCatch.Message()); | 350 *exceptionDetails = createExceptionDetails(errorString, tryCatch, object
Group, generatePreview); |
337 } | 351 } |
338 } | 352 } |
339 | 353 |
340 v8::Local<v8::Object> InjectedScript::commandLineAPI() | 354 v8::Local<v8::Object> InjectedScript::commandLineAPI() |
341 { | 355 { |
342 if (m_commandLineAPI.IsEmpty()) | 356 if (m_commandLineAPI.IsEmpty()) |
343 m_commandLineAPI.Reset(m_context->isolate(), V8Console::createCommandLin
eAPI(m_context)); | 357 m_commandLineAPI.Reset(m_context->isolate(), V8Console::createCommandLin
eAPI(m_context)); |
344 return m_commandLineAPI.Get(m_context->isolate()); | 358 return m_commandLineAPI.Get(m_context->isolate()); |
345 } | 359 } |
346 | 360 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) | 494 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) |
481 { | 495 { |
482 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err
orString, m_remoteCallFrameId); | 496 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err
orString, m_remoteCallFrameId); |
483 if (!remoteId) | 497 if (!remoteId) |
484 return; | 498 return; |
485 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 499 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
486 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); | 500 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); |
487 } | 501 } |
488 | 502 |
489 } // namespace v8_inspector | 503 } // namespace v8_inspector |
OLD | NEW |