| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 InjectedScript::InjectedScript() |
| 51 : InjectedScriptBase("InjectedScript") | 51 : InjectedScriptBase("InjectedScript") |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 InjectedScript::InjectedScript(ScriptObject injectedScriptObject, InspectedState
AccessCheck accessCheck) | 55 InjectedScript::InjectedScript(ScriptValue injectedScriptValue, InspectedStateAc
cessCheck accessCheck) |
| 56 : InjectedScriptBase("InjectedScript", injectedScriptObject, accessCheck) | 56 : InjectedScriptBase("InjectedScript", injectedScriptValue, 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 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) |
| 61 { | 61 { |
| 62 ScriptFunctionCall function(injectedScriptObject(), "evaluate"); | 62 ScriptFunctionCall function(injectedScriptValue(), "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 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) |
| 72 { | 72 { |
| 73 ScriptFunctionCall function(injectedScriptObject(), "callFunctionOn"); | 73 ScriptFunctionCall function(injectedScriptValue(), "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 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) |
| 83 { | 83 { |
| 84 ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"); | 84 ScriptFunctionCall function(injectedScriptValue(), "evaluateOnCallFrame"); |
| 85 function.appendArgument(callFrames); | 85 function.appendArgument(callFrames); |
| 86 function.appendArgument(asyncCallStacks); | 86 function.appendArgument(asyncCallStacks); |
| 87 function.appendArgument(callFrameId); | 87 function.appendArgument(callFrameId); |
| 88 function.appendArgument(expression); | 88 function.appendArgument(expression); |
| 89 function.appendArgument(objectGroup); | 89 function.appendArgument(objectGroup); |
| 90 function.appendArgument(includeCommandLineAPI); | 90 function.appendArgument(includeCommandLineAPI); |
| 91 function.appendArgument(returnByValue); | 91 function.appendArgument(returnByValue); |
| 92 function.appendArgument(generatePreview); | 92 function.appendArgument(generatePreview); |
| 93 makeEvalCall(errorString, function, result, wasThrown); | 93 makeEvalCall(errorString, function, result, wasThrown); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& c
allFrames, const String& callFrameId, RefPtr<JSONObject>* result) | 96 void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& c
allFrames, const String& callFrameId, RefPtr<JSONObject>* result) |
| 97 { | 97 { |
| 98 ScriptFunctionCall function(injectedScriptObject(), "restartFrame"); | 98 ScriptFunctionCall function(injectedScriptValue(), "restartFrame"); |
| 99 function.appendArgument(callFrames); | 99 function.appendArgument(callFrames); |
| 100 function.appendArgument(callFrameId); | 100 function.appendArgument(callFrameId); |
| 101 RefPtr<JSONValue> resultValue; | 101 RefPtr<JSONValue> resultValue; |
| 102 makeCall(function, &resultValue); | 102 makeCall(function, &resultValue); |
| 103 if (resultValue) { | 103 if (resultValue) { |
| 104 if (resultValue->type() == JSONValue::TypeString) { | 104 if (resultValue->type() == JSONValue::TypeString) { |
| 105 resultValue->asString(errorString); | 105 resultValue->asString(errorString); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 if (resultValue->type() == JSONValue::TypeObject) { | 108 if (resultValue->type() == JSONValue::TypeObject) { |
| 109 *result = resultValue->asObject(); | 109 *result = resultValue->asObject(); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 *errorString = "Internal error"; | 113 *errorString = "Internal error"; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void InjectedScript::getStepInPositions(ErrorString* errorString, const ScriptVa
lue& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::
Location> >& positions) | 116 void InjectedScript::getStepInPositions(ErrorString* errorString, const ScriptVa
lue& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::
Location> >& positions) |
| 117 { | 117 { |
| 118 ScriptFunctionCall function(injectedScriptObject(), "getStepInPositions"); | 118 ScriptFunctionCall function(injectedScriptValue(), "getStepInPositions"); |
| 119 function.appendArgument(callFrames); | 119 function.appendArgument(callFrames); |
| 120 function.appendArgument(callFrameId); | 120 function.appendArgument(callFrameId); |
| 121 RefPtr<JSONValue> resultValue; | 121 RefPtr<JSONValue> resultValue; |
| 122 makeCall(function, &resultValue); | 122 makeCall(function, &resultValue); |
| 123 if (resultValue) { | 123 if (resultValue) { |
| 124 if (resultValue->type() == JSONValue::TypeString) { | 124 if (resultValue->type() == JSONValue::TypeString) { |
| 125 resultValue->asString(errorString); | 125 resultValue->asString(errorString); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 if (resultValue->type() == JSONValue::TypeArray) { | 128 if (resultValue->type() == JSONValue::TypeArray) { |
| 129 positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resu
ltValue); | 129 positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resu
ltValue); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 *errorString = "Internal error"; | 133 *errorString = "Internal error"; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void InjectedScript::setVariableValue(ErrorString* errorString, const ScriptValu
e& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt,
int scopeNumber, const String& variableName, const String& newValueStr) | 136 void InjectedScript::setVariableValue(ErrorString* errorString, const ScriptValu
e& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt,
int scopeNumber, const String& variableName, const String& newValueStr) |
| 137 { | 137 { |
| 138 ScriptFunctionCall function(injectedScriptObject(), "setVariableValue"); | 138 ScriptFunctionCall function(injectedScriptValue(), "setVariableValue"); |
| 139 if (callFrameIdOpt) { | 139 if (callFrameIdOpt) { |
| 140 function.appendArgument(callFrames); | 140 function.appendArgument(callFrames); |
| 141 function.appendArgument(*callFrameIdOpt); | 141 function.appendArgument(*callFrameIdOpt); |
| 142 } else { | 142 } else { |
| 143 function.appendArgument(false); | 143 function.appendArgument(false); |
| 144 function.appendArgument(false); | 144 function.appendArgument(false); |
| 145 } | 145 } |
| 146 if (functionObjectIdOpt) | 146 if (functionObjectIdOpt) |
| 147 function.appendArgument(*functionObjectIdOpt); | 147 function.appendArgument(*functionObjectIdOpt); |
| 148 else | 148 else |
| 149 function.appendArgument(false); | 149 function.appendArgument(false); |
| 150 function.appendArgument(scopeNumber); | 150 function.appendArgument(scopeNumber); |
| 151 function.appendArgument(variableName); | 151 function.appendArgument(variableName); |
| 152 function.appendArgument(newValueStr); | 152 function.appendArgument(newValueStr); |
| 153 RefPtr<JSONValue> resultValue; | 153 RefPtr<JSONValue> resultValue; |
| 154 makeCall(function, &resultValue); | 154 makeCall(function, &resultValue); |
| 155 if (!resultValue) { | 155 if (!resultValue) { |
| 156 *errorString = "Internal error"; | 156 *errorString = "Internal error"; |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 if (resultValue->type() == JSONValue::TypeString) { | 159 if (resultValue->type() == JSONValue::TypeString) { |
| 160 resultValue->asString(errorString); | 160 resultValue->asString(errorString); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 // Normal return. | 163 // Normal return. |
| 164 } | 164 } |
| 165 | 165 |
| 166 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String&
functionId, RefPtr<FunctionDetails>* result) | 166 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String&
functionId, RefPtr<FunctionDetails>* result) |
| 167 { | 167 { |
| 168 ScriptFunctionCall function(injectedScriptObject(), "getFunctionDetails"); | 168 ScriptFunctionCall function(injectedScriptValue(), "getFunctionDetails"); |
| 169 function.appendArgument(functionId); | 169 function.appendArgument(functionId); |
| 170 RefPtr<JSONValue> resultValue; | 170 RefPtr<JSONValue> resultValue; |
| 171 makeCall(function, &resultValue); | 171 makeCall(function, &resultValue); |
| 172 if (!resultValue || resultValue->type() != JSONValue::TypeObject) { | 172 if (!resultValue || resultValue->type() != JSONValue::TypeObject) { |
| 173 if (!resultValue->asString(errorString)) | 173 if (!resultValue->asString(errorString)) |
| 174 *errorString = "Internal error"; | 174 *errorString = "Internal error"; |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 *result = FunctionDetails::runtimeCast(resultValue); | 177 *result = FunctionDetails::runtimeCast(resultValue); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void InjectedScript::getProperties(ErrorString* errorString, const String& objec
tId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<Array<PropertyDescr
iptor> >* properties) | 180 void InjectedScript::getProperties(ErrorString* errorString, const String& objec
tId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<Array<PropertyDescr
iptor> >* properties) |
| 181 { | 181 { |
| 182 ScriptFunctionCall function(injectedScriptObject(), "getProperties"); | 182 ScriptFunctionCall function(injectedScriptValue(), "getProperties"); |
| 183 function.appendArgument(objectId); | 183 function.appendArgument(objectId); |
| 184 function.appendArgument(ownProperties); | 184 function.appendArgument(ownProperties); |
| 185 function.appendArgument(accessorPropertiesOnly); | 185 function.appendArgument(accessorPropertiesOnly); |
| 186 | 186 |
| 187 RefPtr<JSONValue> result; | 187 RefPtr<JSONValue> result; |
| 188 makeCall(function, &result); | 188 makeCall(function, &result); |
| 189 if (!result || result->type() != JSONValue::TypeArray) { | 189 if (!result || result->type() != JSONValue::TypeArray) { |
| 190 *errorString = "Internal error"; | 190 *errorString = "Internal error"; |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 *properties = Array<PropertyDescriptor>::runtimeCast(result); | 193 *properties = Array<PropertyDescriptor>::runtimeCast(result); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) | 196 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin
g& objectId, RefPtr<Array<InternalPropertyDescriptor> >* properties) |
| 197 { | 197 { |
| 198 ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties")
; | 198 ScriptFunctionCall function(injectedScriptValue(), "getInternalProperties"); |
| 199 function.appendArgument(objectId); | 199 function.appendArgument(objectId); |
| 200 | 200 |
| 201 RefPtr<JSONValue> result; | 201 RefPtr<JSONValue> result; |
| 202 makeCall(function, &result); | 202 makeCall(function, &result); |
| 203 if (!result || result->type() != JSONValue::TypeArray) { | 203 if (!result || result->type() != JSONValue::TypeArray) { |
| 204 *errorString = "Internal error"; | 204 *errorString = "Internal error"; |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDes
criptor>::runtimeCast(result); | 207 RefPtr<Array<InternalPropertyDescriptor> > array = Array<InternalPropertyDes
criptor>::runtimeCast(result); |
| 208 if (array->length() > 0) | 208 if (array->length() > 0) |
| 209 *properties = array; | 209 *properties = array; |
| 210 } | 210 } |
| 211 | 211 |
| 212 Node* InjectedScript::nodeForObjectId(const String& objectId) | 212 Node* InjectedScript::nodeForObjectId(const String& objectId) |
| 213 { | 213 { |
| 214 if (isEmpty() || !canAccessInspectedWindow()) | 214 if (isEmpty() || !canAccessInspectedWindow()) |
| 215 return 0; | 215 return 0; |
| 216 | 216 |
| 217 ScriptFunctionCall function(injectedScriptObject(), "nodeForObjectId"); | 217 ScriptFunctionCall function(injectedScriptValue(), "nodeForObjectId"); |
| 218 function.appendArgument(objectId); | 218 function.appendArgument(objectId); |
| 219 | 219 |
| 220 bool hadException = false; | 220 bool hadException = false; |
| 221 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 221 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 222 ASSERT(!hadException); | 222 ASSERT(!hadException); |
| 223 | 223 |
| 224 return InjectedScriptHost::scriptValueAsNode(resultValue); | 224 return InjectedScriptHost::scriptValueAsNode(resultValue); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void InjectedScript::releaseObject(const String& objectId) | 227 void InjectedScript::releaseObject(const String& objectId) |
| 228 { | 228 { |
| 229 ScriptFunctionCall function(injectedScriptObject(), "releaseObject"); | 229 ScriptFunctionCall function(injectedScriptValue(), "releaseObject"); |
| 230 function.appendArgument(objectId); | 230 function.appendArgument(objectId); |
| 231 RefPtr<JSONValue> result; | 231 RefPtr<JSONValue> result; |
| 232 makeCall(function, &result); | 232 makeCall(function, &result); |
| 233 } | 233 } |
| 234 | 234 |
| 235 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue&
callFrames, int asyncOrdinal) | 235 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue&
callFrames, int asyncOrdinal) |
| 236 { | 236 { |
| 237 ASSERT(!isEmpty()); | 237 ASSERT(!isEmpty()); |
| 238 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); | 238 ScriptFunctionCall function(injectedScriptValue(), "wrapCallFrames"); |
| 239 function.appendArgument(callFrames); | 239 function.appendArgument(callFrames); |
| 240 function.appendArgument(asyncOrdinal); | 240 function.appendArgument(asyncOrdinal); |
| 241 bool hadException = false; | 241 bool hadException = false; |
| 242 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep
tion); | 242 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep
tion); |
| 243 ASSERT(!hadException); | 243 ASSERT(!hadException); |
| 244 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); | 244 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); |
| 245 if (result->type() == JSONValue::TypeArray) | 245 if (result->type() == JSONValue::TypeArray) |
| 246 return Array<CallFrame>::runtimeCast(result); | 246 return Array<CallFrame>::runtimeCast(result); |
| 247 return Array<CallFrame>::create(); | 247 return Array<CallFrame>::create(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const | 250 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const |
| 251 { | 251 { |
| 252 ASSERT(!isEmpty()); | 252 ASSERT(!isEmpty()); |
| 253 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); | 253 ScriptFunctionCall wrapFunction(injectedScriptValue(), "wrapObject"); |
| 254 wrapFunction.appendArgument(value); | 254 wrapFunction.appendArgument(value); |
| 255 wrapFunction.appendArgument(groupName); | 255 wrapFunction.appendArgument(groupName); |
| 256 wrapFunction.appendArgument(canAccessInspectedWindow()); | 256 wrapFunction.appendArgument(canAccessInspectedWindow()); |
| 257 wrapFunction.appendArgument(generatePreview); | 257 wrapFunction.appendArgument(generatePreview); |
| 258 bool hadException = false; | 258 bool hadException = false; |
| 259 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 259 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
| 260 if (hadException) | 260 if (hadException) |
| 261 return nullptr; | 261 return nullptr; |
| 262 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 262 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); |
| 263 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 263 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 264 } | 264 } |
| 265 | 265 |
| 266 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S
criptValue& table, const ScriptValue& columns) const | 266 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S
criptValue& table, const ScriptValue& columns) const |
| 267 { | 267 { |
| 268 ASSERT(!isEmpty()); | 268 ASSERT(!isEmpty()); |
| 269 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); | 269 ScriptFunctionCall wrapFunction(injectedScriptValue(), "wrapTable"); |
| 270 wrapFunction.appendArgument(canAccessInspectedWindow()); | 270 wrapFunction.appendArgument(canAccessInspectedWindow()); |
| 271 wrapFunction.appendArgument(table); | 271 wrapFunction.appendArgument(table); |
| 272 if (columns.isEmpty()) | 272 if (columns.isEmpty()) |
| 273 wrapFunction.appendArgument(false); | 273 wrapFunction.appendArgument(false); |
| 274 else | 274 else |
| 275 wrapFunction.appendArgument(columns); | 275 wrapFunction.appendArgument(columns); |
| 276 bool hadException = false; | 276 bool hadException = false; |
| 277 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 277 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
| 278 if (hadException) | 278 if (hadException) |
| 279 return nullptr; | 279 return nullptr; |
| 280 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); | 280 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); |
| 281 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); | 281 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); |
| 282 } | 282 } |
| 283 | 283 |
| 284 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no
de, const String& groupName) | 284 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no
de, const String& groupName) |
| 285 { | 285 { |
| 286 return wrapObject(nodeAsScriptValue(node), groupName); | 286 return wrapObject(nodeAsScriptValue(node), groupName); |
| 287 } | 287 } |
| 288 | 288 |
| 289 ScriptValue InjectedScript::findObjectById(const String& objectId) const | 289 ScriptValue InjectedScript::findObjectById(const String& objectId) const |
| 290 { | 290 { |
| 291 ASSERT(!isEmpty()); | 291 ASSERT(!isEmpty()); |
| 292 ScriptFunctionCall function(injectedScriptObject(), "findObjectById"); | 292 ScriptFunctionCall function(injectedScriptValue(), "findObjectById"); |
| 293 function.appendArgument(objectId); | 293 function.appendArgument(objectId); |
| 294 | 294 |
| 295 bool hadException = false; | 295 bool hadException = false; |
| 296 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 296 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 297 ASSERT(!hadException); | 297 ASSERT(!hadException); |
| 298 return resultValue; | 298 return resultValue; |
| 299 } | 299 } |
| 300 | 300 |
| 301 ScriptValue InjectedScript::findCallFrameById(ErrorString* errorString, const Sc
riptValue& topCallFrame, const String& callFrameId) | 301 ScriptValue InjectedScript::findCallFrameById(ErrorString* errorString, const Sc
riptValue& topCallFrame, const String& callFrameId) |
| 302 { | 302 { |
| 303 ScriptFunctionCall function(injectedScriptObject(), "callFrameForId"); | 303 ScriptFunctionCall function(injectedScriptValue(), "callFrameForId"); |
| 304 function.appendArgument(topCallFrame); | 304 function.appendArgument(topCallFrame); |
| 305 function.appendArgument(callFrameId); | 305 function.appendArgument(callFrameId); |
| 306 bool hadException = false; | 306 bool hadException = false; |
| 307 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); | 307 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException
); |
| 308 ASSERT(!hadException); | 308 ASSERT(!hadException); |
| 309 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { | 309 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { |
| 310 *errorString = "Internal error"; | 310 *errorString = "Internal error"; |
| 311 return ScriptValue(); | 311 return ScriptValue(); |
| 312 } | 312 } |
| 313 return resultValue; | 313 return resultValue; |
| 314 } | 314 } |
| 315 | 315 |
| 316 void InjectedScript::inspectNode(Node* node) | 316 void InjectedScript::inspectNode(Node* node) |
| 317 { | 317 { |
| 318 ASSERT(!isEmpty()); | 318 ASSERT(!isEmpty()); |
| 319 ScriptFunctionCall function(injectedScriptObject(), "inspectNode"); | 319 ScriptFunctionCall function(injectedScriptValue(), "inspectNode"); |
| 320 function.appendArgument(nodeAsScriptValue(node)); | 320 function.appendArgument(nodeAsScriptValue(node)); |
| 321 RefPtr<JSONValue> result; | 321 RefPtr<JSONValue> result; |
| 322 makeCall(function, &result); | 322 makeCall(function, &result); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void InjectedScript::releaseObjectGroup(const String& objectGroup) | 325 void InjectedScript::releaseObjectGroup(const String& objectGroup) |
| 326 { | 326 { |
| 327 ASSERT(!isEmpty()); | 327 ASSERT(!isEmpty()); |
| 328 ScriptFunctionCall releaseFunction(injectedScriptObject(), "releaseObjectGro
up"); | 328 ScriptFunctionCall releaseFunction(injectedScriptValue(), "releaseObjectGrou
p"); |
| 329 releaseFunction.appendArgument(objectGroup); | 329 releaseFunction.appendArgument(objectGroup); |
| 330 bool hadException = false; | 330 bool hadException = false; |
| 331 callFunctionWithEvalEnabled(releaseFunction, hadException); | 331 callFunctionWithEvalEnabled(releaseFunction, hadException); |
| 332 ASSERT(!hadException); | 332 ASSERT(!hadException); |
| 333 } | 333 } |
| 334 | 334 |
| 335 ScriptValue InjectedScript::nodeAsScriptValue(Node* node) | 335 ScriptValue InjectedScript::nodeAsScriptValue(Node* node) |
| 336 { | 336 { |
| 337 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); | 337 return InjectedScriptHost::nodeAsScriptValue(scriptState(), node); |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace WebCore | 340 } // namespace WebCore |
| 341 | 341 |
| OLD | NEW |