| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 using WebCore::TypeBuilder::Array; | 41 using WebCore::TypeBuilder::Array; |
| 42 using WebCore::TypeBuilder::Debugger::CallFrame; | 42 using WebCore::TypeBuilder::Debugger::CallFrame; |
| 43 using WebCore::TypeBuilder::Runtime::PropertyDescriptor; | 43 using WebCore::TypeBuilder::Runtime::PropertyDescriptor; |
| 44 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; | 44 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; |
| 45 using WebCore::TypeBuilder::Debugger::FunctionDetails; | 45 using WebCore::TypeBuilder::Debugger::FunctionDetails; |
| 46 using WebCore::TypeBuilder::Runtime::RemoteObject; | 46 using WebCore::TypeBuilder::Runtime::RemoteObject; |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 InjectedScript::InjectedScript() | 50 V8InjectedScript::V8InjectedScript() |
| 51 : InjectedScriptBase("InjectedScript") | 51 : V8InjectedScriptBase("InjectedScript") |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 InjectedScript::InjectedScript(ScriptObject injectedScriptObject, InspectedState
AccessCheck accessCheck) | 55 V8InjectedScript::V8InjectedScript(ScriptObject injectedScriptObject, InspectedS
tateAccessCheck accessCheck) |
| 56 : InjectedScriptBase("InjectedScript", injectedScriptObject, accessCheck) | 56 : V8InjectedScriptBase("InjectedScript", injectedScriptObject, accessCheck) |
| 57 { | 57 { |
| 58 } | 58 } |
| 59 | 59 |
| 60 void InjectedScript::evaluate(ErrorString* errorString, const String& expression
, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, boo
l generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuild
er::OptOutput<bool>* wasThrown) | 60 void V8InjectedScript::evaluate(ErrorString* errorString, const String& expressi
on, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, b
ool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBui
lder::OptOutput<bool>* wasThrown) |
| 61 { | 61 { |
| 62 ScriptFunctionCall function(injectedScriptObject(), "evaluate"); | 62 ScriptFunctionCall function(injectedScriptObject(), "evaluate"); |
| 63 function.appendArgument(expression); | 63 function.appendArgument(expression); |
| 64 function.appendArgument(objectGroup); | 64 function.appendArgument(objectGroup); |
| 65 function.appendArgument(includeCommandLineAPI); | 65 function.appendArgument(includeCommandLineAPI); |
| 66 function.appendArgument(returnByValue); | 66 function.appendArgument(returnByValue); |
| 67 function.appendArgument(generatePreview); | 67 function.appendArgument(generatePreview); |
| 68 makeEvalCall(errorString, function, result, wasThrown); | 68 makeEvalCall(errorString, function, result, wasThrown); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje
ctId, const String& expression, const String& arguments, bool returnByValue, boo
l generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuild
er::OptOutput<bool>* wasThrown) | 71 void V8InjectedScript::callFunctionOn(ErrorString* errorString, const String& ob
jectId, const String& expression, const String& arguments, bool returnByValue, b
ool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBui
lder::OptOutput<bool>* wasThrown) |
| 72 { | 72 { |
| 73 ScriptFunctionCall function(injectedScriptObject(), "callFunctionOn"); | 73 ScriptFunctionCall function(injectedScriptObject(), "callFunctionOn"); |
| 74 function.appendArgument(objectId); | 74 function.appendArgument(objectId); |
| 75 function.appendArgument(expression); | 75 function.appendArgument(expression); |
| 76 function.appendArgument(arguments); | 76 function.appendArgument(arguments); |
| 77 function.appendArgument(returnByValue); | 77 function.appendArgument(returnByValue); |
| 78 function.appendArgument(generatePreview); | 78 function.appendArgument(generatePreview); |
| 79 makeEvalCall(errorString, function, result, wasThrown); | 79 makeEvalCall(errorString, function, result, wasThrown); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const ScriptV
alue& callFrames, const Vector<ScriptValue>& asyncCallStacks, const String& call
FrameId, const String& expression, const String& objectGroup, bool includeComman
dLineAPI, bool returnByValue, bool generatePreview, RefPtr<RemoteObject>* result
, TypeBuilder::OptOutput<bool>* wasThrown) | 82 void V8InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Stack
Trace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String& call
FrameId, const String& expression, const String& objectGroup, bool includeComman
dLineAPI, bool returnByValue, bool generatePreview, RefPtr<RemoteObject>* result
, TypeBuilder::OptOutput<bool>* wasThrown) |
| 83 { | 83 { |
| 84 ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"); | 84 ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"); |
| 85 function.appendArgument(callFrames); | 85 function.appendArgument(callFrames.asJavaScript()); |
| 86 function.appendArgument(asyncCallStacks); | 86 Vector<ScriptValue> asyncCallStacksJavaScript; |
| 87 for (size_t i = 0; i < asyncCallStacks.size(); i++) { |
| 88 if (asyncCallStacks[i].isJavaScript()) |
| 89 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); |
| 90 } |
| 91 function.appendArgument(asyncCallStacksJavaScript); |
| 87 function.appendArgument(callFrameId); | 92 function.appendArgument(callFrameId); |
| 88 function.appendArgument(expression); | 93 function.appendArgument(expression); |
| 89 function.appendArgument(objectGroup); | 94 function.appendArgument(objectGroup); |
| 90 function.appendArgument(includeCommandLineAPI); | 95 function.appendArgument(includeCommandLineAPI); |
| 91 function.appendArgument(returnByValue); | 96 function.appendArgument(returnByValue); |
| 92 function.appendArgument(generatePreview); | 97 function.appendArgument(generatePreview); |
| 93 makeEvalCall(errorString, function, result, wasThrown); | 98 makeEvalCall(errorString, function, result, wasThrown); |
| 94 } | 99 } |
| 95 | 100 |
| 96 void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& c
allFrames, const String& callFrameId, RefPtr<JSONObject>* result) | 101 void V8InjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, const
StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String
& callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* re
sult) |
| 102 { |
| 103 ScriptFunctionCall function(injectedScriptObject(), "getCompletionsOnCallFra
me"); |
| 104 function.appendArgument(callFrames.asJavaScript()); |
| 105 Vector<ScriptValue> asyncCallStacksJavaScript; |
| 106 for (size_t i = 0; i < asyncCallStacks.size(); i++) { |
| 107 if (asyncCallStacks[i].isJavaScript()) |
| 108 asyncCallStacksJavaScript.append(asyncCallStacks[i].asJavaScript()); |
| 109 } |
| 110 function.appendArgument(asyncCallStacksJavaScript); |
| 111 function.appendArgument(callFrameId); |
| 112 function.appendArgument(expression); |
| 113 RefPtr<JSONValue> resultValue; |
| 114 makeCall(function, &resultValue); |
| 115 if (!resultValue || resultValue->type() != JSONValue::TypeArray) { |
| 116 *errorString = "Internal error"; |
| 117 return; |
| 118 } |
| 119 *result = Array<String>::runtimeCast(resultValue); |
| 120 } |
| 121 |
| 122 void V8InjectedScript::restartFrame(ErrorString* errorString, const StackTrace&
callFrames, const String& callFrameId, RefPtr<JSONObject>* result) |
| 97 { | 123 { |
| 98 ScriptFunctionCall function(injectedScriptObject(), "restartFrame"); | 124 ScriptFunctionCall function(injectedScriptObject(), "restartFrame"); |
| 99 function.appendArgument(callFrames); | 125 function.appendArgument(callFrames.asJavaScript()); |
| 100 function.appendArgument(callFrameId); | 126 function.appendArgument(callFrameId); |
| 101 RefPtr<JSONValue> resultValue; | 127 RefPtr<JSONValue> resultValue; |
| 102 makeCall(function, &resultValue); | 128 makeCall(function, &resultValue); |
| 103 if (resultValue) { | 129 if (resultValue) { |
| 104 if (resultValue->type() == JSONValue::TypeString) { | 130 if (resultValue->type() == JSONValue::TypeString) { |
| 105 resultValue->asString(errorString); | 131 resultValue->asString(errorString); |
| 106 return; | 132 return; |
| 107 } | 133 } |
| 108 if (resultValue->type() == JSONValue::TypeObject) { | 134 if (resultValue->type() == JSONValue::TypeObject) { |
| 109 *result = resultValue->asObject(); | 135 *result = resultValue->asObject(); |
| 110 return; | 136 return; |
| 111 } | 137 } |
| 112 } | 138 } |
| 113 *errorString = "Internal error"; | 139 *errorString = "Internal error"; |
| 114 } | 140 } |
| 115 | 141 |
| 116 void InjectedScript::getStepInPositions(ErrorString* errorString, const ScriptVa
lue& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::
Location> >& positions) | 142 void V8InjectedScript::getStepInPositions(ErrorString* errorString, const StackT
race& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger:
:Location> >& positions) |
| 117 { | 143 { |
| 118 ScriptFunctionCall function(injectedScriptObject(), "getStepInPositions"); | 144 ScriptFunctionCall function(injectedScriptObject(), "getStepInPositions"); |
| 119 function.appendArgument(callFrames); | 145 function.appendArgument(callFrames.asJavaScript()); |
| 120 function.appendArgument(callFrameId); | 146 function.appendArgument(callFrameId); |
| 121 RefPtr<JSONValue> resultValue; | 147 RefPtr<JSONValue> resultValue; |
| 122 makeCall(function, &resultValue); | 148 makeCall(function, &resultValue); |
| 123 if (resultValue) { | 149 if (resultValue) { |
| 124 if (resultValue->type() == JSONValue::TypeString) { | 150 if (resultValue->type() == JSONValue::TypeString) { |
| 125 resultValue->asString(errorString); | 151 resultValue->asString(errorString); |
| 126 return; | 152 return; |
| 127 } | 153 } |
| 128 if (resultValue->type() == JSONValue::TypeArray) { | 154 if (resultValue->type() == JSONValue::TypeArray) { |
| 129 positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resu
ltValue); | 155 positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resu
ltValue); |
| 130 return; | 156 return; |
| 131 } | 157 } |
| 132 } | 158 } |
| 133 *errorString = "Internal error"; | 159 *errorString = "Internal error"; |
| 134 } | 160 } |
| 135 | 161 |
| 136 void InjectedScript::setVariableValue(ErrorString* errorString, const ScriptValu
e& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt,
int scopeNumber, const String& variableName, const String& newValueStr) | 162 void V8InjectedScript::setVariableValue(ErrorString* errorString, const StackTra
ce& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt,
int scopeNumber, const String& variableName, const String& newValueStr) |
| 137 { | 163 { |
| 138 ScriptFunctionCall function(injectedScriptObject(), "setVariableValue"); | 164 ScriptFunctionCall function(injectedScriptObject(), "setVariableValue"); |
| 139 if (callFrameIdOpt) { | 165 if (callFrameIdOpt) { |
| 140 function.appendArgument(callFrames); | 166 function.appendArgument(callFrames.asJavaScript()); |
| 141 function.appendArgument(*callFrameIdOpt); | 167 function.appendArgument(*callFrameIdOpt); |
| 142 } else { | 168 } else { |
| 143 function.appendArgument(false); | 169 function.appendArgument(false); |
| 144 function.appendArgument(false); | 170 function.appendArgument(false); |
| 145 } | 171 } |
| 146 if (functionObjectIdOpt) | 172 if (functionObjectIdOpt) |
| 147 function.appendArgument(*functionObjectIdOpt); | 173 function.appendArgument(*functionObjectIdOpt); |
| 148 else | 174 else |
| 149 function.appendArgument(false); | 175 function.appendArgument(false); |
| 150 function.appendArgument(scopeNumber); | 176 function.appendArgument(scopeNumber); |
| 151 function.appendArgument(variableName); | 177 function.appendArgument(variableName); |
| 152 function.appendArgument(newValueStr); | 178 function.appendArgument(newValueStr); |
| 153 RefPtr<JSONValue> resultValue; | 179 RefPtr<JSONValue> resultValue; |
| 154 makeCall(function, &resultValue); | 180 makeCall(function, &resultValue); |
| 155 if (!resultValue) { | 181 if (!resultValue) { |
| 156 *errorString = "Internal error"; | 182 *errorString = "Internal error"; |
| 157 return; | 183 return; |
| 158 } | 184 } |
| 159 if (resultValue->type() == JSONValue::TypeString) { | 185 if (resultValue->type() == JSONValue::TypeString) { |
| 160 resultValue->asString(errorString); | 186 resultValue->asString(errorString); |
| 161 return; | 187 return; |
| 162 } | 188 } |
| 163 // Normal return. | 189 // Normal return. |
| 164 } | 190 } |
| 165 | 191 |
| 166 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String&
functionId, RefPtr<FunctionDetails>* result) | 192 void V8InjectedScript::getFunctionDetails(ErrorString* errorString, const String
& functionId, RefPtr<FunctionDetails>* result) |
| 167 { | 193 { |
| 168 ScriptFunctionCall function(injectedScriptObject(), "getFunctionDetails"); | 194 ScriptFunctionCall function(injectedScriptObject(), "getFunctionDetails"); |
| 169 function.appendArgument(functionId); | 195 function.appendArgument(functionId); |
| 170 RefPtr<JSONValue> resultValue; | 196 RefPtr<JSONValue> resultValue; |
| 171 makeCall(function, &resultValue); | 197 makeCall(function, &resultValue); |
| 172 if (!resultValue || resultValue->type() != JSONValue::TypeObject) { | 198 if (!resultValue || resultValue->type() != JSONValue::TypeObject) { |
| 173 if (!resultValue->asString(errorString)) | 199 if (!resultValue->asString(errorString)) |
| 174 *errorString = "Internal error"; | 200 *errorString = "Internal error"; |
| 175 return; | 201 return; |
| 176 } | 202 } |
| 177 *result = FunctionDetails::runtimeCast(resultValue); | 203 *result = FunctionDetails::runtimeCast(resultValue); |
| 178 } | 204 } |
| 179 | 205 |
| 180 void InjectedScript::getProperties(ErrorString* errorString, const String& objec
tId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<Array<PropertyDescr
iptor> >* properties) | 206 void V8InjectedScript::getCompletions(ErrorString* errorString, const String& ex
pression, RefPtr<TypeBuilder::Array<String> >* result) |
| 207 { |
| 208 *result = TypeBuilder::Array<String>::create(); |
| 209 ScriptFunctionCall function(injectedScriptObject(), "getCompletions"); |
| 210 function.appendArgument(expression); |
| 211 RefPtr<JSONValue> resultValue; |
| 212 makeCall(function, &resultValue); |
| 213 if (!resultValue || resultValue->type() != JSONValue::TypeArray) { |
| 214 *errorString = "Internal error"; |
| 215 return; |
| 216 } |
| 217 *result = Array<String>::runtimeCast(resultValue); |
| 218 } |
| 219 |
| 220 void V8InjectedScript::getProperties(ErrorString* errorString, const String& obj
ectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<Array<PropertyDes
criptor> >* properties) |
| 181 { | 221 { |
| 182 ScriptFunctionCall function(injectedScriptObject(), "getProperties"); | 222 ScriptFunctionCall function(injectedScriptObject(), "getProperties"); |
| 183 function.appendArgument(objectId); | 223 function.appendArgument(objectId); |
| 184 function.appendArgument(ownProperties); | 224 function.appendArgument(ownProperties); |
| 185 function.appendArgument(accessorPropertiesOnly); | 225 function.appendArgument(accessorPropertiesOnly); |
| 186 | 226 |
| 187 RefPtr<JSONValue> result; | 227 RefPtr<JSONValue> result; |
| 188 makeCall(function, &result); | 228 makeCall(function, &result); |
| 189 if (!result || result->type() != JSONValue::TypeArray) { | 229 if (!result || result->type() != JSONValue::TypeArray) { |
| 190 *errorString = "Internal error"; | 230 *errorString = "Internal error"; |
| 191 return; | 231 return; |
| 192 } | 232 } |
| 193 *properties = Array<PropertyDescriptor>::runtimeCast(result); | 233 *properties = Array<PropertyDescriptor>::runtimeCast(result); |
| 194 } | 234 } |
| 195 | 235 |
| 196 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) | 236 void V8InjectedScript::getInternalProperties(ErrorString* errorString, const Str
ing& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) |
| 197 { | 237 { |
| 198 ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties")
; | 238 ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties")
; |
| 199 function.appendArgument(objectId); | 239 function.appendArgument(objectId); |
| 200 | 240 |
| 201 RefPtr<JSONValue> result; | 241 RefPtr<JSONValue> result; |
| 202 makeCall(function, &result); | 242 makeCall(function, &result); |
| 203 if (!result || result->type() != JSONValue::TypeArray) { | 243 if (!result || result->type() != JSONValue::TypeArray) { |
| 204 *errorString = "Internal error"; | 244 *errorString = "Internal error"; |
| 205 return; | 245 return; |
| 206 } | 246 } |
| 207 RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDes
criptor>::runtimeCast(result); | 247 RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDes
criptor>::runtimeCast(result); |
| 208 if (array->length() > 0) | 248 if (array->length() > 0) |
| 209 *properties = array; | 249 *properties = array; |
| 210 } | 250 } |
| 211 | 251 |
| 212 Node* InjectedScript::nodeForObjectId(const String& objectId) | 252 void V8InjectedScript::getProperty(ErrorString* errorString, const String& objec
tId, const RefPtr<JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime::RemoteO
bject>* result, TypeBuilder::OptOutput<bool>* wasThrown) |
| 253 { |
| 254 ScriptFunctionCall function(injectedScriptObject(), "getProperty"); |
| 255 function.appendArgument(objectId); |
| 256 function.appendArgument(propertyPath); |
| 257 makeEvalCall(errorString, function, result, wasThrown); |
| 258 } |
| 259 |
| 260 Node* V8InjectedScript::nodeForObjectId(const String& objectId) |
| 213 { | 261 { |
| 214 if (isEmpty() || !canAccessInspectedWindow()) | 262 if (isEmpty() || !canAccessInspectedWindow()) |
| 215 return 0; | 263 return 0; |
| 216 | 264 |
| 217 ScriptFunctionCall function(injectedScriptObject(), "nodeForObjectId"); | 265 ScriptFunctionCall function(injectedScriptObject(), "nodeForObjectId"); |
| 218 function.appendArgument(objectId); | 266 function.appendArgument(objectId); |
| 219 | 267 |
| 220 bool hadException = false; | 268 bool hadException = false; |
| 221 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 269 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 222 ASSERT(!hadException); | 270 ASSERT(!hadException); |
| 223 | 271 |
| 224 return InjectedScriptHost::scriptValueAsNode(resultValue); | 272 return InjectedScriptHost::scriptValueAsNode(resultValue); |
| 225 } | 273 } |
| 226 | 274 |
| 227 void InjectedScript::releaseObject(const String& objectId) | 275 void V8InjectedScript::releaseObject(const String& objectId) |
| 228 { | 276 { |
| 229 ScriptFunctionCall function(injectedScriptObject(), "releaseObject"); | 277 ScriptFunctionCall function(injectedScriptObject(), "releaseObject"); |
| 230 function.appendArgument(objectId); | 278 function.appendArgument(objectId); |
| 231 RefPtr<JSONValue> result; | 279 RefPtr<JSONValue> result; |
| 232 makeCall(function, &result); | 280 makeCall(function, &result); |
| 233 } | 281 } |
| 234 | 282 |
| 235 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue&
callFrames, int asyncOrdinal) | 283 PassRefPtr<Array<CallFrame> > V8InjectedScript::wrapCallFrames(const StackTrace&
callFrames, int asyncOrdinal) |
| 236 { | 284 { |
| 237 ASSERT(!isEmpty()); | 285 ASSERT(!isEmpty()); |
| 238 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); | 286 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); |
| 239 function.appendArgument(callFrames); | 287 function.appendArgument(callFrames.asJavaScript()); |
| 240 function.appendArgument(asyncOrdinal); | 288 function.appendArgument(asyncOrdinal); |
| 241 bool hadException = false; | 289 bool hadException = false; |
| 242 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep
tion); | 290 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep
tion); |
| 243 ASSERT(!hadException); | 291 ASSERT(!hadException); |
| 244 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); | 292 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); |
| 245 if (result->type() == JSONValue::TypeArray) | 293 if (result->type() == JSONValue::TypeArray) |
| 246 return Array<CallFrame>::runtimeCast(result); | 294 return Array<CallFrame>::runtimeCast(result); |
| 247 return Array<CallFrame>::create(); | 295 return Array<CallFrame>::create(); |
| 248 } | 296 } |
| 249 | 297 |
| 250 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const | 298 PassRefPtr<TypeBuilder::Runtime::RemoteObject> V8InjectedScript::wrapObject(cons
t ScriptValue& value, const String& groupName, bool generatePreview) |
| 251 { | 299 { |
| 252 ASSERT(!isEmpty()); | 300 ASSERT(!isEmpty()); |
| 253 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); | 301 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); |
| 254 wrapFunction.appendArgument(value); | 302 wrapFunction.appendArgument(value); |
| 255 wrapFunction.appendArgument(groupName); | 303 wrapFunction.appendArgument(groupName); |
| 256 wrapFunction.appendArgument(canAccessInspectedWindow()); | 304 wrapFunction.appendArgument(canAccessInspectedWindow()); |
| 257 wrapFunction.appendArgument(generatePreview); | 305 wrapFunction.appendArgument(generatePreview); |
| 258 bool hadException = false; | 306 bool hadException = false; |
| 259 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 307 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
| 260 if (hadException) | 308 if (hadException) |
| 261 return nullptr; | 309 return nullptr; |
| 262 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 310 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); |
| 263 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 311 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 264 } | 312 } |
| 265 | 313 |
| 266 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S
criptValue& table, const ScriptValue& columns) const | 314 PassRefPtr<TypeBuilder::Runtime::RemoteObject> V8InjectedScript::wrapTable(const
ScriptValue& table, const ScriptValue& columns) |
| 267 { | 315 { |
| 268 ASSERT(!isEmpty()); | 316 ASSERT(!isEmpty()); |
| 269 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); | 317 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); |
| 270 wrapFunction.appendArgument(canAccessInspectedWindow()); | 318 wrapFunction.appendArgument(canAccessInspectedWindow()); |
| 271 wrapFunction.appendArgument(table); | 319 wrapFunction.appendArgument(table); |
| 272 if (columns.isEmpty()) | 320 if (columns.isEmpty()) |
| 273 wrapFunction.appendArgument(false); | 321 wrapFunction.appendArgument(false); |
| 274 else | 322 else |
| 275 wrapFunction.appendArgument(columns); | 323 wrapFunction.appendArgument(columns); |
| 276 bool hadException = false; | 324 bool hadException = false; |
| 277 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 325 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
| 278 if (hadException) | 326 if (hadException) |
| 279 return nullptr; | 327 return nullptr; |
| 280 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 328 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); |
| 281 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 329 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 282 } | 330 } |
| 283 | 331 |
| 284 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no
de, const String& groupName) | 332 PassRefPtr<TypeBuilder::Runtime::RemoteObject> V8InjectedScript::wrapNode(Node*
node, const String& groupName) |
| 285 { | 333 { |
| 286 return wrapObject(nodeAsScriptValue(node), groupName); | 334 return wrapObject(nodeAsScriptValue(node), groupName); |
| 287 } | 335 } |
| 288 | 336 |
| 289 ScriptValue InjectedScript::findObjectById(const String& objectId) const | 337 ScriptValue V8InjectedScript::findObjectById(const String& objectId) const |
| 290 { | 338 { |
| 291 ASSERT(!isEmpty()); | 339 ASSERT(!isEmpty()); |
| 292 ScriptFunctionCall function(injectedScriptObject(), "findObjectById"); | 340 ScriptFunctionCall function(injectedScriptObject(), "findObjectById"); |
| 293 function.appendArgument(objectId); | 341 function.appendArgument(objectId); |
| 294 | 342 |
| 295 bool hadException = false; | 343 bool hadException = false; |
| 296 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 344 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 297 ASSERT(!hadException); | 345 ASSERT(!hadException); |
| 298 return resultValue; | 346 return resultValue; |
| 299 } | 347 } |
| 300 | 348 |
| 301 ScriptValue InjectedScript::findCallFrameById(ErrorString* errorString, const Sc
riptValue& topCallFrame, const String& callFrameId) | 349 ActivationFrame V8InjectedScript::findCallFrameById(ErrorString* errorString, co
nst StackTrace& topCallFrame, const String& callFrameId) |
| 302 { | 350 { |
| 351 ASSERT(topCallFrame.isJavaScript()); |
| 303 ScriptFunctionCall function(injectedScriptObject(), "callFrameForId"); | 352 ScriptFunctionCall function(injectedScriptObject(), "callFrameForId"); |
| 304 function.appendArgument(topCallFrame); | 353 function.appendArgument(topCallFrame.asJavaScript()); |
| 305 function.appendArgument(callFrameId); | 354 function.appendArgument(callFrameId); |
| 306 bool hadException = false; | 355 bool hadException = false; |
| 307 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 356 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 308 ASSERT(!hadException); | 357 ASSERT(!hadException); |
| 309 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { | 358 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { |
| 310 *errorString = "Internal error"; | 359 *errorString = "Internal error"; |
| 311 return ScriptValue(); | 360 return ActivationFrame(); |
| 312 } | 361 } |
| 313 return resultValue; | 362 return ActivationFrame(resultValue); |
| 314 } | 363 } |
| 315 | 364 |
| 316 void InjectedScript::inspectNode(Node* node) | 365 void V8InjectedScript::inspectNode(Node* node) |
| 317 { | 366 { |
| 318 ASSERT(!isEmpty()); | 367 ASSERT(!isEmpty()); |
| 319 ScriptFunctionCall function(injectedScriptObject(), "inspectNode"); | 368 ScriptFunctionCall function(injectedScriptObject(), "inspectNode"); |
| 320 function.appendArgument(nodeAsScriptValue(node)); | 369 function.appendArgument(nodeAsScriptValue(node)); |
| 321 RefPtr<JSONValue> result; | 370 RefPtr<JSONValue> result; |
| 322 makeCall(function, &result); | 371 makeCall(function, &result); |
| 323 } | 372 } |
| 324 | 373 |
| 325 void InjectedScript::releaseObjectGroup(const String& objectGroup) | 374 void V8InjectedScript::releaseObjectGroup(const String& objectGroup) |
| 326 { | 375 { |
| 327 ASSERT(!isEmpty()); | 376 ASSERT(!isEmpty()); |
| 328 ScriptFunctionCall releaseFunction(injectedScriptObject(), "releaseObjectGro
up"); | 377 ScriptFunctionCall releaseFunction(injectedScriptObject(), "releaseObjectGro
up"); |
| 329 releaseFunction.appendArgument(objectGroup); | 378 releaseFunction.appendArgument(objectGroup); |
| 330 bool hadException = false; | 379 bool hadException = false; |
| 331 callFunctionWithEvalEnabled(releaseFunction, hadException); | 380 callFunctionWithEvalEnabled(releaseFunction, hadException); |
| 332 ASSERT(!hadException); | 381 ASSERT(!hadException); |
| 333 } | 382 } |
| 334 | 383 |
| 335 ScriptValue InjectedScript::nodeAsScriptValue(Node* node) | 384 ScriptValue V8InjectedScript::nodeAsScriptValue(Node* node) |
| 336 { | 385 { |
| 337 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); | 386 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); |
| 338 } | 387 } |
| 339 | 388 |
| 340 } // namespace WebCore | 389 } // namespace WebCore |
| 341 | 390 |
| OLD | NEW |