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

Side by Side Diff: src/inspector/InjectedScript.cpp

Issue 2352263003: Revert of [inspector] provide more usefull error message for non serializable value (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | src/inspector/StringUtil.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (hasInternalError(errorString, resultValue.IsEmpty())) return; 147
148 std::unique_ptr<protocol::Value> protocolValue = 148 std::unique_ptr<protocol::Value> protocolValue =
149 toProtocolValue(errorString, context, resultValue); 149 toProtocolValue(context, resultValue);
150 if (!protocolValue) return; 150 if (hasInternalError(errorString, !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
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;
184 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = 181 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject =
185 protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); 182 protocol::Runtime::RemoteObject::parse(
186 if (!remoteObject) *errorString = errors.errors(); 183 toProtocolValue(context, wrappedObject).get(), &errors);
184 if (!remoteObject) *errorString = "Object has too long reference chain";
187 return remoteObject; 185 return remoteObject;
188 } 186 }
189 187
190 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, 188 bool InjectedScript::wrapObjectProperty(ErrorString* errorString,
191 v8::Local<v8::Object> object, 189 v8::Local<v8::Object> object,
192 v8::Local<v8::Name> key, 190 v8::Local<v8::Name> key,
193 const String16& groupName, 191 const String16& groupName,
194 bool forceValueType, 192 bool forceValueType,
195 bool generatePreview) const { 193 bool generatePreview) const {
196 v8::Local<v8::Value> property; 194 v8::Local<v8::Value> property;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 v8::Local<v8::Context> context = m_context->context(); 265 v8::Local<v8::Context> context = m_context->context();
268 V8FunctionCall function(m_context->inspector(), context, v8Value(), 266 V8FunctionCall function(m_context->inspector(), context, v8Value(),
269 "wrapTable"); 267 "wrapTable");
270 function.appendArgument(table); 268 function.appendArgument(table);
271 if (columns.IsEmpty()) 269 if (columns.IsEmpty())
272 function.appendArgument(false); 270 function.appendArgument(false);
273 else 271 else
274 function.appendArgument(columns); 272 function.appendArgument(columns);
275 bool hadException = false; 273 bool hadException = false;
276 v8::Local<v8::Value> r = function.call(hadException); 274 v8::Local<v8::Value> r = function.call(hadException);
277 if (hadException || r.IsEmpty()) return nullptr; 275 if (hadException) return nullptr;
278 protocol::ErrorString errorString;
279 std::unique_ptr<protocol::Value> protocolValue =
280 toProtocolValue(&errorString, context, r);
281 if (!protocolValue) return nullptr;
282 protocol::ErrorSupport errors; 276 protocol::ErrorSupport errors;
283 return protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); 277 return protocol::Runtime::RemoteObject::parse(
278 toProtocolValue(context, r).get(), &errors);
284 } 279 }
285 280
286 bool InjectedScript::findObject(ErrorString* errorString, 281 bool InjectedScript::findObject(ErrorString* errorString,
287 const RemoteObjectId& objectId, 282 const RemoteObjectId& objectId,
288 v8::Local<v8::Value>* outObject) const { 283 v8::Local<v8::Value>* outObject) const {
289 *outObject = m_native->objectForId(objectId.id()); 284 *outObject = m_native->objectForId(objectId.id());
290 if (outObject->IsEmpty()) 285 if (outObject->IsEmpty())
291 *errorString = "Could not find object with given id"; 286 *errorString = "Could not find object with given id";
292 return !outObject->IsEmpty(); 287 return !outObject->IsEmpty();
293 } 288 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 void InjectedScript::CallFrameScope::findInjectedScript( 562 void InjectedScript::CallFrameScope::findInjectedScript(
568 V8InspectorSessionImpl* session) { 563 V8InspectorSessionImpl* session) {
569 std::unique_ptr<RemoteCallFrameId> remoteId = 564 std::unique_ptr<RemoteCallFrameId> remoteId =
570 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); 565 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
571 if (!remoteId) return; 566 if (!remoteId) return;
572 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 567 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
573 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); 568 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get());
574 } 569 }
575 570
576 } // namespace v8_inspector 571 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | src/inspector/StringUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698