Chromium Code Reviews| 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_manager->debugger(), context(), v8Value(), "restar tFrame"); | |
| 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_manager->debugger(), context(), v8Value(), "setVar iableValue"); | |
| 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_manager->debugger(), context(), v8Value(), "getFun ctionDetails"); | 175 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFun ctionDetails"); |
| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 result = protocol::StringValue::create("Object has too long referenc e chain(must not be longer than " + String16::number(protocol::Value::maxDepth) + ")"); | 449 result = protocol::StringValue::create("Object has too long referenc e chain(must not be longer than " + String16::number(protocol::Value::maxDepth) + ")"); |
| 505 } | 450 } |
| 506 return result.release(); | 451 return result.release(); |
| 507 } | 452 } |
| 508 | 453 |
| 509 void InjectedScript::dispose() | 454 void InjectedScript::dispose() |
| 510 { | 455 { |
| 511 m_manager->discardInjectedScript(m_contextId); | 456 m_manager->discardInjectedScript(m_contextId); |
| 512 } | 457 } |
| 513 | 458 |
| 459 v8::MaybeLocal<v8::Value> InjectedScript::resolveCallArgument(ErrorString* error String, protocol::Runtime::CallArgument* callArgument) | |
| 460 { | |
| 461 if (callArgument->hasObjectId()) { | |
| 462 OwnPtr<RemoteObjectId> remoteObjectId = RemoteObjectId::parse(callArgume nt->getObjectId("")); | |
| 463 if (!remoteObjectId) { | |
| 464 *errorString = "Invalid object id in call argument"; | |
| 465 return v8::MaybeLocal<v8::Value>(); | |
| 466 } | |
| 467 if (remoteObjectId->contextId() != m_contextId) { | |
| 468 *errorString = "Argument should belong to the same JavaScript world as target object"; | |
| 469 return v8::MaybeLocal<v8::Value>(); | |
| 470 } | |
| 471 v8::Local<v8::Value> object = findObject(*remoteObjectId); | |
| 472 if (object.IsEmpty()) { | |
| 473 *errorString = "Could not find object with given id"; | |
| 474 return v8::MaybeLocal<v8::Value>(); | |
| 475 } | |
| 476 return object; | |
| 477 } | |
| 478 if (callArgument->hasValue()) { | |
| 479 String16 value = callArgument->getValue(nullptr)->toJSONString(); | |
| 480 if (callArgument->getType(String16()) == "number") | |
| 481 value = "Number(" + value + ")"; | |
|
pfeldman
2016/03/15 19:12:22
What is this for?
kozy
2016/03/16 02:15:15
It repeats InjectedScriptSource.js behavior for -I
| |
| 482 v8::Local<v8::Value> object; | |
| 483 if (!m_manager->debugger()->compileAndRunInternalScript(context(), toV8S tring(m_isolate, value)).ToLocal(&object)) { | |
| 484 *errorString = "Couldn't parse value object in call argument"; | |
| 485 return v8::MaybeLocal<v8::Value>(); | |
| 486 } | |
| 487 return object; | |
| 488 } | |
| 489 return v8::Undefined(m_isolate); | |
| 490 } | |
| 491 | |
| 514 } // namespace blink | 492 } // namespace blink |
| OLD | NEW |