本文整理汇总了C++中InjectedScript类的典型用法代码示例。如果您正苦于以下问题:C++ InjectedScript类的具体用法?C++ InjectedScript怎么用?C++ InjectedScript使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InjectedScript类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addToFrontend
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
{
RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
.setSource(messageSourceValue(m_source))
.setLevel(messageLevelValue(m_level))
.setText(m_message);
// FIXME: only send out type for ConsoleAPI source messages.
jsonObj->setType(messageTypeValue(m_type));
jsonObj->setLine(static_cast<int>(m_line));
jsonObj->setUrl(m_url);
jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
jsonObj->setNetworkRequestId(m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<InspectorValue> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console");
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->pushValue(inspectorValue);
}
jsonObj->setParameters(jsonArgs);
}
}
if (m_callStack)
jsonObj->setStackTrace(m_callStack->buildInspectorArray());
frontend->messageAdded(jsonObj);
}
示例2: callFunctionOn
void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>& result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
String arguments;
if (optionalArguments)
arguments = (*optionalArguments)->toJSONString();
#if ENABLE(JAVASCRIPT_DEBUGGER)
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions;
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
#endif
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
muteConsole();
injectedScript.callFunctionOn(errorString, objectId, expression, arguments, asBool(returnByValue), asBool(generatePreview), &result, wasThrown);
if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
unmuteConsole();
#if ENABLE(JAVASCRIPT_DEBUGGER)
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
#endif
}
}
示例3: lock
void InspectorHeapAgent::getRemoteObject(ErrorString& errorString, int heapObjectId, const String* optionalObjectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
{
// Prevent the cell from getting collected as we look it up.
VM& vm = m_environment.vm();
JSLockHolder lock(vm);
DeferGC deferGC(vm.heap);
unsigned heapObjectIdentifier = static_cast<unsigned>(heapObjectId);
const std::optional<HeapSnapshotNode> optionalNode = nodeForHeapObjectIdentifier(errorString, heapObjectIdentifier);
if (!optionalNode)
return;
JSCell* cell = optionalNode->cell;
Structure* structure = cell->structure(vm);
if (!structure) {
errorString = ASCIILiteral("Unable to get object details");
return;
}
JSGlobalObject* globalObject = structure->globalObject();
if (!globalObject) {
errorString = ASCIILiteral("Unable to get object details");
return;
}
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject->globalExec());
if (injectedScript.hasNoValue()) {
errorString = ASCIILiteral("Unable to get object details - InjectedScript");
return;
}
String objectGroup = optionalObjectGroup ? *optionalObjectGroup : String();
result = injectedScript.wrapObject(cell, objectGroup, true);
}
示例4: scriptStateForFrameId
void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, const bool* const returnByValue, RefPtr<InspectorObject>* result, bool* wasThrown)
{
ScriptState* scriptState = 0;
if (frameId) {
scriptState = scriptStateForFrameId(*frameId);
if (!scriptState) {
*errorString = "Frame with given id not found.";
return;
}
} else
scriptState = getDefaultInspectedState();
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
ASSERT(m_scriptDebugServer);
bool pauseStateChanged = false;
ScriptDebugServer::PauseOnExceptionsState presentState = m_scriptDebugServer->pauseOnExceptionsState();
if (asBool(doNotPauseOnExceptions) && presentState != ScriptDebugServer::DontPauseOnExceptions) {
m_scriptDebugServer->setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
pauseStateChanged = true;
}
#endif
injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), result, wasThrown);
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (pauseStateChanged)
m_scriptDebugServer->setPauseOnExceptionsState(presentState);
#endif
}
示例5: injectedScriptForEval
void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
{
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState();
if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteConsole) {
if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExceptions)
scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
}
ScriptValue value;
bool wasThrownValue;
String exceptionMessage;
scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value, &wasThrownValue, &exceptionMessage);
*wasThrown = wasThrownValue;
if (value.hasNoValue()) {
*errorString = "Script execution failed";
return;
}
result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
if (wasThrownValue)
result->setDescription(exceptionMessage);
if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteConsole) {
unmuteConsole();
if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState)
scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState);
}
}
示例6: ASCIILiteral
void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const InspectorArray* optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
errorString = ASCIILiteral("Could not find InjectedScript for objectId");
return;
}
String arguments;
if (optionalArguments)
arguments = optionalArguments->toJSONString();
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions;
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
muteConsole();
injectedScript.callFunctionOn(errorString, objectId, expression, arguments, asBool(returnByValue), asBool(generatePreview), &result, wasThrown);
if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
unmuteConsole();
setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
}
}
示例7: addToFrontend
void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost)
{
RefPtr<InspectorObject> jsonObj = InspectorObject::create();
jsonObj->setNumber("source", static_cast<int>(m_source));
jsonObj->setNumber("type", static_cast<int>(m_type));
jsonObj->setNumber("level", static_cast<int>(m_level));
jsonObj->setNumber("line", static_cast<int>(m_line));
jsonObj->setString("url", m_url);
jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
jsonObj->setString("message", m_message);
if (m_type == NetworkErrorMessageType)
jsonObj->setNumber("requestId", m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i));
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->pushValue(inspectorValue);
}
jsonObj->setArray("parameters", jsonArgs);
}
}
if (m_callStack)
jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject());
frontend->addConsoleMessage(jsonObj);
}
示例8: evaluateOnCallFrame
void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
{
if (!isPaused() || m_currentCallStack.isNull()) {
*errorString = "Attempt to access callframe when debugger is not on pause";
return;
}
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState();
if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExceptions)
scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
}
injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, &result, wasThrown);
if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
unmuteConsole();
if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState)
scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState);
}
}
示例9: setVariableValue
void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const String* callFrameId, const String* functionObjectId)
{
InjectedScript injectedScript;
if (callFrameId) {
if (!isPaused() || m_currentCallStack.isNull()) {
*errorString = "Attempt to access callframe when debugger is not on pause";
return;
}
injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*callFrameId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
} else if (functionObjectId) {
injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*functionObjectId);
if (injectedScript.hasNoValue()) {
*errorString = "Function object id cannot be resolved";
return;
}
} else {
*errorString = "Either call frame or function object must be specified";
return;
}
String newValueString = newValue->toJSONString();
injectedScript.setVariableValue(errorString, m_currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString);
}
示例10: ASSERT
void InspectorDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = InspectorFrontend::Debugger::Reason::Exception;
m_breakAuxData = injectedScript.wrapObject(exception, "backtrace")->openAccessors();
// m_breakAuxData might be null after this.
}
}
m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
m_javaScriptPauseScheduled = false;
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
if (m_listener)
m_listener->didPause();
}
示例11: inspectorFrontend
void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async)
{
InspectorFrontend* frontend = inspectorFrontend();
if (!frontend)
return;
// FIXME: explicitly pass injectedScriptId along with node id to the frontend.
bool injectedScriptIdIsNodeId = injectedScriptId <= 0;
InjectedScript injectedScript;
if (injectedScriptIdIsNodeId)
injectedScript = m_inspectorController->injectedScriptForNodeId(-injectedScriptId);
else
injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptForId(injectedScriptId);
if (injectedScript.hasNoValue())
return;
RefPtr<SerializedScriptValue> result;
bool hadException = false;
injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException);
if (async)
return; // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
frontend->didDispatchOnInjectedScript(callId, result.get(), hadException);
}
示例12: ASSERT
Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> InspectorDebuggerAgent::currentCallFrames(InjectedScript injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>::create();
return injectedScript.wrapCallFrames(m_currentCallStack);
}
示例13: setPropertyValue
void InspectorRuntimeAgent::setPropertyValue(ErrorString* errorString, const String& objectId, const String& propertyName, const String& expression)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (!injectedScript.hasNoValue())
injectedScript.setPropertyValue(errorString, objectId, propertyName, expression);
else
*errorString = "No injected script found";
}
示例14: injectedScriptForEval
void InspectorRuntimeAgent::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)
{
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
if (injectedScript.isEmpty())
return;
InjectedScriptCallScope callScope(this, asBool(doNotPauseOnExceptionsAndMuteConsole));
injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasThrown, &exceptionDetails);
}
示例15: getFunctionDetails
void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>& details)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(functionId);
if (injectedScript.hasNoValue()) {
*errorString = "Function object id is obsolete";
return;
}
injectedScript.getFunctionDetails(errorString, functionId, &details);
}