| #include "config.h" |
| #include "bindings/core/dart/DartInspectorRuntimeAgent.h" |
| |
| #include "bindings/core/v8/ScriptState.h" |
| #include "bindings/core/dart/DartInjectedScript.h" |
| #include "bindings/core/dart/DartInjectedScriptManager.h" |
| #include "bindings/core/dart/DartScriptState.h" |
| #include "bindings/core/dart/DartScriptDebugServer.h" |
| #include "core/inspector/InjectedScript.h" |
| #include "core/inspector/InspectorState.h" |
| #include "core/inspector/V8Debugger.h" |
| #include "platform/JSONValues.h" |
| |
| using blink::TypeBuilder::Runtime::ExecutionContextDescription; |
| |
| namespace blink { |
| |
| static V8Debugger::PauseOnExceptionsState setPauseOnExceptionsState(V8Debugger::PauseOnExceptionsState newState) |
| { |
| DartScriptDebugServer& scriptDebugServer = DartScriptDebugServer::shared(); |
| V8Debugger::PauseOnExceptionsState presentState = scriptDebugServer.pauseOnExceptionsState(); |
| if (presentState != newState) |
| scriptDebugServer.setPauseOnExceptionsState(newState); |
| return presentState; |
| } |
| |
| DartInspectorRuntimeAgent::DartInspectorRuntimeAgent(DartInjectedScriptManager* injectedScriptManager, InspectorRuntimeAgent* inspectorRuntimeAgent) |
| { |
| m_injectedScriptManager = injectedScriptManager; |
| m_inspectorRuntimeAgent = inspectorRuntimeAgent; |
| } |
| |
| DartInjectedScript* DartInspectorRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) |
| { |
| if (!executionContextId) { |
| return 0; |
| } |
| DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScriptForId(*executionContextId); |
| if (injectedScript == 0) |
| *errorString = "Execution context with given id not found."; |
| return injectedScript; |
| } |
| |
| void DartInspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown, RefPtr<TypeBuilder::Debugger::ExceptionDetails>& exceptionDetails) |
| { |
| DartInjectedScript* injectedScript = injectedScriptForEval(errorString, executionContextId); |
| if (!injectedScript) |
| return; |
| V8Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = V8Debugger::DontPauseOnExceptions; |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
| previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
| m_inspectorRuntimeAgent->muteConsole(); |
| |
| injectedScript->evaluate(errorString, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasThrown, &exceptionDetails); |
| |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
| m_inspectorRuntimeAgent->unmuteConsole(); |
| setPauseOnExceptionsState(previousPauseOnExceptionsState); |
| } |
| } |
| |
| void DartInspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<JSONArray>* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) |
| { |
| DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); |
| if (!injectedScript) { |
| *errorString = "Inspected frame has gone"; |
| return; |
| } |
| String arguments; |
| if (optionalArguments) |
| arguments = (*optionalArguments)->toJSONString(); |
| |
| V8Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = V8Debugger::DontPauseOnExceptions; |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
| previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
| m_inspectorRuntimeAgent->muteConsole(); |
| |
| injectedScript->callFunctionOn(errorString, objectId, expression, arguments, asBool(returnByValue), asBool(generatePreview), &result, wasThrown); |
| |
| if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
| m_inspectorRuntimeAgent->unmuteConsole(); |
| setPauseOnExceptionsState(previousPauseOnExceptionsState); |
| } |
| |
| } |
| |
| void DartInspectorRuntimeAgent::getCompletions(ErrorString* errorString, const String& expression, const int* executionContextId, RefPtr<TypeBuilder::Array<String> >& result) |
| { |
| DartInjectedScript* injectedScript = injectedScriptForEval(errorString, executionContextId); |
| if (!injectedScript) |
| return; |
| |
| V8Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); |
| m_inspectorRuntimeAgent->muteConsole(); |
| |
| injectedScript->getCompletions(errorString, expression, &result); |
| |
| m_inspectorRuntimeAgent->unmuteConsole(); |
| setPauseOnExceptionsState(previousPauseOnExceptionsState); |
| |
| } |
| |
| void DartInspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* ownProperties, const bool* accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& internalProperties) |
| { |
| DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); |
| if (!injectedScript) { |
| *errorString = "Inspected frame has gone"; |
| return; |
| } |
| |
| V8Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); |
| m_inspectorRuntimeAgent->muteConsole(); |
| |
| injectedScript->getProperties(errorString, objectId, asBool(ownProperties), asBool(accessorPropertiesOnly), &result); |
| |
| if (!asBool(accessorPropertiesOnly)) |
| injectedScript->getInternalProperties(errorString, objectId, &internalProperties); |
| |
| m_inspectorRuntimeAgent->unmuteConsole(); |
| setPauseOnExceptionsState(previousPauseOnExceptionsState); |
| } |
| |
| void DartInspectorRuntimeAgent::getProperty(ErrorString* errorString, const String& objectId, const RefPtr<JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) |
| { |
| DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); |
| if (!injectedScript) { |
| *errorString = "Inspected frame has gone"; |
| return; |
| } |
| |
| V8Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); |
| m_inspectorRuntimeAgent->muteConsole(); |
| |
| injectedScript->getProperty(errorString, objectId, propertyPath, &result, wasThrown); |
| |
| m_inspectorRuntimeAgent->unmuteConsole(); |
| setPauseOnExceptionsState(previousPauseOnExceptionsState); |
| } |
| |
| void DartInspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) |
| { |
| DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); |
| if (injectedScript) |
| injectedScript->releaseObject(objectId); |
| } |
| |
| void DartInspectorRuntimeAgent::releaseObjectGroup(ErrorString*, const String& objectGroup) |
| { |
| m_injectedScriptManager->releaseObjectGroup(objectGroup); |
| } |
| |
| void DartInspectorRuntimeAgent::addExecutionContextToFrontendHelper(DartScriptState* scriptState, bool isPageContext, const String& name, const String& frameId) |
| { |
| m_inspectorRuntimeAgent->addExecutionContextToFrontendDart(m_injectedScriptManager->injectedScriptIdFor(scriptState), "", "", name, frameId, "Dart", scriptState->libraryId()); |
| } |
| |
| } // namespace blink |