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); }
void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) { ScriptObject jsonObj = frontend->newScriptObject(); jsonObj.set("source", static_cast<int>(m_source)); jsonObj.set("type", static_cast<int>(m_type)); jsonObj.set("level", static_cast<int>(m_level)); jsonObj.set("line", static_cast<int>(m_line)); jsonObj.set("url", m_url); jsonObj.set("groupLevel", static_cast<int>(m_groupLevel)); jsonObj.set("repeatCount", static_cast<int>(m_repeatCount)); Vector<RefPtr<SerializedScriptValue> > arguments; if (!m_arguments.isEmpty()) { InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get()); for (unsigned i = 0; i < m_arguments.size(); ++i) { RefPtr<SerializedScriptValue> serializedValue = injectedScript.wrapForConsole(m_arguments[i]); arguments.append(serializedValue); } } frontend->addConsoleMessage(jsonObj, m_frames, arguments, m_message); }
void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState* scriptState, const Vector<ScriptValue> arguments, const String& message) { ScriptFunctionCall function(m_webInspector, "dispatch"); function.appendArgument("addConsoleMessage"); function.appendArgument(messageObj); if (!frames.isEmpty()) { for (unsigned i = 0; i < frames.size(); ++i) function.appendArgument(frames[i]); } else if (!arguments.isEmpty()) { InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState); for (unsigned i = 0; i < arguments.size(); ++i) { RefPtr<SerializedScriptValue> serializedValue = injectedScript.wrapForConsole(arguments[i]); ScriptValue scriptValue = ScriptValue::deserialize(this->scriptState(), serializedValue.get()); if (scriptValue.hasNoValue()) { ASSERT_NOT_REACHED(); return; } function.appendArgument(scriptValue); } } else { function.appendArgument(message); } function.call(); }