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);
}
Пример #2
0
void InspectorBackend::dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments)
{
    InspectorFrontend* frontend = inspectorFrontend();
    if (!frontend)
        return;

    ScriptFunctionCall function(m_inspectorController->m_scriptState, m_inspectorController->m_injectedScriptObj, "dispatch");
    function.appendArgument(methodName);
    function.appendArgument(arguments);
    bool hadException = false;
    ScriptValue result = function.call(hadException);
    if (hadException)
        frontend->didDispatchOnInjectedScript(callId, "", true);
    else
        frontend->didDispatchOnInjectedScript(callId, result.toString(m_inspectorController->m_scriptState), false);
}
void InspectorBackend::dispatchOnInjectedScript(long callId, const String& methodName, const String& arguments, bool async)
{
    InspectorFrontend* frontend = inspectorFrontend();
    if (!frontend)
        return;

    ScriptFunctionCall function(m_inspectorController->m_scriptState, m_inspectorController->m_injectedScriptObj, "dispatch");
    function.appendArgument(methodName);
    function.appendArgument(arguments);
    if (async)
        function.appendArgument(static_cast<int>(callId));
    bool hadException = false;
    ScriptValue result = function.call(hadException);
    if (async)
        return;  // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
    if (hadException)
        frontend->didDispatchOnInjectedScript(callId, "", true);
    else
        frontend->didDispatchOnInjectedScript(callId, result.toString(m_inspectorController->m_scriptState), false);
}