JSGlobalObjectDebuggerAgent.cpp [plain text]
#include "config.h"
#include "JSGlobalObjectDebuggerAgent.h"
#if ENABLE(INSPECTOR)
#include "InjectedScriptManager.h"
#include "InspectorConsoleAgent.h"
#include "JSGlobalObject.h"
#include "ScriptArguments.h"
#include "ScriptCallStack.h"
#include "ScriptCallStackFactory.h"
using namespace JSC;
namespace Inspector {
JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent(InjectedScriptManager* injectedScriptManager, JSC::JSGlobalObject& globalObject, InspectorConsoleAgent* consoleAgent)
: InspectorDebuggerAgent(injectedScriptManager)
, m_scriptDebugServer(globalObject)
, m_consoleAgent(consoleAgent)
{
}
void JSGlobalObjectDebuggerAgent::startListeningScriptDebugServer()
{
scriptDebugServer().addListener(this);
}
void JSGlobalObjectDebuggerAgent::stopListeningScriptDebugServer(bool isBeingDestroyed)
{
scriptDebugServer().removeListener(this, isBeingDestroyed);
}
InjectedScript JSGlobalObjectDebuggerAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId)
{
if (executionContextId) {
*error = ASCIILiteral("Execution context id is not supported for JSContext inspection as there is only one execution context.");
return InjectedScript();
}
ExecState* exec = m_scriptDebugServer.globalObject().globalExec();
return injectedScriptManager()->injectedScriptFor(exec);
}
void JSGlobalObjectDebuggerAgent::breakpointActionLog(JSC::ExecState* exec, const String& message)
{
m_consoleAgent->addMessageToConsole(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture), 0);
}
}
#endif // ENABLE(INSPECTOR)