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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 v8::TryCatch tryCatch(m_context->isolate()); | 138 v8::TryCatch tryCatch(m_context->isolate()); |
139 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); | 139 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); |
140 if (tryCatch.HasCaught()) { | 140 if (tryCatch.HasCaught()) { |
141 *exceptionDetails = createExceptionDetails(errorString, tryCatch, groupName, | 141 *exceptionDetails = createExceptionDetails(errorString, tryCatch, groupName, |
142 generatePreview); | 142 generatePreview); |
143 // FIXME: make properties optional | 143 // FIXME: make properties optional |
144 *properties = Array<PropertyDescriptor>::create(); | 144 *properties = Array<PropertyDescriptor>::create(); |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 if (hasInternalError(errorString, resultValue.IsEmpty())) return; |
148 std::unique_ptr<protocol::Value> protocolValue = | 148 std::unique_ptr<protocol::Value> protocolValue = |
149 toProtocolValue(context, resultValue); | 149 toProtocolValue(errorString, context, resultValue); |
150 if (hasInternalError(errorString, !protocolValue)) return; | 150 if (!protocolValue) return; |
151 protocol::ErrorSupport errors(errorString); | 151 protocol::ErrorSupport errors(errorString); |
152 std::unique_ptr<Array<PropertyDescriptor>> result = | 152 std::unique_ptr<Array<PropertyDescriptor>> result = |
153 Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); | 153 Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); |
154 if (!hasInternalError(errorString, errors.hasErrors())) | 154 if (!hasInternalError(errorString, errors.hasErrors())) |
155 *properties = std::move(result); | 155 *properties = std::move(result); |
156 } | 156 } |
157 | 157 |
158 void InjectedScript::releaseObject(const String16& objectId) { | 158 void InjectedScript::releaseObject(const String16& objectId) { |
159 std::unique_ptr<protocol::Value> parsedObjectId = | 159 std::unique_ptr<protocol::Value> parsedObjectId = |
160 protocol::parseJSON(objectId); | 160 protocol::parseJSON(objectId); |
(...skipping 10 matching lines...) Expand all Loading... |
171 ErrorString* errorString, v8::Local<v8::Value> value, | 171 ErrorString* errorString, v8::Local<v8::Value> value, |
172 const String16& groupName, bool forceValueType, | 172 const String16& groupName, bool forceValueType, |
173 bool generatePreview) const { | 173 bool generatePreview) const { |
174 v8::HandleScope handles(m_context->isolate()); | 174 v8::HandleScope handles(m_context->isolate()); |
175 v8::Local<v8::Value> wrappedObject; | 175 v8::Local<v8::Value> wrappedObject; |
176 v8::Local<v8::Context> context = m_context->context(); | 176 v8::Local<v8::Context> context = m_context->context(); |
177 if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview) | 177 if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview) |
178 .ToLocal(&wrappedObject)) | 178 .ToLocal(&wrappedObject)) |
179 return nullptr; | 179 return nullptr; |
180 protocol::ErrorSupport errors; | 180 protocol::ErrorSupport errors; |
| 181 std::unique_ptr<protocol::Value> protocolValue = |
| 182 toProtocolValue(errorString, context, wrappedObject); |
| 183 if (!protocolValue) return nullptr; |
181 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = | 184 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = |
182 protocol::Runtime::RemoteObject::parse( | 185 protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); |
183 toProtocolValue(context, wrappedObject).get(), &errors); | 186 if (!remoteObject) *errorString = errors.errors(); |
184 if (!remoteObject) *errorString = "Object has too long reference chain"; | |
185 return remoteObject; | 187 return remoteObject; |
186 } | 188 } |
187 | 189 |
188 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, | 190 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, |
189 v8::Local<v8::Object> object, | 191 v8::Local<v8::Object> object, |
190 v8::Local<v8::Name> key, | 192 v8::Local<v8::Name> key, |
191 const String16& groupName, | 193 const String16& groupName, |
192 bool forceValueType, | 194 bool forceValueType, |
193 bool generatePreview) const { | 195 bool generatePreview) const { |
194 v8::Local<v8::Value> property; | 196 v8::Local<v8::Value> property; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 v8::Local<v8::Context> context = m_context->context(); | 267 v8::Local<v8::Context> context = m_context->context(); |
266 V8FunctionCall function(m_context->inspector(), context, v8Value(), | 268 V8FunctionCall function(m_context->inspector(), context, v8Value(), |
267 "wrapTable"); | 269 "wrapTable"); |
268 function.appendArgument(table); | 270 function.appendArgument(table); |
269 if (columns.IsEmpty()) | 271 if (columns.IsEmpty()) |
270 function.appendArgument(false); | 272 function.appendArgument(false); |
271 else | 273 else |
272 function.appendArgument(columns); | 274 function.appendArgument(columns); |
273 bool hadException = false; | 275 bool hadException = false; |
274 v8::Local<v8::Value> r = function.call(hadException); | 276 v8::Local<v8::Value> r = function.call(hadException); |
275 if (hadException) return nullptr; | 277 if (hadException || r.IsEmpty()) return nullptr; |
| 278 protocol::ErrorString errorString; |
| 279 std::unique_ptr<protocol::Value> protocolValue = |
| 280 toProtocolValue(&errorString, context, r); |
| 281 if (!protocolValue) return nullptr; |
276 protocol::ErrorSupport errors; | 282 protocol::ErrorSupport errors; |
277 return protocol::Runtime::RemoteObject::parse( | 283 return protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); |
278 toProtocolValue(context, r).get(), &errors); | |
279 } | 284 } |
280 | 285 |
281 bool InjectedScript::findObject(ErrorString* errorString, | 286 bool InjectedScript::findObject(ErrorString* errorString, |
282 const RemoteObjectId& objectId, | 287 const RemoteObjectId& objectId, |
283 v8::Local<v8::Value>* outObject) const { | 288 v8::Local<v8::Value>* outObject) const { |
284 *outObject = m_native->objectForId(objectId.id()); | 289 *outObject = m_native->objectForId(objectId.id()); |
285 if (outObject->IsEmpty()) | 290 if (outObject->IsEmpty()) |
286 *errorString = "Could not find object with given id"; | 291 *errorString = "Could not find object with given id"; |
287 return !outObject->IsEmpty(); | 292 return !outObject->IsEmpty(); |
288 } | 293 } |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 void InjectedScript::CallFrameScope::findInjectedScript( | 567 void InjectedScript::CallFrameScope::findInjectedScript( |
563 V8InspectorSessionImpl* session) { | 568 V8InspectorSessionImpl* session) { |
564 std::unique_ptr<RemoteCallFrameId> remoteId = | 569 std::unique_ptr<RemoteCallFrameId> remoteId = |
565 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); | 570 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); |
566 if (!remoteId) return; | 571 if (!remoteId) return; |
567 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 572 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
568 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); | 573 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); |
569 } | 574 } |
570 | 575 |
571 } // namespace v8_inspector | 576 } // namespace v8_inspector |
OLD | NEW |