| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 String16& callFrameId) | |
| 173 { | |
| 174 v8::HandleScope handles(m_isolate); | |
| 175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); | |
| 176 function.appendArgument(callFrames); | |
| 177 function.appendArgument(callFrameId); | |
| 178 OwnPtr<protocol::Value> resultValue = makeCall(function); | |
| 179 if (resultValue) { | |
| 180 if (resultValue->type() == protocol::Value::TypeString) { | |
| 181 resultValue->asString(errorString); | |
| 182 } else { | |
| 183 bool value; | |
| 184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); | |
| 185 } | |
| 186 return; | |
| 187 } | |
| 188 *errorString = "Internal error"; | |
| 189 } | |
| 190 | |
| 191 void InjectedScript::setVariableValue(ErrorString* errorString, | |
| 192 v8::Local<v8::Object> callFrames, | |
| 193 const protocol::Maybe<String16>& callFrameIdOpt, | |
| 194 const protocol::Maybe<String16>& functionObjectIdOpt, | |
| 195 int scopeNumber, | |
| 196 const String16& variableName, | |
| 197 const String16& newValueStr) | |
| 198 { | |
| 199 v8::HandleScope handles(m_isolate); | |
| 200 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue"); | |
| 201 if (callFrameIdOpt.isJust()) { | |
| 202 function.appendArgument(callFrames); | |
| 203 function.appendArgument(callFrameIdOpt.fromJust()); | |
| 204 } else { | |
| 205 function.appendArgument(false); | |
| 206 function.appendArgument(false); | |
| 207 } | |
| 208 if (functionObjectIdOpt.isJust()) | |
| 209 function.appendArgument(functionObjectIdOpt.fromJust()); | |
| 210 else | |
| 211 function.appendArgument(false); | |
| 212 function.appendArgument(scopeNumber); | |
| 213 function.appendArgument(variableName); | |
| 214 function.appendArgument(newValueStr); | |
| 215 OwnPtr<protocol::Value> resultValue = makeCall(function); | |
| 216 if (!resultValue) { | |
| 217 *errorString = "Internal error"; | |
| 218 return; | |
| 219 } | |
| 220 if (resultValue->type() == protocol::Value::TypeString) { | |
| 221 resultValue->asString(errorString); | |
| 222 return; | |
| 223 } | |
| 224 // Normal return. | |
| 225 } | |
| 226 | |
| 227 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16
& functionId, OwnPtr<FunctionDetails>* result) | 172 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16
& functionId, OwnPtr<FunctionDetails>* result) |
| 228 { | 173 { |
| 229 v8::HandleScope handles(m_isolate); | 174 v8::HandleScope handles(m_isolate); |
| 230 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); | 175 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"
); |
| 231 function.appendArgument(functionId); | 176 function.appendArgument(functionId); |
| 232 OwnPtr<protocol::Value> resultValue = makeCall(function); | 177 OwnPtr<protocol::Value> resultValue = makeCall(function); |
| 233 protocol::ErrorSupport errors(errorString); | 178 protocol::ErrorSupport errors(errorString); |
| 234 *result = FunctionDetails::parse(resultValue.get(), &errors); | 179 *result = FunctionDetails::parse(resultValue.get(), &errors); |
| 235 } | 180 } |
| 236 | 181 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 result = protocol::StringValue::create("Object has too long referenc
e chain"); | 469 result = protocol::StringValue::create("Object has too long referenc
e chain"); |
| 525 } | 470 } |
| 526 return result.release(); | 471 return result.release(); |
| 527 } | 472 } |
| 528 | 473 |
| 529 void InjectedScript::dispose() | 474 void InjectedScript::dispose() |
| 530 { | 475 { |
| 531 m_manager->discardInjectedScript(m_contextId); | 476 m_manager->discardInjectedScript(m_contextId); |
| 532 } | 477 } |
| 533 | 478 |
| 479 v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* error
String, protocol::Runtime::CallArgument* callArgument) |
| 480 { |
| 481 if (callArgument->hasObjectId()) { |
| 482 OwnPtr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(errorStrin
g, callArgument->getObjectId("")); |
| 483 if (!remoteObjectId) |
| 484 return v8::MaybeLocal<v8::Value>(); |
| 485 if (remoteObjectId->contextId() != m_contextId) { |
| 486 *errorString = "Argument should belong to the same JavaScript world
as target object"; |
| 487 return v8::MaybeLocal<v8::Value>(); |
| 488 } |
| 489 v8::Local<v8::Value> object = findObject(*remoteObjectId); |
| 490 if (object.IsEmpty()) { |
| 491 *errorString = "Could not find object with given id"; |
| 492 return v8::MaybeLocal<v8::Value>(); |
| 493 } |
| 494 return object; |
| 495 } |
| 496 if (callArgument->hasValue()) { |
| 497 String16 value = callArgument->getValue(nullptr)->toJSONString(); |
| 498 if (callArgument->getType(String16()) == "number") |
| 499 value = "Number(" + value + ")"; |
| 500 v8::Local<v8::Value> object; |
| 501 if (!m_client->compileAndRunInternalScript(toV8String(m_isolate, value))
.ToLocal(&object)) { |
| 502 *errorString = "Couldn't parse value object in call argument"; |
| 503 return v8::MaybeLocal<v8::Value>(); |
| 504 } |
| 505 return object; |
| 506 } |
| 507 return v8::Undefined(m_isolate); |
| 508 } |
| 509 |
| 534 } // namespace blink | 510 } // namespace blink |
| OLD | NEW |