Commit 379c8a1f authored by joepeck@webkit.org's avatar joepeck@webkit.org

Web Inspector: ConsoleMessage should include line and column number where possible

https://bugs.webkit.org/show_bug.cgi?id=114929

Source/WebCore:

  - adds "m_column" to WebCore::ConsoleMessage
  - adds "column" to Console.ConsoleMessage in the inspector protocol
  - set the column number for console.* functions (Console.cpp)
  - set the column number for XSLT errors (XSLTProcessor)
  - plumb columnNumber everywhere else it is needed, set it to 0 and file
    bugs for all cases missing columnNumber that could provide it.

Reviewed by Timothy Hatcher.

Test: inspector/console/console-url-line-column.html
      inspector/console/console-messages-stack-traces.html

* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::ConsoleMessage):
(WebCore::ConsoleMessage::autogenerateMetadata):
(WebCore::ConsoleMessage::addToFrontend):
(WebCore::ConsoleMessage::isEqual):
Add m_column and set it where appropriate.

* inspector/Inspector.json:
Add column property to Console.ConsoleMessage.

* page/Console.cpp:
(WebCore::internalAddMessage):
(WebCore::Console::profile):
Set columnNumber like lineNumber from the last stack frame.
(WebCore::Console::groupEnd):
Line and column are unused in this message type, set both to 0.

* xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::parseErrorFunc):
* xml/XSLTProcessorQt.cpp:
(WebCore::XSLTMessageHandler::handleMessage):
Add real column numbers, the XSLT handlers already had it available.

* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* css/CSSParser.cpp:
(WebCore::CSSParser::logError):
* dom/ScriptExecutionContext.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::addConsoleMessage):
* dom/Document.cpp:
(WebCore::Document::logExceptionToConsole):
(WebCore::Document::addMessage):
* dom/Document.h:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::addMessageToConsole):
(WebCore::InspectorConsoleAgent::stopTiming):
(WebCore::InspectorConsoleAgent::didFinishXHRLoading):
(WebCore::InspectorConsoleAgent::didReceiveResponse):
(WebCore::InspectorConsoleAgent::didFailLoading):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorConsoleInstrumentation.h:
(WebCore::InspectorInstrumentation::addMessageToConsole):
(WebCore::InspectorInstrumentation::addStartProfilingMessageToConsole):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::addMessageToConsoleImpl):
(WebCore::InspectorInstrumentation::addStartProfilingMessageToConsoleImpl):
(WebCore::InspectorInstrumentation::addProfileImpl):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::addProfile):
(WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole):
(WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole):
(WebCore::InspectorProfilerAgent::start):
(WebCore::InspectorProfilerAgent::stop):
* inspector/InspectorProfilerAgent.h:
(InspectorProfilerAgent):
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::addMessageToConsole):
* page/ChromeClient.h:
(WebCore::ChromeClient::addMessageToConsole):
* page/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::logToConsole):
* page/PageConsole.cpp:
(WebCore::PageConsole::addMessage):
* page/PageConsole.h:
* workers/DefaultSharedWorkerRepository.cpp:
(SharedWorkerProxy):
(WebCore::postExceptionTask):
(WebCore::SharedWorkerProxy::postExceptionToWorkerObject):
(WebCore::postConsoleMessageTask):
(WebCore::SharedWorkerProxy::postConsoleMessageToWorkerObject):
* workers/SharedWorkerContext.cpp:
(WebCore::SharedWorkerContext::logExceptionToConsole):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::logExceptionToConsole):
(WebCore::WorkerContext::addConsoleMessage):
(WebCore::WorkerContext::addMessage):
(WebCore::WorkerContext::addMessageToWorkerConsole):
* workers/WorkerContext.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerExceptionTask::create):
(WebCore::WorkerExceptionTask::WorkerExceptionTask):
(WebCore::WorkerExceptionTask::performTask):
(WorkerExceptionTask):
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
(WebCore::postConsoleMessageTask):
(WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
* workers/WorkerMessagingProxy.h:
(WorkerMessagingProxy):
* workers/WorkerReportingProxy.h:
(WorkerReportingProxy):
Plumb columnNumber through where appropriate. File bugs where missing.

Source/WebKit/blackberry:

Reviewed by Timothy Hatcher.

* Api/DumpRenderTreeClient.h:
* Api/WebPageClient.h:
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::addMessageToConsole):
* WebCoreSupport/ChromeClientBlackBerry.h:
(ChromeClientBlackBerry):

