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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 2367163002: [DevTools] handle navigation after console.log (Closed)
Patch Set: Created 4 years, 2 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 | third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 { 108 {
109 } 109 }
110 110
111 InjectedScript::~InjectedScript() 111 InjectedScript::~InjectedScript()
112 { 112 {
113 } 113 }
114 114
115 void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Objec t> object, const String16& groupName, bool ownProperties, bool accessorPropertie sOnly, bool generatePreview, std::unique_ptr<Array<PropertyDescriptor>>* propert ies, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) 115 void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Objec t> object, const String16& groupName, bool ownProperties, bool accessorPropertie sOnly, bool generatePreview, std::unique_ptr<Array<PropertyDescriptor>>* propert ies, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
116 { 116 {
117 v8::HandleScope handles(m_context->isolate()); 117 v8::HandleScope handles(m_context->isolate());
118 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value (), "getProperties"); 118 v8::Local<v8::Context> context = m_context->context();
119 V8FunctionCall function(m_context->debugger(), context, v8Value(), "getPrope rties");
119 function.appendArgument(object); 120 function.appendArgument(object);
120 function.appendArgument(groupName); 121 function.appendArgument(groupName);
121 function.appendArgument(ownProperties); 122 function.appendArgument(ownProperties);
122 function.appendArgument(accessorPropertiesOnly); 123 function.appendArgument(accessorPropertiesOnly);
123 function.appendArgument(generatePreview); 124 function.appendArgument(generatePreview);
124 125
125 v8::TryCatch tryCatch(m_context->isolate()); 126 v8::TryCatch tryCatch(m_context->isolate());
126 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling(); 127 v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling();
127 if (tryCatch.HasCaught()) { 128 if (tryCatch.HasCaught()) {
128 *exceptionDetails = createExceptionDetails(tryCatch.Message()); 129 *exceptionDetails = createExceptionDetails(tryCatch.Message());
129 // FIXME: make properties optional 130 // FIXME: make properties optional
130 *properties = Array<PropertyDescriptor>::create(); 131 *properties = Array<PropertyDescriptor>::create();
131 return; 132 return;
132 } 133 }
133 134
134 std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(function.co ntext(), resultValue); 135 std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(context, re sultValue);
135 if (hasInternalError(errorString, !protocolValue)) 136 if (hasInternalError(errorString, !protocolValue))
136 return; 137 return;
137 protocol::ErrorSupport errors(errorString); 138 protocol::ErrorSupport errors(errorString);
138 std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor >::parse(protocolValue.get(), &errors); 139 std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor >::parse(protocolValue.get(), &errors);
139 if (!hasInternalError(errorString, errors.hasErrors())) 140 if (!hasInternalError(errorString, errors.hasErrors()))
140 *properties = std::move(result); 141 *properties = std::move(result);
141 } 142 }
142 143
143 void InjectedScript::releaseObject(const String16& objectId) 144 void InjectedScript::releaseObject(const String16& objectId)
144 { 145 {
145 std::unique_ptr<protocol::Value> parsedObjectId = protocol::parseJSON(object Id); 146 std::unique_ptr<protocol::Value> parsedObjectId = protocol::parseJSON(object Id);
146 if (!parsedObjectId) 147 if (!parsedObjectId)
147 return; 148 return;
148 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get()); 149 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get());
149 if (!object) 150 if (!object)
150 return; 151 return;
151 int boundId = 0; 152 int boundId = 0;
152 if (!object->getNumber("id", &boundId)) 153 if (!object->getNumber("id", &boundId))
153 return; 154 return;
154 m_native->unbind(boundId); 155 m_native->unbind(boundId);
155 } 156 }
156 157
157 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(Erro rString* errorString, v8::Local<v8::Value> value, const String16& groupName, boo l forceValueType, bool generatePreview) const 158 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(Erro rString* errorString, v8::Local<v8::Value> value, const String16& groupName, boo l forceValueType, bool generatePreview) const
158 { 159 {
159 v8::HandleScope handles(m_context->isolate()); 160 v8::HandleScope handles(m_context->isolate());
160 v8::Local<v8::Value> wrappedObject; 161 v8::Local<v8::Value> wrappedObject;
162 v8::Local<v8::Context> context = m_context->context();
161 if (!wrapValue(errorString, value, groupName, forceValueType, generatePrevie w).ToLocal(&wrappedObject)) 163 if (!wrapValue(errorString, value, groupName, forceValueType, generatePrevie w).ToLocal(&wrappedObject))
162 return nullptr; 164 return nullptr;
163 protocol::ErrorSupport errors; 165 protocol::ErrorSupport errors;
164 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Ru ntime::RemoteObject::parse(toProtocolValue(m_context->context(), wrappedObject). get(), &errors); 166 std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Ru ntime::RemoteObject::parse(toProtocolValue(context, wrappedObject).get(), &error s);
165 if (!remoteObject) 167 if (!remoteObject)
166 *errorString = "Object has too long reference chain"; 168 *errorString = "Object has too long reference chain";
167 return remoteObject; 169 return remoteObject;
168 } 170 }
169 171
170 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local<v8:: Object> object, v8::Local<v8::Name> key, const String16& groupName, bool forceVa lueType, bool generatePreview) const 172 bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local<v8:: Object> object, v8::Local<v8::Name> key, const String16& groupName, bool forceVa lueType, bool generatePreview) const
171 { 173 {
172 v8::Local<v8::Value> property; 174 v8::Local<v8::Value> property;
173 if (hasInternalError(errorString, !object->Get(m_context->context(), key).To Local(&property))) 175 v8::Local<v8::Context> context = m_context->context();
176 if (hasInternalError(errorString, !object->Get(context, key).ToLocal(&proper ty)))
174 return false; 177 return false;
175 v8::Local<v8::Value> wrappedProperty; 178 v8::Local<v8::Value> wrappedProperty;
176 if (!wrapValue(errorString, property, groupName, forceValueType, generatePre view).ToLocal(&wrappedProperty)) 179 if (!wrapValue(errorString, property, groupName, forceValueType, generatePre view).ToLocal(&wrappedProperty))
177 return false; 180 return false;
178 v8::Maybe<bool> success = createDataProperty(m_context->context(), object, k ey, wrappedProperty); 181 v8::Maybe<bool> success = createDataProperty(context, object, key, wrappedPr operty);
179 if (hasInternalError(errorString, success.IsNothing() || !success.FromJust() )) 182 if (hasInternalError(errorString, success.IsNothing() || !success.FromJust() ))
180 return false; 183 return false;
181 return true; 184 return true;
182 } 185 }
183 186
184 bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local<v8: :Array> array, v8::Local<v8::String> property, const String16& groupName, bool f orceValueType, bool generatePreview) const 187 bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local<v8: :Array> array, v8::Local<v8::String> property, const String16& groupName, bool f orceValueType, bool generatePreview) const
185 { 188 {
186 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value (), "wrapPropertyInArray"); 189 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value (), "wrapPropertyInArray");
187 function.appendArgument(array); 190 function.appendArgument(array);
188 function.appendArgument(property); 191 function.appendArgument(property);
(...skipping 30 matching lines...) Expand all
219 bool hadException = false; 222 bool hadException = false;
220 v8::Local<v8::Value> r = function.call(hadException); 223 v8::Local<v8::Value> r = function.call(hadException);
221 if (hasInternalError(errorString, hadException || r.IsEmpty())) 224 if (hasInternalError(errorString, hadException || r.IsEmpty()))
222 return v8::MaybeLocal<v8::Value>(); 225 return v8::MaybeLocal<v8::Value>();
223 return r; 226 return r;
224 } 227 }
225 228
226 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::L ocal<v8::Value> table, v8::Local<v8::Value> columns) const 229 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::L ocal<v8::Value> table, v8::Local<v8::Value> columns) const
227 { 230 {
228 v8::HandleScope handles(m_context->isolate()); 231 v8::HandleScope handles(m_context->isolate());
229 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value (), "wrapTable"); 232 v8::Local<v8::Context> context = m_context->context();
233 V8FunctionCall function(m_context->debugger(), context, v8Value(), "wrapTabl e");
230 function.appendArgument(canAccessInspectedWindow()); 234 function.appendArgument(canAccessInspectedWindow());
231 function.appendArgument(table); 235 function.appendArgument(table);
232 if (columns.IsEmpty()) 236 if (columns.IsEmpty())
233 function.appendArgument(false); 237 function.appendArgument(false);
234 else 238 else
235 function.appendArgument(columns); 239 function.appendArgument(columns);
236 bool hadException = false; 240 bool hadException = false;
237 v8::Local<v8::Value> r = function.call(hadException); 241 v8::Local<v8::Value> r = function.call(hadException);
238 if (hadException) 242 if (hadException)
239 return nullptr; 243 return nullptr;
240 protocol::ErrorSupport errors; 244 protocol::ErrorSupport errors;
241 return protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->con text(), r).get(), &errors); 245 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context, r).ge t(), &errors);
242 } 246 }
243 247
244 bool InjectedScript::findObject(ErrorString* errorString, const RemoteObjectId& objectId, v8::Local<v8::Value>* outObject) const 248 bool InjectedScript::findObject(ErrorString* errorString, const RemoteObjectId& objectId, v8::Local<v8::Value>* outObject) const
245 { 249 {
246 *outObject = m_native->objectForId(objectId.id()); 250 *outObject = m_native->objectForId(objectId.id());
247 if (outObject->IsEmpty()) 251 if (outObject->IsEmpty())
248 *errorString = "Could not find object with given id"; 252 *errorString = "Could not find object with given id";
249 return !outObject->IsEmpty(); 253 return !outObject->IsEmpty();
250 } 254 }
251 255
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session) 511 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session)
508 { 512 {
509 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err orString, m_remoteCallFrameId); 513 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err orString, m_remoteCallFrameId);
510 if (!remoteId) 514 if (!remoteId)
511 return; 515 return;
512 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 516 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
513 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() ); 517 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() );
514 } 518 }
515 519
516 } // namespace blink 520 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698