| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 108 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
| 109 if (exceptionDetails->isJust()) { | 109 if (exceptionDetails->isJust()) { |
| 110 // FIXME: make properties optional | 110 // FIXME: make properties optional |
| 111 *properties = Array<PropertyDescriptor>::create(); | 111 *properties = Array<PropertyDescriptor>::create(); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 protocol::ErrorSupport errors(errorString); | 114 protocol::ErrorSupport errors(errorString); |
| 115 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); | 115 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto
col::Runtime::ExceptionDetails>* exceptionDetails) | |
| 119 { | |
| 120 v8::HandleScope handles(m_isolate); | |
| 121 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInt
ernalProperties"); | |
| 122 function.appendArgument(objectId); | |
| 123 | |
| 124 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | |
| 125 if (exceptionDetails->isJust()) | |
| 126 return; | |
| 127 protocol::ErrorSupport errors(errorString); | |
| 128 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc
riptor>::parse(result.get(), &errors); | |
| 129 if (!errors.hasErrors() && array->length() > 0) | |
| 130 *properties = array.release(); | |
| 131 } | |
| 132 | |
| 133 void InjectedScript::releaseObject(const String16& objectId) | 118 void InjectedScript::releaseObject(const String16& objectId) |
| 134 { | 119 { |
| 135 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); | 120 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); |
| 136 if (!parsedObjectId) | 121 if (!parsedObjectId) |
| 137 return; | 122 return; |
| 138 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); | 123 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb
jectId.get()); |
| 139 if (!object) | 124 if (!object) |
| 140 return; | 125 return; |
| 141 int boundId = 0; | 126 int boundId = 0; |
| 142 if (!object->getNumber("id", &boundId)) | 127 if (!object->getNumber("id", &boundId)) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 else | 204 else |
| 220 function.appendArgument(columns); | 205 function.appendArgument(columns); |
| 221 bool hadException = false; | 206 bool hadException = false; |
| 222 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException
); | 207 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException
); |
| 223 if (hadException) | 208 if (hadException) |
| 224 return nullptr; | 209 return nullptr; |
| 225 protocol::ErrorSupport errors; | 210 protocol::ErrorSupport errors; |
| 226 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); | 211 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).
get(), &errors); |
| 227 } | 212 } |
| 228 | 213 |
| 229 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId)
const | 214 bool InjectedScript::findObject(ErrorString* errorString, const RemoteObjectId&
objectId, v8::Local<v8::Value>* outObject) const |
| 230 { | 215 { |
| 231 return m_native->objectForId(objectId.id()); | 216 *outObject = m_native->objectForId(objectId.id()); |
| 217 if (outObject->IsEmpty()) |
| 218 *errorString = "Could not find object with given id"; |
| 219 return !outObject->IsEmpty(); |
| 232 } | 220 } |
| 233 | 221 |
| 234 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const | 222 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const |
| 235 { | 223 { |
| 236 return m_native->groupName(objectId.id()); | 224 return m_native->groupName(objectId.id()); |
| 237 } | 225 } |
| 238 | 226 |
| 239 void InjectedScript::releaseObjectGroup(const String16& objectGroup) | 227 void InjectedScript::releaseObjectGroup(const String16& objectGroup) |
| 240 { | 228 { |
| 241 v8::HandleScope handles(m_isolate); | 229 v8::HandleScope handles(m_isolate); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* error
String, protocol::Runtime::CallArgument* callArgument) | 336 v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* error
String, protocol::Runtime::CallArgument* callArgument) |
| 349 { | 337 { |
| 350 if (callArgument->hasObjectId()) { | 338 if (callArgument->hasObjectId()) { |
| 351 OwnPtr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(errorStrin
g, callArgument->getObjectId("")); | 339 OwnPtr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(errorStrin
g, callArgument->getObjectId("")); |
| 352 if (!remoteObjectId) | 340 if (!remoteObjectId) |
| 353 return v8::MaybeLocal<v8::Value>(); | 341 return v8::MaybeLocal<v8::Value>(); |
| 354 if (remoteObjectId->contextId() != m_contextId) { | 342 if (remoteObjectId->contextId() != m_contextId) { |
| 355 *errorString = "Argument should belong to the same JavaScript world
as target object"; | 343 *errorString = "Argument should belong to the same JavaScript world
as target object"; |
| 356 return v8::MaybeLocal<v8::Value>(); | 344 return v8::MaybeLocal<v8::Value>(); |
| 357 } | 345 } |
| 358 v8::Local<v8::Value> object = findObject(*remoteObjectId); | 346 v8::Local<v8::Value> object; |
| 359 if (object.IsEmpty()) { | 347 if (!findObject(errorString, *remoteObjectId, &object)) |
| 360 *errorString = "Could not find object with given id"; | |
| 361 return v8::MaybeLocal<v8::Value>(); | 348 return v8::MaybeLocal<v8::Value>(); |
| 362 } | |
| 363 return object; | 349 return object; |
| 364 } | 350 } |
| 365 if (callArgument->hasValue()) { | 351 if (callArgument->hasValue()) { |
| 366 String16 value = callArgument->getValue(nullptr)->toJSONString(); | 352 String16 value = callArgument->getValue(nullptr)->toJSONString(); |
| 367 if (callArgument->getType(String16()) == "number") | 353 if (callArgument->getType(String16()) == "number") |
| 368 value = "Number(" + value + ")"; | 354 value = "Number(" + value + ")"; |
| 369 v8::Local<v8::Value> object; | 355 v8::Local<v8::Value> object; |
| 370 if (!m_manager->debugger()->compileAndRunInternalScript(context(), toV8S
tring(m_isolate, value)).ToLocal(&object)) { | 356 if (!m_manager->debugger()->compileAndRunInternalScript(context(), toV8S
tring(m_isolate, value)).ToLocal(&object)) { |
| 371 *errorString = "Couldn't parse value object in call argument"; | 357 *errorString = "Couldn't parse value object in call argument"; |
| 372 return v8::MaybeLocal<v8::Value>(); | 358 return v8::MaybeLocal<v8::Value>(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 return; | 429 return; |
| 444 *result = remoteObject.release(); | 430 *result = remoteObject.release(); |
| 445 if (exceptionDetails) | 431 if (exceptionDetails) |
| 446 *exceptionDetails = createExceptionDetails(tryCatch.Message()); | 432 *exceptionDetails = createExceptionDetails(tryCatch.Message()); |
| 447 if (wasThrown) | 433 if (wasThrown) |
| 448 *wasThrown = true; | 434 *wasThrown = true; |
| 449 } | 435 } |
| 450 } | 436 } |
| 451 | 437 |
| 452 } // namespace blink | 438 } // namespace blink |
| OLD | NEW |