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 17 matching lines...) Expand all Loading... | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/v8_inspector/InjectedScript.h" | 31 #include "platform/v8_inspector/InjectedScript.h" |
32 | 32 |
33 #include "platform/inspector_protocol/Parser.h" | 33 #include "platform/inspector_protocol/Parser.h" |
34 #include "platform/inspector_protocol/Values.h" | 34 #include "platform/inspector_protocol/Values.h" |
35 #include "platform/v8_inspector/InjectedScriptHost.h" | 35 #include "platform/v8_inspector/InjectedScriptHost.h" |
36 #include "platform/v8_inspector/InjectedScriptManager.h" | 36 #include "platform/v8_inspector/InjectedScriptManager.h" |
37 #include "platform/v8_inspector/RemoteObjectId.h" | 37 #include "platform/v8_inspector/RemoteObjectId.h" |
38 #include "platform/v8_inspector/V8DebuggerImpl.h" | |
38 #include "platform/v8_inspector/V8FunctionCall.h" | 39 #include "platform/v8_inspector/V8FunctionCall.h" |
39 #include "platform/v8_inspector/V8StringUtil.h" | 40 #include "platform/v8_inspector/V8StringUtil.h" |
40 #include "platform/v8_inspector/public/V8Debugger.h" | 41 #include "platform/v8_inspector/public/V8Debugger.h" |
41 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
42 #include "platform/v8_inspector/public/V8ToProtocolValue.h" | 43 #include "platform/v8_inspector/public/V8ToProtocolValue.h" |
43 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
44 | 45 |
45 using blink::protocol::Array; | 46 using blink::protocol::Array; |
46 using blink::protocol::Debugger::CallFrame; | 47 using blink::protocol::Debugger::CallFrame; |
47 using blink::protocol::Debugger::CollectionEntry; | 48 using blink::protocol::Debugger::CollectionEntry; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 if (originScriptId) | 109 if (originScriptId) |
109 exceptionDetails->setScriptId(String::number(originScriptId)); | 110 exceptionDetails->setScriptId(String::number(originScriptId)); |
110 return exceptionDetails.release(); | 111 return exceptionDetails.release(); |
111 } | 112 } |
112 | 113 |
113 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) | 114 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) |
114 { | 115 { |
115 data.GetParameter()->dispose(); | 116 data.GetParameter()->dispose(); |
116 } | 117 } |
117 | 118 |
118 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPt r<InjectedScriptNative> injectedScriptNative, int contextId) | 119 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> in jectedScriptNative, int contextId) |
119 : m_manager(manager) | 120 : m_manager(manager) |
120 , m_isolate(context->GetIsolate()) | 121 , m_isolate(context->GetIsolate()) |
121 , m_context(m_isolate, context) | 122 , m_context(m_isolate, context) |
122 , m_value(m_isolate, object) | 123 , m_value(m_isolate, object) |
123 , m_client(client) | |
124 , m_native(injectedScriptNative) | 124 , m_native(injectedScriptNative) |
125 , m_contextId(contextId) | 125 , m_contextId(contextId) |
126 { | 126 { |
127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); | 127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); |
128 } | 128 } |
129 | 129 |
130 InjectedScript::~InjectedScript() | 130 InjectedScript::~InjectedScript() |
131 { | 131 { |
132 } | 132 } |
133 | 133 |
134 void InjectedScript::evaluate(ErrorString* errorString, const String& expression , const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, boo l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 134 void InjectedScript::evaluate(ErrorString* errorString, const String& expression , const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, boo l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
135 { | 135 { |
136 v8::HandleScope handles(m_isolate); | 136 v8::HandleScope handles(m_isolate); |
137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); | 137 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua te"); |
138 function.appendArgument(expression); | 138 function.appendArgument(expression); |
139 function.appendArgument(objectGroup); | 139 function.appendArgument(objectGroup); |
140 function.appendArgument(includeCommandLineAPI); | 140 function.appendArgument(includeCommandLineAPI); |
141 function.appendArgument(returnByValue); | 141 function.appendArgument(returnByValue); |
142 function.appendArgument(generatePreview); | 142 function.appendArgument(generatePreview); |
143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
144 } | 144 } |
145 | 145 |
146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje ctId, const String& expression, const String& arguments, bool returnByValue, boo l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown) | 146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje ctId, const String& expression, const String& arguments, bool returnByValue, boo l generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown) |
147 { | 147 { |
148 v8::HandleScope handles(m_isolate); | 148 v8::HandleScope handles(m_isolate); |
149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); | 149 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "callFu nctionOn"); |
150 function.appendArgument(objectId); | 150 function.appendArgument(objectId); |
151 function.appendArgument(expression); | 151 function.appendArgument(expression); |
152 function.appendArgument(arguments); | 152 function.appendArgument(arguments); |
153 function.appendArgument(returnByValue); | 153 function.appendArgument(returnByValue); |
154 function.appendArgument(generatePreview); | 154 function.appendArgument(generatePreview); |
155 *result = makeEvalCall(errorString, function, wasThrown); | 155 *result = makeEvalCall(errorString, function, wasThrown); |
156 } | 156 } |
157 | 157 |
158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool genera tePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol: :Runtime::ExceptionDetails>* exceptionDetails) | 158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool genera tePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol: :Runtime::ExceptionDetails>* exceptionDetails) |
159 { | 159 { |
160 v8::HandleScope handles(m_isolate); | 160 v8::HandleScope handles(m_isolate); |
161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame "); | 161 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua teOnCallFrame"); |
162 function.appendArgument(callFrames); | 162 function.appendArgument(callFrames); |
163 function.appendArgument(callFrameId); | 163 function.appendArgument(callFrameId); |
164 function.appendArgument(expression); | 164 function.appendArgument(expression); |
165 function.appendArgument(objectGroup); | 165 function.appendArgument(objectGroup); |
166 function.appendArgument(includeCommandLineAPI); | 166 function.appendArgument(includeCommandLineAPI); |
167 function.appendArgument(returnByValue); | 167 function.appendArgument(returnByValue); |
168 function.appendArgument(generatePreview); | 168 function.appendArgument(generatePreview); |
169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); | 169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); |
170 } | 170 } |
171 | 171 |
172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object > callFrames, const String& callFrameId) | 172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object > callFrames, const String& callFrameId) |
173 { | 173 { |
174 v8::HandleScope handles(m_isolate); | 174 v8::HandleScope handles(m_isolate); |
175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); | 175 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "restar tFrame"); |
176 function.appendArgument(callFrames); | 176 function.appendArgument(callFrames); |
177 function.appendArgument(callFrameId); | 177 function.appendArgument(callFrameId); |
178 OwnPtr<protocol::Value> resultValue = makeCall(function); | 178 OwnPtr<protocol::Value> resultValue = makeCall(function); |
179 if (resultValue) { | 179 if (resultValue) { |
180 if (resultValue->type() == protocol::Value::TypeString) { | 180 if (resultValue->type() == protocol::Value::TypeString) { |
181 resultValue->asString(errorString); | 181 resultValue->asString(errorString); |
182 } else { | 182 } else { |
183 bool value; | 183 bool value; |
184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); | 184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); |
185 } | 185 } |
186 return; | 186 return; |
187 } | 187 } |
188 *errorString = "Internal error"; | 188 *errorString = "Internal error"; |
189 } | 189 } |
190 | 190 |
191 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8:: Object> callFrames, const String& callFrameId, Maybe<Array<protocol::Debugger::L ocation>>* positions) | 191 void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8:: Object> callFrames, const String& callFrameId, Maybe<Array<protocol::Debugger::L ocation>>* positions) |
192 { | 192 { |
193 v8::HandleScope handles(m_isolate); | 193 v8::HandleScope handles(m_isolate); |
194 V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions" ); | 194 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getSte pInPositions"); |
195 function.appendArgument(callFrames); | 195 function.appendArgument(callFrames); |
196 function.appendArgument(callFrameId); | 196 function.appendArgument(callFrameId); |
197 OwnPtr<protocol::Value> resultValue = makeCall(function); | 197 OwnPtr<protocol::Value> resultValue = makeCall(function); |
198 if (resultValue) { | 198 if (resultValue) { |
199 if (resultValue->type() == protocol::Value::TypeString) { | 199 if (resultValue->type() == protocol::Value::TypeString) { |
200 resultValue->asString(errorString); | 200 resultValue->asString(errorString); |
201 return; | 201 return; |
202 } | 202 } |
203 if (resultValue->type() == protocol::Value::TypeArray) { | 203 if (resultValue->type() == protocol::Value::TypeArray) { |
204 protocol::ErrorSupport errors(errorString); | 204 protocol::ErrorSupport errors(errorString); |
205 *positions = Array<protocol::Debugger::Location>::parse(resultValue. get(), &errors); | 205 *positions = Array<protocol::Debugger::Location>::parse(resultValue. get(), &errors); |
206 return; | 206 return; |
207 } | 207 } |
208 } | 208 } |
209 *errorString = "Internal error"; | 209 *errorString = "Internal error"; |
210 } | 210 } |
211 | 211 |
212 void InjectedScript::setVariableValue(ErrorString* errorString, | 212 void InjectedScript::setVariableValue(ErrorString* errorString, |
213 v8::Local<v8::Object> callFrames, | 213 v8::Local<v8::Object> callFrames, |
214 const protocol::Maybe<String>& callFrameIdOpt, | 214 const protocol::Maybe<String>& callFrameIdOpt, |
215 const protocol::Maybe<String>& functionObjectIdOpt, | 215 const protocol::Maybe<String>& functionObjectIdOpt, |
216 int scopeNumber, | 216 int scopeNumber, |
217 const String& variableName, | 217 const String& variableName, |
218 const String& newValueStr) | 218 const String& newValueStr) |
219 { | 219 { |
220 v8::HandleScope handles(m_isolate); | 220 v8::HandleScope handles(m_isolate); |
221 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); | 221 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setVar iableValue"); |
222 if (callFrameIdOpt.isJust()) { | 222 if (callFrameIdOpt.isJust()) { |
223 function.appendArgument(callFrames); | 223 function.appendArgument(callFrames); |
224 function.appendArgument(callFrameIdOpt.fromJust()); | 224 function.appendArgument(callFrameIdOpt.fromJust()); |
225 } else { | 225 } else { |
226 function.appendArgument(false); | 226 function.appendArgument(false); |
227 function.appendArgument(false); | 227 function.appendArgument(false); |
228 } | 228 } |
229 if (functionObjectIdOpt.isJust()) | 229 if (functionObjectIdOpt.isJust()) |
230 function.appendArgument(functionObjectIdOpt.fromJust()); | 230 function.appendArgument(functionObjectIdOpt.fromJust()); |
231 else | 231 else |
232 function.appendArgument(false); | 232 function.appendArgument(false); |
233 function.appendArgument(scopeNumber); | 233 function.appendArgument(scopeNumber); |
234 function.appendArgument(variableName); | 234 function.appendArgument(variableName); |
235 function.appendArgument(newValueStr); | 235 function.appendArgument(newValueStr); |
236 OwnPtr<protocol::Value> resultValue = makeCall(function); | 236 OwnPtr<protocol::Value> resultValue = makeCall(function); |
237 if (!resultValue) { | 237 if (!resultValue) { |
238 *errorString = "Internal error"; | 238 *errorString = "Internal error"; |
239 return; | 239 return; |
240 } | 240 } |
241 if (resultValue->type() == protocol::Value::TypeString) { | 241 if (resultValue->type() == protocol::Value::TypeString) { |
242 resultValue->asString(errorString); | 242 resultValue->asString(errorString); |
243 return; | 243 return; |
244 } | 244 } |
245 // Normal return. | 245 // Normal return. |
246 } | 246 } |
247 | 247 |
248 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, OwnPtr<FunctionDetails>* result) | 248 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, OwnPtr<FunctionDetails>* result) |
249 { | 249 { |
250 v8::HandleScope handles(m_isolate); | 250 v8::HandleScope handles(m_isolate); |
251 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails" ); | 251 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFun ctionDetails"); |
252 function.appendArgument(functionId); | 252 function.appendArgument(functionId); |
253 OwnPtr<protocol::Value> resultValue = makeCall(function); | 253 OwnPtr<protocol::Value> resultValue = makeCall(function); |
254 protocol::ErrorSupport errors(errorString); | 254 protocol::ErrorSupport errors(errorString); |
255 *result = FunctionDetails::parse(resultValue.get(), &errors); | 255 *result = FunctionDetails::parse(resultValue.get(), &errors); |
256 } | 256 } |
257 | 257 |
258 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S tring& objectId, OwnPtr<GeneratorObjectDetails>* result) | 258 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S tring& objectId, OwnPtr<GeneratorObjectDetails>* result) |
259 { | 259 { |
260 v8::HandleScope handles(m_isolate); | 260 v8::HandleScope handles(m_isolate); |
261 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD etails"); | 261 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getGen eratorObjectDetails"); |
262 function.appendArgument(objectId); | 262 function.appendArgument(objectId); |
263 OwnPtr<protocol::Value> resultValue = makeCall(function); | 263 OwnPtr<protocol::Value> resultValue = makeCall(function); |
264 protocol::ErrorSupport errors(errorString); | 264 protocol::ErrorSupport errors(errorString); |
265 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); | 265 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); |
266 } | 266 } |
267 | 267 |
268 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String & objectId, OwnPtr<Array<CollectionEntry>>* result) | 268 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String & objectId, OwnPtr<Array<CollectionEntry>>* result) |
269 { | 269 { |
270 v8::HandleScope handles(m_isolate); | 270 v8::HandleScope handles(m_isolate); |
271 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie s"); | 271 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCol lectionEntries"); |
272 function.appendArgument(objectId); | 272 function.appendArgument(objectId); |
273 OwnPtr<protocol::Value> resultValue = makeCall(function); | 273 OwnPtr<protocol::Value> resultValue = makeCall(function); |
274 protocol::ErrorSupport errors(errorString); | 274 protocol::ErrorSupport errors(errorString); |
275 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); | 275 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); |
276 } | 276 } |
277 | 277 |
278 void InjectedScript::getProperties(ErrorString* errorString, const String& objec tId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnP tr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDet ails>* exceptionDetails) | 278 void InjectedScript::getProperties(ErrorString* errorString, const String& objec tId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnP tr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDet ails>* exceptionDetails) |
279 { | 279 { |
280 v8::HandleScope handles(m_isolate); | 280 v8::HandleScope handles(m_isolate); |
281 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); | 281 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro perties"); |
282 function.appendArgument(objectId); | 282 function.appendArgument(objectId); |
283 function.appendArgument(ownProperties); | 283 function.appendArgument(ownProperties); |
284 function.appendArgument(accessorPropertiesOnly); | 284 function.appendArgument(accessorPropertiesOnly); |
285 function.appendArgument(generatePreview); | 285 function.appendArgument(generatePreview); |
286 | 286 |
287 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); | 287 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); |
288 if (exceptionDetails->isJust()) { | 288 if (exceptionDetails->isJust()) { |
289 // FIXME: make properties optional | 289 // FIXME: make properties optional |
290 *properties = Array<PropertyDescriptor>::create(); | 290 *properties = Array<PropertyDescriptor>::create(); |
291 return; | 291 return; |
292 } | 292 } |
293 protocol::ErrorSupport errors(errorString); | 293 protocol::ErrorSupport errors(errorString); |
294 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); | 294 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); |
295 } | 295 } |
296 | 296 |
297 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protoco l::Runtime::ExceptionDetails>* exceptionDetails) | 297 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protoco l::Runtime::ExceptionDetails>* exceptionDetails) |
298 { | 298 { |
299 v8::HandleScope handles(m_isolate); | 299 v8::HandleScope handles(m_isolate); |
300 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti es"); | 300 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInt ernalProperties"); |
301 function.appendArgument(objectId); | 301 function.appendArgument(objectId); |
302 | 302 |
303 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); | 303 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); |
304 if (exceptionDetails->isJust()) | 304 if (exceptionDetails->isJust()) |
305 return; | 305 return; |
306 protocol::ErrorSupport errors(errorString); | 306 protocol::ErrorSupport errors(errorString); |
307 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors); | 307 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors); |
308 if (!errors.hasErrors() && array->length() > 0) | 308 if (!errors.hasErrors() && array->length() > 0) |
309 *properties = array.release(); | 309 *properties = array.release(); |
310 } | 310 } |
311 | 311 |
312 void InjectedScript::releaseObject(const String& objectId) | 312 void InjectedScript::releaseObject(const String& objectId) |
313 { | 313 { |
314 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); | 314 OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); |
315 if (!parsedObjectId) | 315 if (!parsedObjectId) |
316 return; | 316 return; |
317 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get()); | 317 protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedOb jectId.get()); |
318 if (!object) | 318 if (!object) |
319 return; | 319 return; |
320 int boundId = 0; | 320 int boundId = 0; |
321 if (!object->getNumber("id", &boundId)) | 321 if (!object->getNumber("id", &boundId)) |
322 return; | 322 return; |
323 m_native->unbind(boundId); | 323 m_native->unbind(boundId); |
324 } | 324 } |
325 | 325 |
326 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI) | 326 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI) |
327 { | 327 { |
328 // TODO(dgozman): get rid of this check. | |
329 if (!m_manager->debugger()->client()->isExecutionAllowed()) | |
pfeldman
2016/03/08 20:23:21
Can you do this within runCompiledScript?
dgozman
2016/03/09 22:01:53
Done.
| |
330 return v8::MaybeLocal<v8::Value>(); | |
331 | |
328 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate); | 332 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate); |
329 v8::Local<v8::Object> global = context()->Global(); | 333 v8::Local<v8::Object> global = context()->Global(); |
330 if (includeCommandLineAPI) { | 334 if (includeCommandLineAPI) { |
331 V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI" ); | 335 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "co mmandLineAPI"); |
332 bool hadException = false; | 336 bool hadException = false; |
333 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ; | 337 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ; |
334 if (!hadException) | 338 if (!hadException) |
335 global->Set(commandLineAPISymbolValue, commandLineAPI); | 339 global->Set(commandLineAPISymbolValue, commandLineAPI); |
336 } | 340 } |
337 | 341 |
338 v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context() , script); | 342 v8::MaybeLocal<v8::Value> maybeValue = m_manager->debugger()->runCompiledScr ipt(context(), script); |
339 if (includeCommandLineAPI) | 343 if (includeCommandLineAPI) |
340 global->Delete(context(), commandLineAPISymbolValue); | 344 global->Delete(context(), commandLineAPISymbolValue); |
341 | 345 |
342 return maybeValue; | 346 return maybeValue; |
343 } | 347 } |
344 | 348 |
345 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames) | 349 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames) |
346 { | 350 { |
347 v8::HandleScope handles(m_isolate); | 351 v8::HandleScope handles(m_isolate); |
348 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames"); | 352 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCa llFrames"); |
349 function.appendArgument(callFrames); | 353 function.appendArgument(callFrames); |
350 bool hadException = false; | 354 bool hadException = false; |
351 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); | 355 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); |
352 ASSERT(!hadException); | 356 ASSERT(!hadException); |
353 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ; | 357 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ; |
354 protocol::ErrorSupport errors; | 358 protocol::ErrorSupport errors; |
355 if (result && result->type() == protocol::Value::TypeArray) | 359 if (result && result->type() == protocol::Value::TypeArray) |
356 return Array<CallFrame>::parse(result.get(), &errors); | 360 return Array<CallFrame>::parse(result.get(), &errors); |
357 return Array<CallFrame>::create(); | 361 return Array<CallFrame>::create(); |
358 } | 362 } |
359 | 363 |
360 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String& groupName, bool generatePreview) const | 364 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String& groupName, bool generatePreview) const |
361 { | 365 { |
362 v8::HandleScope handles(m_isolate); | 366 v8::HandleScope handles(m_isolate); |
363 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); | 367 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject"); |
364 function.appendArgument(value); | 368 function.appendArgument(value); |
365 function.appendArgument(groupName); | 369 function.appendArgument(groupName); |
366 function.appendArgument(canAccessInspectedWindow()); | 370 function.appendArgument(canAccessInspectedWindow()); |
367 function.appendArgument(generatePreview); | 371 function.appendArgument(generatePreview); |
368 bool hadException = false; | 372 bool hadException = false; |
369 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ; | 373 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ; |
370 if (hadException) | 374 if (hadException) |
371 return nullptr; | 375 return nullptr; |
372 protocol::ErrorSupport errors; | 376 protocol::ErrorSupport errors; |
373 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); | 377 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); |
374 } | 378 } |
375 | 379 |
376 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const | 380 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const |
377 { | 381 { |
378 v8::HandleScope handles(m_isolate); | 382 v8::HandleScope handles(m_isolate); |
379 V8FunctionCall function(m_client, context(), v8Value(), "wrapTable"); | 383 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTa ble"); |
380 function.appendArgument(canAccessInspectedWindow()); | 384 function.appendArgument(canAccessInspectedWindow()); |
381 function.appendArgument(table); | 385 function.appendArgument(table); |
382 if (columns.IsEmpty()) | 386 if (columns.IsEmpty()) |
383 function.appendArgument(false); | 387 function.appendArgument(false); |
384 else | 388 else |
385 function.appendArgument(columns); | 389 function.appendArgument(columns); |
386 bool hadException = false; | 390 bool hadException = false; |
387 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException ); | 391 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException ); |
388 if (hadException) | 392 if (hadException) |
389 return nullptr; | 393 return nullptr; |
390 protocol::ErrorSupport errors; | 394 protocol::ErrorSupport errors; |
391 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); | 395 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); |
392 } | 396 } |
393 | 397 |
394 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const | 398 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const |
395 { | 399 { |
396 return m_native->objectForId(objectId.id()); | 400 return m_native->objectForId(objectId.id()); |
397 } | 401 } |
398 | 402 |
399 String InjectedScript::objectGroupName(const RemoteObjectId& objectId) const | 403 String InjectedScript::objectGroupName(const RemoteObjectId& objectId) const |
400 { | 404 { |
401 return m_native->groupName(objectId.id()); | 405 return m_native->groupName(objectId.id()); |
402 } | 406 } |
403 | 407 |
404 void InjectedScript::releaseObjectGroup(const String& objectGroup) | 408 void InjectedScript::releaseObjectGroup(const String& objectGroup) |
405 { | 409 { |
406 v8::HandleScope handles(m_isolate); | 410 v8::HandleScope handles(m_isolate); |
407 m_native->releaseObjectGroup(objectGroup); | 411 m_native->releaseObjectGroup(objectGroup); |
408 if (objectGroup == "console") { | 412 if (objectGroup == "console") { |
409 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua tionResult"); | 413 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "cl earLastEvaluationResult"); |
410 bool hadException = false; | 414 bool hadException = false; |
411 callFunctionWithEvalEnabled(function, hadException); | 415 callFunctionWithEvalEnabled(function, hadException); |
412 ASSERT(!hadException); | 416 ASSERT(!hadException); |
413 } | 417 } |
414 } | 418 } |
415 | 419 |
416 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) | 420 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) |
417 { | 421 { |
418 v8::HandleScope handles(m_isolate); | 422 v8::HandleScope handles(m_isolate); |
419 V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectForm atterEnabled"); | 423 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCus tomObjectFormatterEnabled"); |
420 function.appendArgument(enabled); | 424 function.appendArgument(enabled); |
421 makeCall(function); | 425 makeCall(function); |
422 } | 426 } |
423 | 427 |
424 bool InjectedScript::canAccessInspectedWindow() const | 428 bool InjectedScript::canAccessInspectedWindow() const |
425 { | 429 { |
426 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); | 430 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); |
427 if (callingContext.IsEmpty()) | 431 if (callingContext.IsEmpty()) |
428 return true; | 432 return true; |
429 return m_client->callingContextCanAccessContext(callingContext, context()); | 433 return m_manager->debugger()->client()->callingContextCanAccessContext(calli ngContext, context()); |
430 } | 434 } |
431 | 435 |
432 v8::Local<v8::Context> InjectedScript::context() const | 436 v8::Local<v8::Context> InjectedScript::context() const |
433 { | 437 { |
434 return m_context.Get(m_isolate); | 438 return m_context.Get(m_isolate); |
435 } | 439 } |
436 | 440 |
437 v8::Local<v8::Value> InjectedScript::v8Value() const | 441 v8::Local<v8::Value> InjectedScript::v8Value() const |
438 { | 442 { |
439 return m_value.Get(m_isolate); | 443 return m_value.Get(m_isolate); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 } | 530 } |
527 return result.release(); | 531 return result.release(); |
528 } | 532 } |
529 | 533 |
530 void InjectedScript::dispose() | 534 void InjectedScript::dispose() |
531 { | 535 { |
532 m_manager->discardInjectedScript(m_contextId); | 536 m_manager->discardInjectedScript(m_contextId); |
533 } | 537 } |
534 | 538 |
535 } // namespace blink | 539 } // namespace blink |
OLD | NEW |