https://bugs.webkit.org/show_bug.cgi?id=67399
Reviewed by Pavel Feldman.
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::ConsoleMessage):
* inspector/ConsoleMessage.h:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl):
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessage.prototype._formatMessage.else.else.linkifier):
(WebInspector.ConsoleMessage.prototype._formatMessage):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.showAnchorLocation):
* inspector/front-end/inspector.js:
(WebInspector.linkifyStringAsFragmentWithCustomLinkifier):
(WebInspector.linkifyStringAsFragment):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95984
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-26 Vsevolod Vlasov <vsevik@chromium.org>
+
+ Web Inspector: XMLHttpRequest console logging messages should link to network panel when possible.
+ https://bugs.webkit.org/show_bug.cgi?id=67399
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/ConsoleMessage.cpp:
+ (WebCore::ConsoleMessage::ConsoleMessage):
+ * inspector/ConsoleMessage.h:
+ * inspector/InspectorConsoleAgent.cpp:
+ (WebCore::InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest):
+ * inspector/InspectorConsoleAgent.h:
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl):
+ * inspector/front-end/ConsoleMessage.js:
+ (WebInspector.ConsoleMessage.prototype._formatMessage.else.else.linkifier):
+ (WebInspector.ConsoleMessage.prototype._formatMessage):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.ResourcesPanel.prototype.showAnchorLocation):
+ * inspector/front-end/inspector.js:
+ (WebInspector.linkifyStringAsFragmentWithCustomLinkifier):
+ (WebInspector.linkifyStringAsFragment):
+
2011-09-26 Jer Noble <jer.noble@apple.com>
White flash when entering full-screen using element.webkitRequestFullScreen()
namespace WebCore {
-ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u)
+ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, const String& requestId)
: m_source(s)
, m_type(t)
, m_level(l)
, m_line(li)
, m_url(u)
, m_repeatCount(1)
+ , m_requestId(requestId)
{
}
class ConsoleMessage {
WTF_MAKE_NONCOPYABLE(ConsoleMessage); WTF_MAKE_FAST_ALLOCATED;
public:
- ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u);
+ ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, const String& requestId = String());
ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, const String& responseUrl, const String& requestId);
~ConsoleMessage();
m_injectedScriptManager->discardInjectedScriptsFor(window);
}
-void InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber)
+void InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& url, const String& sendURL, unsigned sendLineNumber)
{
if (!m_inspectorAgent->enabled())
return;
- if (m_inspectorState->getBoolean(ConsoleAgentState::monitoringXHR))
- addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL);
+ if (m_frontend && m_inspectorState->getBoolean(ConsoleAgentState::monitoringXHR)) {
+ String message = "XHR finished loading: \"" + url + "\".";
+ String requestId = IdentifiersFactory::requestId(identifier);
+ addConsoleMessage(adoptPtr(new ConsoleMessage(NetworkMessageSource, LogMessageType, LogMessageLevel, message, sendLineNumber, sendURL, requestId)));
+ }
+
+
}
void InspectorConsoleAgent::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
void frameWindowDiscarded(DOMWindow*);
- void resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber);
+ void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& url, const String& sendURL, unsigned sendLineNumber);
void didReceiveResponse(unsigned long identifier, const ResourceResponse&);
void didFailLoading(unsigned long identifier, const ResourceError&);
#if ENABLE(JAVASCRIPT_DEBUGGER)
void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
{
if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
- consoleAgent->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber);
+ consoleAgent->resourceRetrievedByXMLHttpRequest(identifier, url, sendURL, sendLineNumber);
if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
resourceAgent->setInitialXHRContent(identifier, sourceString);
}
}
} else if (this.source === WebInspector.ConsoleMessage.MessageSource.Network) {
if (this._request) {
- this._stackTrace = this._request.stackTrace;
- messageText = document.createElement("span");
- messageText.appendChild(document.createTextNode(this._request.requestMethod + " "));
- var anchor = WebInspector.linkifyURLAsNode(this._request.url);
- anchor.setAttribute("request_id", this._request.requestId);
- anchor.setAttribute("preferred_panel", "network");
- messageText.appendChild(anchor);
- if (this._request.failed)
- messageText.appendChild(document.createTextNode(" " + this._request.localizedFailDescription));
- else
- messageText.appendChild(document.createTextNode(" " + this._request.statusCode + " (" + this._request.statusText + ")"));
+ if (this.level === WebInspector.ConsoleMessage.MessageLevel.Error) {
+ this._stackTrace = this._request.stackTrace;
+ messageText = document.createElement("span");
+ messageText.appendChild(document.createTextNode(this._request.requestMethod + " "));
+ var anchor = WebInspector.linkifyURLAsNode(this._request.url);
+ anchor.setAttribute("request_id", this._request.requestId);
+ anchor.setAttribute("preferred_panel", "network");
+ messageText.appendChild(anchor);
+ if (this._request.failed)
+ messageText.appendChild(document.createTextNode(" " + this._request.localizedFailDescription));
+ else
+ messageText.appendChild(document.createTextNode(" " + this._request.statusCode + " (" + this._request.statusText + ")"));
+ } else {
+ messageText = document.createElement("span");
+
+ function linkifier(title, url, lineNumber)
+ {
+ var isExternal = !this._request;
+ var anchor = WebInspector.linkifyURLAsNode(url, title, null, isExternal);
+ if (this._request) {
+ anchor.setAttribute("request_id", this._request.requestId);
+ anchor.setAttribute("preferred_panel", "network");
+ }
+ return anchor;
+ }
+
+ var fragment = WebInspector.linkifyStringAsFragmentWithCustomLinkifier(this._messageText, linkifier.bind(this));
+ messageText.appendChild(fragment);
+ }
} else {
var isExternal = !WebInspector.resourceForURL(this.url);
var anchor = WebInspector.linkifyURLAsNode(this.url, this.url, "console-message-url", isExternal);
showAnchorLocation: function(anchor)
{
var resource = WebInspector.resourceForURL(anchor.href);
- if (resource.type === WebInspector.Resource.Type.XHR) {
- // Show XHRs in the network panel only.
- if (WebInspector.panels.network && WebInspector.panels.network.canShowAnchorLocation(anchor)) {
- WebInspector.setCurrentPanel(WebInspector.panels.network);
- WebInspector.panels.network.showAnchorLocation(anchor);
- }
- return;
- }
var lineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number")) : undefined;
this.showResource(resource, lineNumber);
},
return true;
}
-WebInspector.linkifyStringAsFragment = function(string)
+WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linkifier)
{
var container = document.createDocumentFragment();
var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|www\.)[\w$\-_+*'=\|\/\\(){}[\]%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({%@&#~]/;
break;
linkString = linkString[0];
- var title = linkString;
var linkIndex = string.indexOf(linkString);
var nonLink = string.substring(0, linkIndex);
container.appendChild(document.createTextNode(nonLink));
- var profileStringMatches = WebInspector.ProfileType.URLRegExp.exec(title);
- if (profileStringMatches)
- title = WebInspector.panels.profiles.displayTitleForProfileLink(profileStringMatches[2], profileStringMatches[1]);
-
+ var title = linkString;
var realURL = (linkString.indexOf("www.") === 0 ? "http://" + linkString : linkString);
var lineColumnMatch = lineColumnRegEx.exec(realURL);
if (lineColumnMatch)
realURL = realURL.substring(0, realURL.length - lineColumnMatch[0].length);
- var hasResourceWithURL = !!WebInspector.resourceForURL(realURL);
- var urlNode = WebInspector.linkifyURLAsNode(realURL, title, null, hasResourceWithURL);
- container.appendChild(urlNode);
- if (lineColumnMatch) {
- urlNode.setAttribute("line_number", lineColumnMatch[1]);
- urlNode.setAttribute("preferred_panel", "scripts");
- }
+ var linkNode = linkifier(title, realURL, lineColumnMatch ? lineColumnMatch[1] : undefined);
+ container.appendChild(linkNode);
string = string.substring(linkIndex + linkString.length, string.length);
}
return container;
}
+WebInspector.linkifyStringAsFragment = function(string)
+{
+ function linkifier(title, url, lineNumber)
+ {
+ var profileStringMatches = WebInspector.ProfileType.URLRegExp.exec(title);
+ if (profileStringMatches)
+ title = WebInspector.panels.profiles.displayTitleForProfileLink(profileStringMatches[2], profileStringMatches[1]);
+
+ var isExternal = !WebInspector.resourceForURL(url);
+ var urlNode = WebInspector.linkifyURLAsNode(url, title, null, isExternal);
+ if (typeof(lineNumber) !== "undefined") {
+ urlNode.setAttribute("line_number", lineNumber);
+ urlNode.setAttribute("preferred_panel", "scripts");
+ }
+
+ return urlNode;
+ }
+
+ return WebInspector.linkifyStringAsFragmentWithCustomLinkifier(string, linkifier);
+}
+
WebInspector.showProfileForURL = function(url)
{
WebInspector.showPanel("profiles");