WorkerDebuggerAgent.cpp [plain text]
#include "config.h"
#include "WorkerDebuggerAgent.h"
#include "ScriptState.h"
#include "WorkerGlobalScope.h"
#include <JavaScriptCore/ConsoleMessage.h>
#include <JavaScriptCore/InjectedScript.h>
#include <JavaScriptCore/InjectedScriptManager.h>
#include <JavaScriptCore/ScriptCallStack.h>
#include <JavaScriptCore/ScriptCallStackFactory.h>
namespace WebCore {
using namespace JSC;
using namespace Inspector;
WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerAgentContext& context)
: WebDebuggerAgent(context)
, m_workerGlobalScope(context.workerGlobalScope)
{
ASSERT(context.workerGlobalScope.isContextThread());
}
WorkerDebuggerAgent::~WorkerDebuggerAgent() = default;
void WorkerDebuggerAgent::breakpointActionLog(ExecState& state, const String& message)
{
m_workerGlobalScope.addConsoleMessage(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state)));
}
InjectedScript WorkerDebuggerAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
{
if (executionContextId) {
errorString = "Execution context id is not supported for workers as there is only one execution context."_s;
return InjectedScript();
}
JSC::ExecState* scriptState = execStateFromWorkerGlobalScope(&m_workerGlobalScope);
return injectedScriptManager().injectedScriptFor(scriptState);
}
}