#include "config.h"
#include "InjectedScript.h"
-#if ENABLE(INSPECTOR)
-
#include "InspectorValues.h"
#include "JSCInlines.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
#include <wtf/text/WTFString.h>
-using Inspector::TypeBuilder::Array;
+using Inspector::Protocol::Array;
namespace Inspector {
{
}
-void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
+void InjectedScript::evaluate(ErrorString& errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluate"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(expression);
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- makeEvalCall(errorString, function, result, wasThrown);
+ function.appendArgument(saveResult);
+ makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
-void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
+void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("callFunctionOn"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
+void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluateOnCallFrame"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- makeEvalCall(errorString, function, result, wasThrown);
+ function.appendArgument(saveResult);
+ makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
-void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<Inspector::TypeBuilder::Debugger::FunctionDetails>* result)
+void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>* result)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getFunctionDetails"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(functionId);
RefPtr<InspectorValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != InspectorValue::Type::Object) {
if (!resultValue->asString(errorString))
- *errorString = ASCIILiteral("Internal error");
+ errorString = ASCIILiteral("Internal error");
return;
}
- *result = Inspector::TypeBuilder::Debugger::FunctionDetails::runtimeCast(resultValue);
+ *result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTF::move(resultValue));
}
-void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
function.appendArgument(ownProperties);
+ function.appendArgument(generatePreview);
+
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
+ if (!result || result->type() != InspectorValue::Type::Array) {
+ errorString = ASCIILiteral("Internal error");
+ return;
+ }
+
+ *properties = BindingTraits<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTF::move(result));
+}
+
+void InjectedScript::getDisplayableProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+{
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getDisplayableProperties"), inspectorEnvironment()->functionCallHandler());
+ function.appendArgument(objectId);
+ function.appendArgument(generatePreview);
RefPtr<InspectorValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::TypeArray) {
- *errorString = ASCIILiteral("Internal error");
+ if (!result || result->type() != InspectorValue::Type::Array) {
+ errorString = ASCIILiteral("Internal error");
return;
}
- *properties = Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>::runtimeCast(result);
+ *properties = BindingTraits<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTF::move(result));
}
-void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>* properties)
+void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>* properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
+ function.appendArgument(generatePreview);
RefPtr<InspectorValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::TypeArray) {
- *errorString = ASCIILiteral("Internal error");
+ if (!result || result->type() != InspectorValue::Type::Array) {
+ errorString = ASCIILiteral("Internal error");
return;
}
- RefPtr<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>> array = Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>::runtimeCast(result);
- if (array->length() > 0)
- *properties = array;
+ auto array = BindingTraits<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>::runtimeCast(WTF::move(result));
+ *properties = array->length() > 0 ? array : nullptr;
}
-PassRefPtr<Array<Inspector::TypeBuilder::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
+void InjectedScript::getCollectionEntries(ErrorString& errorString, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries)
+{
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getCollectionEntries"), inspectorEnvironment()->functionCallHandler());
+ function.appendArgument(objectId);
+ function.appendArgument(objectGroup);
+ function.appendArgument(startIndex);
+ function.appendArgument(numberToFetch);
+
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
+ if (!result || result->type() != InspectorValue::Type::Array) {
+ errorString = ASCIILiteral("Internal error");
+ return;
+ }
+
+ *entries = BindingTraits<Array<Protocol::Runtime::CollectionEntry>>::runtimeCast(WTF::move(result));
+}
+
+void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+{
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("saveResult"), inspectorEnvironment()->functionCallHandler());
+ function.appendArgument(callArgumentJSON);
+
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
+ if (!result || result->type() != InspectorValue::Type::Integer) {
+ errorString = ASCIILiteral("Internal error");
+ return;
+ }
+
+ int savedResultIndexInt = 0;
+ if (result->asInteger(savedResultIndexInt) && savedResultIndexInt > 0)
+ *savedResultIndex = savedResultIndexInt;
+}
+
+Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());
Deprecated::ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(scriptState());
- if (result->type() == InspectorValue::TypeArray)
- return Array<Inspector::TypeBuilder::Debugger::CallFrame>::runtimeCast(result);
+ if (result->type() == InspectorValue::Type::Array)
+ return BindingTraits<Array<Inspector::Protocol::Debugger::CallFrame>>::runtimeCast(WTF::move(result)).releaseNonNull();
- return Array<Inspector::TypeBuilder::Debugger::CallFrame>::create();
+ return Array<Inspector::Protocol::Debugger::CallFrame>::create();
}
-PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
+RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapObject"), inspectorEnvironment()->functionCallHandler());
if (hadException)
return nullptr;
- RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
- return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
+ RefPtr<InspectorObject> resultObject;
+ bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
+ ASSERT_UNUSED(castSucceeded, castSucceeded);
+
+ return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
}
-PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const
+RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapTable"), inspectorEnvironment()->functionCallHandler());
if (hadException)
return nullptr;
- RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
- return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
+ RefPtr<InspectorObject> resultObject;
+ bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
+ ASSERT_UNUSED(castSucceeded, castSucceeded);
+
+ return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
+}
+
+void InjectedScript::setExceptionValue(const Deprecated::ScriptValue& value)
+{
+ ASSERT(!hasNoValue());
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("setExceptionValue"), inspectorEnvironment()->functionCallHandler());
+ function.appendArgument(value);
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
+}
+
+void InjectedScript::clearExceptionValue()
+{
+ ASSERT(!hasNoValue());
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("clearExceptionValue"), inspectorEnvironment()->functionCallHandler());
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
}
Deprecated::ScriptValue InjectedScript::findObjectById(const String& objectId) const
} // namespace Inspector
-#endif // ENABLE(INSPECTOR)