EncodedJSValue JSC_HOST_CALL jsConsolePrototypeFunctionGroupCollapsed(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSConsole::s_info)) return throwVMTypeError(exec); JSConsole* castedThis = static_cast<JSConsole*>(asObject(thisValue)); Console* imp = static_cast<Console*>(castedThis->impl()); RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 0)); size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); imp->groupCollapsed(scriptArguments, callStack); return JSValue::encode(jsUndefined()); }
void InspectorConsoleAgent::consoleCount(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> arguments) { RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(scriptState)); const ScriptCallFrame& lastCaller = callStack->at(0); // Follow Firebug's behavior of counting with null and undefined title in // the same bucket as no argument String title; arguments->getFirstArgumentAsString(title); String identifier = title.isEmpty() ? String(lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber())) : String(title + '@'); HashCountedSet<String>::AddResult result = m_counts.add(identifier); String message = title + ": " + String::number(result.storedValue->value); addMessageToConsole(ConsoleAPIMessageSource, LogMessageType, DebugMessageLevel, message, callStack.get()); }
PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld* isolatedWorld, ContentSecurityPolicy* policy) { JSValue v = exec->argument(0); CallData callData; if (getCallData(v, callData) == CallTypeNone) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector(exec)); if (policy && !policy->allowEval(callStack.release())) return nullptr; UString string = v.toString(exec)->value(exec); if (exec->hadException()) return nullptr; return adoptPtr(new ScheduledAction(ustringToString(string), isolatedWorld)); } return adoptPtr(new ScheduledAction(exec, v, isolatedWorld)); }
EncodedJSValue JSC_HOST_CALL jsConsolePrototypeFunctionTimeEnd(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSConsole::s_info)) return throwVMTypeError(exec); JSConsole* castedThis = static_cast<JSConsole*>(asObject(thisValue)); Console* imp = static_cast<Console*>(castedThis->impl()); RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); imp->timeEnd(title, scriptArguments, callStack); return JSValue::encode(jsUndefined()); }
void Console::profileEnd(const String& title, ScriptState* state) { Page* page = this->page(); if (!page) return; if (!InspectorInstrumentation::profilerEnabled(page)) return; RefPtr<ScriptProfile> profile = ScriptProfiler::stop(state, title); if (!profile) return; m_profiles.append(profile); RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, 1)); InspectorInstrumentation::addProfile(page, profile, callStack); }
static void internalAddMessage(Page* page, MessageType type, MessageLevel level, JSC::ExecState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArguments = false, bool printTrace = false) { RefPtr<ScriptArguments> arguments = prpArguments; if (!page) return; if (!acceptNoArguments && !arguments->argumentCount()) return; size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); const ScriptCallFrame& lastCaller = callStack->at(0); String message; bool gotMessage = arguments->getFirstArgumentAsString(message); InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); if (page->settings().privateBrowsingEnabled()) return; if (gotMessage) page->chrome().client().addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL()); if (!page->settings().logsPageMessagesToSystemConsoleEnabled() && !PageConsole::shouldPrintExceptions()) return; PageConsole::printSourceURLAndLine(lastCaller.sourceURL(), lastCaller.lineNumber()); PageConsole::printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level); for (size_t i = 0; i < arguments->argumentCount(); ++i) { String argAsString = arguments->argumentAt(i).toString(arguments->globalState()); printf(" %s", argAsString.utf8().data()); } printf("\n"); if (printTrace) { printf("Stack Trace\n"); for (size_t i = 0; i < callStack->size(); ++i) { String functionName = String(callStack->at(i).functionName()); printf("\t%s\n", functionName.utf8().data()); } } }
void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> scriptArguments, bool acceptNoArguments, bool printTrace) { if (!context()) return; RefPtr<ScriptArguments> arguments = scriptArguments; if (!acceptNoArguments && !arguments->argumentCount()) return; size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(stackSize)); String message; bool gotStringMessage = arguments->getFirstArgumentAsString(message); InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSource, type, level, message, state, arguments); if (gotStringMessage) reportMessageToClient(level, message, callStack); }
void ConsoleBase::count(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> arguments) { RefPtr<ScriptCallStack> callStack(ScriptCallStack::capture(1)); // Follow Firebug's behavior of counting with null and undefined title in // the same bucket as no argument String title; arguments->getFirstArgumentAsString(title); String identifier = title.isEmpty() ? String(callStack->topSourceURL() + ':' + String::number(callStack->topLineNumber())) : String(title + '@'); HashCountedSet<String>::AddResult result = m_counts.add(identifier); String message = title + ": " + String::number(result.storedValue->value); RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, DebugMessageLevel, message); consoleMessage->setType(CountMessageType); consoleMessage->setScriptState(scriptState); consoleMessage->setCallStack(callStack.release()); reportMessageToConsole(consoleMessage.release()); }
void ConsoleClient::printConsoleMessageWithArguments(MessageSource source, MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments) { bool isTraceMessage = type == MessageType::Trace; size_t stackSize = isTraceMessage ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, stackSize)); const ScriptCallFrame& lastCaller = callStack->at(0); StringBuilder builder; if (!lastCaller.sourceURL().isEmpty()) { appendURLAndPosition(builder, lastCaller.sourceURL(), lastCaller.lineNumber(), lastCaller.columnNumber()); builder.appendLiteral(": "); } appendMessagePrefix(builder, source, type, level); for (size_t i = 0; i < arguments->argumentCount(); ++i) { String argAsString = arguments->argumentAt(i).toString(arguments->globalState()); builder.append(' '); builder.append(argAsString.utf8().data()); } WTFLogAlways("%s", builder.toString().utf8().data()); if (isTraceMessage) { for (size_t i = 0; i < callStack->size(); ++i) { const ScriptCallFrame& callFrame = callStack->at(i); String functionName = String(callFrame.functionName()); if (functionName.isEmpty()) functionName = ASCIILiteral("(unknown)"); StringBuilder callFrameBuilder; callFrameBuilder.appendNumber(i); callFrameBuilder.appendLiteral(": "); callFrameBuilder.append(functionName); callFrameBuilder.append('('); appendURLAndPosition(callFrameBuilder, callFrame.sourceURL(), callFrame.lineNumber(), callFrame.columnNumber()); callFrameBuilder.append(')'); WTFLogAlways("%s", callFrameBuilder.toString().utf8().data()); } } }
void Console::profile(const String& title, ScriptState* state) { Page* page = this->page(); if (!page) return; // FIXME: log a console message when profiling is disabled. if (!InspectorInstrumentation::profilerEnabled(page)) return; String resolvedTitle = title; if (title.isNull()) // no title so give it the next user initiated profile title. resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfileName(page, true); ScriptProfiler::start(state, resolvedTitle); RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, 1)); const ScriptCallFrame& lastCaller = callStack->at(0); InspectorInstrumentation::addStartProfilingMessageToConsole(page, resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL()); }
void Console::addMessage(MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArguments, bool printTrace) { RefPtr<ScriptArguments> arguments = prpArguments; Page* page = this->page(); if (!page) return; if (!acceptNoArguments && !arguments->argumentCount()) return; size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); const ScriptCallFrame& lastCaller = callStack->at(0); if (shouldPrintExceptions()) { printSourceURLAndLine(lastCaller.sourceURL(), 0); printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level); for (unsigned i = 0; i < arguments->argumentCount(); ++i) { String argAsString; if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString)) printf(" %s", argAsString.utf8().data()); } printf("\n"); } if (printTrace) { printf("Stack Trace\n"); for (unsigned i = 0; i < callStack->size(); ++i) { String functionName = String(callStack->at(i).functionName()); printf("\t%s\n", functionName.utf8().data()); } } String message; if (arguments->getFirstArgumentAsString(message)) page->chrome()->client()->addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments.release()); }
static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArguments = false, bool printTrace = false) { RefPtr<ScriptArguments> arguments = prpArguments; if (!page) return; if (!acceptNoArguments && !arguments->argumentCount()) return; size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); const ScriptCallFrame& lastCaller = callStack->at(0); String message; bool gotMessage = arguments->getFirstArgumentAsString(message); InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); if (gotMessage) page->chrome()->client()->addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); }
void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, PassRefPtr<Inspector::ScriptArguments> prpArguments) { RefPtr<ScriptArguments> arguments = prpArguments; String message; bool gotMessage = arguments->getFirstArgumentAsString(message); InspectorInstrumentation::addMessageToConsole(&m_page, MessageSource::ConsoleAPI, type, level, message, exec, arguments); if (m_page.usesEphemeralSession()) return; if (gotMessage) { size_t stackSize = type == MessageType::Trace ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, stackSize)); const ScriptCallFrame& lastCaller = callStack->at(0); m_page.chrome().client().addMessageToConsole(MessageSource::ConsoleAPI, type, level, message, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL()); } if (m_page.settings().logsPageMessagesToSystemConsoleEnabled() || PageConsoleClient::shouldPrintExceptions()) ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, exec, arguments.release()); }
void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); const ScriptCallFrame& lastCaller = callStack->at(0); // Follow Firebug's behavior of counting with null and undefined title in // the same bucket as no argument String title; arguments->getFirstArgumentAsString(title); String identifier = title + '@' + lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber()); HashMap<String, unsigned>::iterator it = m_counts.find(identifier); int count; if (it == m_counts.end()) count = 1; else { count = it->value + 1; m_counts.remove(it); } m_counts.add(identifier, count); String message = title + ": " + String::number(count); addMessageToConsole(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, callStack); }
void Console::timeEnd(JSC::ExecState* state, const String& title) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release()); }
void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1)); m_consoleAgent->stopTiming(title, WTF::move(callStack)); }
void Console::timeEnd(ScriptState* state, const String& title) { TRACE_EVENT_COPY_ASYNC_END0("webkit", title.utf8().data(), this); RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release()); }
void JSConsoleClient::timeEnd(ExecState* exec, const String& title) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1)); m_consoleAgent->stopTiming(title, callStack.release()); }
void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title) { RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1)); InspectorInstrumentation::stopConsoleTiming(&m_page.mainFrame(), title, callStack.release()); }