Source/WebKit/efl:

Reviewed by Timothy Hatcher.

* WebCoreSupport/ChromeClientEfl.cpp:
(WebCore::ChromeClientEfl::addMessageToConsole):
* WebCoreSupport/ChromeClientEfl.h:
(ChromeClientEfl):

Source/WebKit/gtk:

Reviewed by Timothy Hatcher.

* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::addMessageToConsole):
* WebCoreSupport/ChromeClientGtk.h:
(ChromeClient):

Source/WebKit/mac:

Reviewed by Timothy Hatcher.

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::addMessageToConsole):

Source/WebKit/qt:

Reviewed by Timothy Hatcher.

* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::addMessageToConsole):
* WebCoreSupport/ChromeClientQt.h:

Source/WebKit/win:

Reviewed by Timothy Hatcher.

* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::addMessageToConsole):
* WebCoreSupport/WebChromeClient.h:

Source/WebKit/wince:

Reviewed by Timothy Hatcher.

* WebCoreSupport/ChromeClientWinCE.cpp:
(WebKit::ChromeClientWinCE::addMessageToConsole):
* WebCoreSupport/ChromeClientWinCE.h:

Source/WebKit2:

Reviewed by Timothy Hatcher.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::addMessageToConsole):
* WebProcess/WebCoreSupport/WebChromeClient.h:

LayoutTests:

Update a test that was outputting the url and line number of console
method calls, to output the column number as well. Added a test that
verifies that console API messages have stack traces if appropriate.

Reviewed by Timothy Hatcher.

