void ConsoleMessage::addToFrontend(ConsoleFrontendDispatcher* consoleFrontendDispatcher, InjectedScriptManager* injectedScriptManager, bool generatePreview) { Ref<Inspector::Protocol::Console::ConsoleMessage> jsonObj = Inspector::Protocol::Console::ConsoleMessage::create() .setSource(messageSourceValue(m_source)) .setLevel(messageLevelValue(m_level)) .setText(m_message) .release(); // FIXME: only send out type for ConsoleAPI source messages. jsonObj->setType(messageTypeValue(m_type)); jsonObj->setLine(static_cast<int>(m_line)); jsonObj->setColumn(static_cast<int>(m_column)); jsonObj->setUrl(m_url); jsonObj->setRepeatCount(static_cast<int>(m_repeatCount)); if (m_source == MessageSource::Network && !m_requestId.isEmpty()) jsonObj->setNetworkRequestId(m_requestId); if (m_arguments && m_arguments->argumentCount()) { InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState()); if (!injectedScript.hasNoValue()) { Ref<Inspector::Protocol::Array<Inspector::Protocol::Runtime::RemoteObject>> jsonArgs = Inspector::Protocol::Array<Inspector::Protocol::Runtime::RemoteObject>::create(); if (m_type == MessageType::Table && generatePreview && m_arguments->argumentCount()) { Deprecated::ScriptValue table = m_arguments->argumentAt(0); Deprecated::ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : Deprecated::ScriptValue(); RefPtr<Inspector::Protocol::Runtime::RemoteObject> inspectorValue = injectedScript.wrapTable(table, columns); if (!inspectorValue) { ASSERT_NOT_REACHED(); return; } jsonArgs->addItem(inspectorValue.copyRef()); if (m_arguments->argumentCount() > 1) jsonArgs->addItem(injectedScript.wrapObject(columns, ASCIILiteral("console"), true)); } else { for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { RefPtr<Inspector::Protocol::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), ASCIILiteral("console"), generatePreview); if (!inspectorValue) { ASSERT_NOT_REACHED(); return; } jsonArgs->addItem(inspectorValue.copyRef()); } } jsonObj->setParameters(WTF::move(jsonArgs)); } } if (m_callStack) jsonObj->setStackTrace(m_callStack->buildInspectorArray()); consoleFrontendDispatcher->messageAdded(WTF::move(jsonObj)); }
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview) { RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create() .setSource(messageSourceValue(m_source)) .setLevel(messageLevelValue(m_level)) .setText(m_message) .setTimestamp(m_timestamp); // FIXME: only send out type for ConsoleAPI source messages. jsonObj->setType(messageTypeValue(m_type)); jsonObj->setLine(static_cast<int>(m_line)); jsonObj->setColumn(static_cast<int>(m_column)); jsonObj->setUrl(m_url); ScriptState* scriptState = m_scriptState.get(); if (scriptState && scriptState->executionContext()->isDocument()) jsonObj->setExecutionContextId(injectedScriptManager->injectedScriptIdFor(scriptState)); if (m_source == NetworkMessageSource && !m_requestId.isEmpty()) jsonObj->setNetworkRequestId(m_requestId); if (m_arguments && m_arguments->argumentCount()) { InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->scriptState()); if (!injectedScript.isEmpty()) { RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create(); if (m_type == TableMessageType && generatePreview && m_arguments->argumentCount()) { ScriptValue table = m_arguments->argumentAt(0); ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : ScriptValue(); RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapTable(table, columns); if (!inspectorValue) { ASSERT_NOT_REACHED(); return; } jsonArgs->addItem(inspectorValue); } else { for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console", generatePreview); if (!inspectorValue) { ASSERT_NOT_REACHED(); return; } jsonArgs->addItem(inspectorValue); } } jsonObj->setParameters(jsonArgs); } } if (m_callStack) jsonObj->setStackTrace(m_callStack->buildInspectorArray()); frontend->messageAdded(jsonObj); frontend->flush(); }