PassRefPtr<InspectorValue> InjectedScript::callFrames() { ASSERT(!hasNoValue()); ScriptFunctionCall function(m_injectedScriptObject, "callFrames"); ScriptValue callFramesValue = function.call(); return callFramesValue.toInspectorValue(m_injectedScriptObject.scriptState()); }
PassRefPtr<InspectorArray> InjectedScript::wrapCallFrames(const ScriptValue& callFrames) { ASSERT(!hasNoValue()); ScriptFunctionCall function(m_injectedScriptObject, "wrapCallFrames"); function.appendArgument(callFrames); ScriptValue callFramesValue = function.call(); RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(m_injectedScriptObject.scriptState()); if (result->type() == InspectorValue::TypeArray) return result->asArray(); return InspectorArray::create(); }
PassRefPtr<InspectorValue> InjectedScript::wrapForConsole(ScriptValue value) { ASSERT(!hasNoValue()); ScriptFunctionCall wrapFunction(m_injectedScriptObject, "wrapObjectForConsole"); wrapFunction.appendArgument(value); wrapFunction.appendArgument(canAccessInspectedWindow()); bool hadException = false; ScriptValue r = wrapFunction.call(hadException); if (hadException) return InspectorString::create("<exception>"); return r.toInspectorValue(m_injectedScriptObject.scriptState()); }
PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& callFrames) { ASSERT(!hasNoValue()); ScriptFunctionCall function(m_injectedScriptObject, "wrapCallFrames"); function.appendArgument(callFrames); bool hadException = false; ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(m_injectedScriptObject.scriptState()); if (result->type() == InspectorValue::TypeArray) return Array<CallFrame>::runtimeCast(result); return Array<CallFrame>::create(); }
PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(ScriptValue value, const String& groupName) const { ASSERT(!hasNoValue()); ScriptFunctionCall wrapFunction(m_injectedScriptObject, "wrapObject"); wrapFunction.appendArgument(value); wrapFunction.appendArgument(groupName); wrapFunction.appendArgument(canAccessInspectedWindow()); bool hadException = false; ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); if (hadException) { return 0; } RefPtr<InspectorObject> rawResult = r.toInspectorValue(m_injectedScriptObject.scriptState())->asObject(); return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); }
PassRefPtr<InspectorObject> InjectedScript::wrapObject(ScriptValue value, const String& groupName) const { ASSERT(!hasNoValue()); ScriptFunctionCall wrapFunction(m_injectedScriptObject, "wrapObject"); wrapFunction.appendArgument(value); wrapFunction.appendArgument(groupName); wrapFunction.appendArgument(canAccessInspectedWindow()); bool hadException = false; ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); if (hadException) { RefPtr<InspectorObject> result = InspectorObject::create(); result->setString("description", "<exception>"); return result; } return r.toInspectorValue(m_injectedScriptObject.scriptState())->asObject(); }
void InjectedScript::dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException) { ASSERT(!hasNoValue()); if (!canAccessInspectedWindow()) { *hadException = true; return; } ScriptFunctionCall function(m_injectedScriptObject, "dispatch"); function.appendArgument(methodName); function.appendArgument(arguments); *hadException = false; ScriptValue resultValue = function.call(*hadException); if (!*hadException) *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); }
void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result) { if (hasNoValue() || !canAccessInspectedWindow()) { *result = InspectorValue::null(); return; } bool hadException = false; ScriptValue resultValue = function.call(hadException); ASSERT(!hadException); if (!hadException) *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); else *result = InspectorString::create("Exception while making a call."); }
void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result) { if (hasNoValue() || !canAccessInspectedWindow()) { *result = InspectorValue::null(); return; } bool hadException = false; ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); if (!hadException) { *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); if (!*result) *result = InspectorString::create(String::format("Object has too long reference chain(must not be longer than %d)", InspectorValue::maxDepth)); } else *result = InspectorString::create("Exception while making a call."); }