* inspector/console/console-url-and-line-expected.txt: Removed.
* inspector/console/console-url-line-column-expected.txt: Added.
* inspector/console/console-url-line-column.html: Renamed from LayoutTests/inspector/console/console-url-and-line.html.
* inspector/console/console-messages-stack-traces-expected.txt: Added.
* inspector/console/console-messages-stack-traces.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149125 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c79cd825
2013-04-25 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: ConsoleMessage should include line and column number where possible
https://bugs.webkit.org/show_bug.cgi?id=114929
Update a test that was outputting the url and line number of console
method calls, to output the column number as well. Added a test that
verifies that console API messages have stack traces if appropriate.
Reviewed by Timothy Hatcher.
* inspector/console/console-url-and-line-expected.txt: Removed.
* inspector/console/console-url-line-column-expected.txt: Added.
* inspector/console/console-url-line-column.html: Renamed from LayoutTests/inspector/console/console-url-and-line.html.
* inspector/console/console-messages-stack-traces-expected.txt: Added.
* inspector/console/console-messages-stack-traces.html: Added.
2013-04-25 Lamarque V. Souza <Lamarque.Souza@basyskom.com>
Sec-WebSocket-Extensions header field must not appear more than once in an HTTP response.
......
CONSOLE MESSAGE: line 17: log
CONSOLE MESSAGE: line 18: info
CONSOLE MESSAGE: line 19: warn
CONSOLE MESSAGE: line 20: debug
CONSOLE MESSAGE: line 21: error
CONSOLE MESSAGE: line 22: assert
CONSOLE MESSAGE: line 23: trace
CONSOLE MESSAGE: line 24: 1,2,3
CONSOLE MESSAGE: line 25: [object HTMLBodyElement]
CONSOLE MESSAGE: line 31: MARKER: EXPECT NO STACK TRACES
CONSOLE MESSAGE: line 35: MARKER: DONE
Tests that console-api messages contain stack traces.
SUCCESS
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function performConsoleMessages() {
// No console message.
console.timeStamp();
console.markTimeline();
// Expected to have stack traces.
console.time("time"); // Nothing until timeEnd.
console.clear();
console.group("group");
console.profile("profile");
console.log("log");
console.info("info");
console.warn("warn");
console.error("debug");
console.error("error");
console.assert(false, "assert");
console.trace("trace");
console.dir([1,2,3]);
console.dirxml(document.body);
console.count("count");
console.profileEnd("profile");
console.timeEnd("time");
// Not expected to have stack traces.
console.log("MARKER: EXPECT NO STACK TRACES");
console.groupEnd("group");
// End the test
console.log("MARKER: DONE");
}
function test()
{
InspectorTest.addSniffer(WebInspector.ConsoleDispatcher.prototype, "messageAdded", messageAdded, true);
var hadIssue = false;
var expectStackTraces = true;
function messageAdded(payload)
{
if (payload.level === "log") {
if (payload.text === "MARKER: DONE") {
InspectorTest.addResult(hadIssue ? "FAILURE" : "SUCCESS");
InspectorTest.completeTest();
return;
}
if (payload.text === "MARKER: EXPECT NO STACK TRACES") {
expectStackTraces = false;
return;
}
}
var url = payload.url;
var lastSlashIndex = url.lastIndexOf("/");
url = url.substring(lastSlashIndex + 1);
if ("stackTrace" in payload && !expectStackTraces) {
InspectorTest.addResult("Unexpected stack trace for: " + JSON.stringify(payload));
hadIssue = true;
} else if (!("stackTrace" in payload) && expectStackTraces) {
InspectorTest.addResult("Expected stack trace for: " + JSON.stringify(payload));
hadIssue = true;
}
}
InspectorTest.evaluateInPage("performConsoleMessages()");
}
</script>
</head>
<body onload="runTest()">
<p>Tests that console-api messages contain stack traces.</p>
</body>
</html>
CONSOLE MESSAGE: line 9: one
CONSOLE MESSAGE: line 10: two
CONSOLE MESSAGE: line 11: three
Tests that console's url and line properties are defiend for console.log entries. Bug 72256.
Message at location: console-url-and-line.html:9
Message at location: console-url-and-line.html:10
Message at location: console-url-and-line.html:11
CONSOLE MESSAGE: line 9: one
CONSOLE MESSAGE: line 10: two
CONSOLE MESSAGE: line 11: three
CONSOLE MESSAGE: line 14: error
CONSOLE MESSAGE: line 14: log
CONSOLE MESSAGE: line 15: info
CONSOLE MESSAGE: line 15: warn
CONSOLE MESSAGE: line 16: assert
Tests that url, line, and column properties are defined for console functions.
Message at location: console-url-line-column.html:9:15
Message at location: console-url-line-column.html:10:15
Message at location: console-url-line-column.html:11:15
Message at location: console-url-line-column.html:14:17
Message at location: console-url-line-column.html:14:39
Message at location: console-url-line-column.html:15:16
Message at location: console-url-line-column.html:15:38
Message at location: console-url-line-column.html:16:18
......@@ -9,6 +9,11 @@ function log() {
console.log("one");
console.log("two");
console.log("three");
// Different types and different columns.
console.error("error"); console.log("log");
console.info("info"); console.warn("warn");
console.assert(false, "assert");
}
function test()
......@@ -20,8 +25,8 @@ function test()
var url = payload.url;
var lastSlashIndex = url.lastIndexOf("/");
url = url.substring(lastSlashIndex + 1);
InspectorTest.addResult("Message at location: " + url + ":" + payload.line);
if (payload.line === 10)
InspectorTest.addResult("Message at location: " + url + ":" + payload.line + ":" + payload.column);
if (payload.line === 16)
InspectorTest.completeTest();
}
......@@ -33,7 +38,7 @@ function test()
<body onload="runTest()">
<p>
Tests that console's url and line properties are defiend for console.log entries. Bug 72256.
Tests that url, line, and column properties are defined for console functions.
</p>
</body>
......
2013-04-25 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: ConsoleMessage should include line and column number where possible
https://bugs.webkit.org/show_bug.cgi?id=114929
- adds "m_column" to WebCore::ConsoleMessage
- adds "column" to Console.ConsoleMessage in the inspector protocol
- set the column number for console.* functions (Console.cpp)
- set the column number for XSLT errors (XSLTProcessor)
- plumb columnNumber everywhere else it is needed, set it to 0 and file
bugs for all cases missing columnNumber that could provide it.
Reviewed by Timothy Hatcher.
Test: inspector/console/console-url-line-column.html
inspector/console/console-messages-stack-traces.html
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::ConsoleMessage):
(WebCore::ConsoleMessage::autogenerateMetadata):
(WebCore::ConsoleMessage::addToFrontend):
(WebCore::ConsoleMessage::isEqual):
Add m_column and set it where appropriate.
* inspector/Inspector.json:
Add column property to Console.ConsoleMessage.
* page/Console.cpp:
(WebCore::internalAddMessage):
(WebCore::Console::profile):
Set columnNumber like lineNumber from the last stack frame.
(WebCore::Console::groupEnd):
Line and column are unused in this message type, set both to 0.
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::parseErrorFunc):
* xml/XSLTProcessorQt.cpp:
(WebCore::XSLTMessageHandler::handleMessage):
Add real column numbers, the XSLT handlers already had it available.
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* css/CSSParser.cpp:
(WebCore::CSSParser::logError):
* dom/ScriptExecutionContext.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::addConsoleMessage):
* dom/Document.cpp:
(WebCore::Document::logExceptionToConsole):
(WebCore::Document::addMessage):
* dom/Document.h:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::addMessageToConsole):
(WebCore::InspectorConsoleAgent::stopTiming):
(WebCore::InspectorConsoleAgent::didFinishXHRLoading):
(WebCore::InspectorConsoleAgent::didReceiveResponse):
(WebCore::InspectorConsoleAgent::didFailLoading):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorConsoleInstrumentation.h:
(WebCore::InspectorInstrumentation::addMessageToConsole):
(WebCore::InspectorInstrumentation::addStartProfilingMessageToConsole):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::addMessageToConsoleImpl):
(WebCore::InspectorInstrumentation::addStartProfilingMessageToConsoleImpl):
(WebCore::InspectorInstrumentation::addProfileImpl):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::addProfile):
(WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole):
(WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole):
(WebCore::InspectorProfilerAgent::start):
(WebCore::InspectorProfilerAgent::stop):
* inspector/InspectorProfilerAgent.h:
(InspectorProfilerAgent):
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::addMessageToConsole):
* page/ChromeClient.h:
(WebCore::ChromeClient::addMessageToConsole):
* page/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::logToConsole):
* page/PageConsole.cpp:
(WebCore::PageConsole::addMessage):
* page/PageConsole.h:
* workers/DefaultSharedWorkerRepository.cpp:
(SharedWorkerProxy):
(WebCore::postExceptionTask):
(WebCore::SharedWorkerProxy::postExceptionToWorkerObject):
(WebCore::postConsoleMessageTask):
(WebCore::SharedWorkerProxy::postConsoleMessageToWorkerObject):
* workers/SharedWorkerContext.cpp:
(WebCore::SharedWorkerContext::logExceptionToConsole):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::logExceptionToConsole):
(WebCore::WorkerContext::addConsoleMessage):
(WebCore::WorkerContext::addMessage):
(WebCore::WorkerContext::addMessageToWorkerConsole):
* workers/WorkerContext.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerExceptionTask::create):
(WebCore::WorkerExceptionTask::WorkerExceptionTask):
(WebCore::WorkerExceptionTask::performTask):
(WorkerExceptionTask):
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
(WebCore::postConsoleMessageTask):
(WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
* workers/WorkerMessagingProxy.h:
(WorkerMessagingProxy):
* workers/WorkerReportingProxy.h:
(WorkerReportingProxy):
Plumb columnNumber through where appropriate. File bugs where missing.
2013-04-25 Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] Animated opacity does not trigger accelerated compositing
......
......@@ -78,7 +78,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
if (callType == CallTypeNone) {
callType = m_customResolver->methodTable()->getCallData(m_customResolver.get(), callData);
if (callType == CallTypeNone) {
// FIXME: Pass actual line number and source URL.
// FIXME: <http://webkit.org/b/114312> JSCustomXPathNSResolver::lookupNamespaceURI Console Message should include Line, Column, and SourceURL
if (PageConsole* console = m_globalObject->impl()->pageConsole())
console->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return String();
......
......@@ -11510,8 +11510,9 @@ bool CSSParser::isLoggingErrors()
void CSSParser::logError(const String& message, int lineNumber)
{
// FIXME: <http://webkit.org/b/114313> CSS Parser ConsoleMessage errors should include column numbers
PageConsole* console = m_styleSheet->singleOwnerDocument()->page()->console();
console->addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleSheet->baseURL().string(), lineNumber + 1);
console->addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleSheet->baseURL().string(), lineNumber + 1, 0);
}
StyleRuleKeyframes* CSSParser::createKeyframesRule(const String& name, PassOwnPtr<Vector<RefPtr<StyleKeyframe> > > popKeyframes)
......
......@@ -2657,7 +2657,7 @@ EventTarget* Document::errorEventTarget()
void Document::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack)
{
addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, callStack);
addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, 0, callStack);
}
void Document::setURL(const KURL& url)
......@@ -4843,7 +4843,7 @@ void Document::addConsoleMessage(MessageSource source, MessageLevel level, const
page->console()->addMessage(source, level, message, requestIdentifier, this);
}
void Document::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier)
void Document::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier)
{
if (!isContextThread()) {
postTask(AddConsoleMessageTask::create(source, level, message));
......@@ -4851,7 +4851,7 @@ void Document::addMessage(MessageSource source, MessageLevel level, const String
}
if (Page* page = this->page())
page->console()->addMessage(source, level, message, sourceURL, lineNumber, callStack, state, requestIdentifier);
page->console()->addMessage(source, level, message, sourceURL, lineNumber, columnNumber, callStack, state, requestIdentifier);
}
const SecurityOrigin* Document::topOrigin() const
......
......@@ -1248,7 +1248,7 @@ private:
virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls.
virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0);
virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0);
virtual double minimumTimerInterval() const;
......
......@@ -302,9 +302,9 @@ void ScriptExecutionContext::reportException(const String& errorMessage, int lin
m_pendingExceptions.clear();
}
void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier)
void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier)
{
addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestIdentifier);
addMessage(source, level, message, sourceURL, lineNumber, columnNumber, 0, state, requestIdentifier);
}
bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL, CachedScript* cachedScript)
......
......@@ -76,9 +76,10 @@ public:
virtual void disableEval(const String& errorMessage) = 0;
bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sourceURL, CachedScript* = 0);
// FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number
void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0);
void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
virtual const SecurityOrigin* topOrigin() const = 0;
......@@ -182,8 +183,9 @@ private:
virtual const KURL& virtualURL() const = 0;
virtual KURL virtualCompleteURL(const String&) const = 0;
virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0) = 0;
virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0) = 0;
virtual EventTarget* errorEventTarget() = 0;
// FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number
virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0;
bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL, CachedScript*);
......
......@@ -56,19 +56,21 @@ ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source,
, m_message(message)
, m_url()
, m_line(0)
, m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
{
autogenerateMetadata(canGenerateCallStack);
}
ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, ScriptState* state, unsigned long requestIdentifier)
ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, ScriptState* state, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
, m_message(message)
, m_url(url)
, m_line(line)
, m_column(column)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
{
......@@ -82,6 +84,7 @@ ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, Mes
, m_message(message)
, m_arguments(0)
, m_line(0)
, m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
{
......@@ -89,6 +92,7 @@ ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, Mes
const ScriptCallFrame& frame = callStack->at(0);
m_url = frame.sourceURL();
m_line = frame.lineNumber();
m_column = frame.columnNumber();
}
m_callStack = callStack;
}
......@@ -101,6 +105,7 @@ ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source,
, m_arguments(arguments)
, m_url()
, m_line(0)
, m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
{
......@@ -127,6 +132,7 @@ void ConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, ScriptState
const ScriptCallFrame& frame = m_callStack->at(0);
m_url = frame.sourceURL();
m_line = frame.lineNumber();
m_column = frame.columnNumber();
return;
}
......@@ -191,6 +197,7 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
// 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 == NetworkMessageSource && !m_requestId.isEmpty())
......@@ -255,6 +262,7 @@ bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
&& msg->m_level == m_level
&& msg->m_message == m_message
&& msg->m_line == m_line
&& msg->m_column == m_column
&& msg->m_url == m_url
&& msg->m_requestId == m_requestId;
}
......
......@@ -53,7 +53,7 @@ class ConsoleMessage {
WTF_MAKE_NONCOPYABLE(ConsoleMessage); WTF_MAKE_FAST_ALLOCATED;
public:
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, unsigned long requestIdentifier = 0);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, ScriptState* = 0, unsigned long requestIdentifier = 0);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, ScriptState* = 0, unsigned long requestIdentifier = 0);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, ScriptState*, unsigned long requestIdentifier = 0);
~ConsoleMessage();
......@@ -82,6 +82,7 @@ private:
RefPtr<ScriptCallStack> m_callStack;
String m_url;
unsigned m_line;
unsigned m_column;
unsigned m_repeatCount;
String m_requestId;
};
......
......@@ -766,6 +766,7 @@
{ "name": "type", "type": "string", "optional": true, "enum": ["log", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "timing", "profile", "profileEnd"], "description": "Console message type." },
{ "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." },
{ "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message." },
{ "name": "column", "type": "integer", "optional": true, "description": "Column number on the line in the resource that generated this message." },
{ "name": "repeatCount", "type": "integer", "optional": true, "description": "Repeat count for repeated messages." },
{ "name": "parameters", "type": "array", "items": { "$ref": "Runtime.RemoteObject" }, "optional": true, "description": "Message parameters in case of the formatted message." },
{ "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." },
......
......@@ -178,7 +178,7 @@ void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageTyp
addConsoleMessage(adoptPtr(new ConsoleMessage(!isWorkerAgent(), source, type, level, message, arguments, state, requestIdentifier)));
}
void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier)
void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier)
{
if (!developerExtrasEnabled())
return;
......@@ -193,7 +193,7 @@ void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageTyp
return;
bool canGenerateCallStack = !isWorkerAgent() && m_frontend;
addConsoleMessage(adoptPtr(new ConsoleMessage(canGenerateCallStack, source, type, level, message, scriptId, lineNumber, state, requestIdentifier)));
addConsoleMessage(adoptPtr(new ConsoleMessage(canGenerateCallStack, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier)));
}
Vector<unsigned> InspectorConsoleAgent::consoleMessageArgumentCounts()
......@@ -230,8 +230,7 @@ void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCal
double elapsed = monotonicallyIncreasingTime() - startTime;
String message = title + String::format(": %.3fms", elapsed * 1000);
const ScriptCallFrame& lastCaller = callStack->at(0);
addMessageToConsole(ConsoleAPIMessageSource, TimingMessageType, DebugMessageLevel, message, lastCaller.sourceURL(), lastCaller.lineNumber());
addMessageToConsole(ConsoleAPIMessageSource, TimingMessageType, DebugMessageLevel, message, callStack);
}
void InspectorConsoleAgent::count(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
......@@ -273,10 +272,9 @@ void InspectorConsoleAgent::didFinishXHRLoading(unsigned long requestIdentifier,
return;
if (m_frontend && m_state->getBoolean(ConsoleAgentState::monitoringXHR)) {
String message = "XHR finished loading: \"" + url + "\".";
addMessageToConsole(NetworkMessageSource, LogMessageType, DebugMessageLevel, message, sendURL, sendLineNumber, 0, requestIdentifier);
// FIXME: <http://webkit.org/b/114316> InspectorConsoleAgent::didFinishXHRLoading ConsoleMessage should include a column number
addMessageToConsole(NetworkMessageSource, LogMessageType, DebugMessageLevel, message, sendURL, sendLineNumber, 0, 0, requestIdentifier);
}
}
void InspectorConsoleAgent::didReceiveResponse(unsigned long requestIdentifier, const ResourceResponse& response)
......@@ -286,7 +284,7 @@ void InspectorConsoleAgent::didReceiveResponse(unsigned long requestIdentifier,
if (response.httpStatusCode() >= 400) {
String message = "Failed to load resource: the server responded with a status of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusText() + ')';
addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message, response.url().string(), 0, 0, requestIdentifier);
addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message, response.url().string(), 0, 0, 0, requestIdentifier);
}
}
......@@ -302,7 +300,7 @@ void InspectorConsoleAgent::didFailLoading(unsigned long requestIdentifier, cons
message.appendLiteral(": ");
message.append(error.localizedDescription());
}
addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, requestIdentifier);
addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, 0, requestIdentifier);
}
void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled)
......
......@@ -71,7 +71,7 @@ public:
virtual void restore();
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, ScriptState*, PassRefPtr<ScriptArguments>, unsigned long requestIdentifier = 0);
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
// FIXME: Remove once we no longer generate stacks outside of Inspector.
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);
......@@ -88,8 +88,8 @@ public:
void didReceiveResponse(unsigned long requestIdentifier, const ResourceResponse&);
void didFailLoading(unsigned long requestIdentifier, const ResourceError&);
#if ENABLE(JAVASCRIPT_DEBUGGER)
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, unsigned columnNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, unsigned columnNumber, const String& sourceURL);
#endif
virtual void setMonitoringXHREnabled(ErrorString*, bool enabled);
virtual void addInspectedNode(ErrorString*, int nodeId) = 0;
......
......@@ -73,11 +73,11 @@ inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSou
#endif
}
inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier)
inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier)
{
#if ENABLE(INSPECTOR)
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, state, requestIdentifier);
addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier);
#else
UNUSED_PARAM(page);
UNUSED_PARAM(source);
......@@ -108,11 +108,11 @@ inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerC
#endif
}
inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier)
inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier)
{
#if ENABLE(INSPECTOR)
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForWorkerContext(workerContext))
addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, state, requestIdentifier);
addMessageToConsoleImpl(instrumentingAgents, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier);
#else
UNUSED_PARAM(workerContext);
UNUSED_PARAM(source);
......@@ -121,6 +121,7 @@ inline void InspectorInstrumentation::addMessageToConsole(WorkerContext* workerC
UNUSED_PARAM(message);
UNUSED_PARAM(scriptId);
UNUSED_PARAM(lineNumber);
UNUSED_PARAM(columnNumber);
UNUSED_PARAM(state);
UNUSED_PARAM(requestIdentifier);
#endif
......@@ -175,15 +176,16 @@ inline void InspectorInstrumentation::consoleTimeStamp(Frame* frame, PassRefPtr<
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* page, const String& title, unsigned lineNumber, const String& sourceURL)
inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* page, const String& title, unsigned lineNumber, unsigned columnNumber, const String& sourceURL)
{
#if ENABLE(INSPECTOR)
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
addStartProfilingMessageToConsoleImpl(instrumentingAgents, title, lineNumber, sourceURL);
addStartProfilingMessageToConsoleImpl(instrumentingAgents, title, lineNumber, columnNumber, sourceURL);
#else
UNUSED_PARAM(page);