Modified: trunk/Source/WebInspectorUI/UserInterface/FrameResourceManager.js (156283 => 156284)
--- trunk/Source/WebInspectorUI/UserInterface/FrameResourceManager.js 2013-09-23 19:27:15 UTC (rev 156283)
+++ trunk/Source/WebInspectorUI/UserInterface/FrameResourceManager.js 2013-09-23 19:27:38 UTC (rev 156284)
@@ -173,7 +173,7 @@
this._mainFrameDidChange(oldMainFrame);
},
- resourceRequestWillBeSent: function(requestIdentifier, frameIdentifier, loaderIdentifier, request, type, redirectResponse, timestamp)
+ resourceRequestWillBeSent: function(requestIdentifier, frameIdentifier, loaderIdentifier, request, type, redirectResponse, timestamp, initiator)
{
// Called from WebInspector.NetworkObserver.
@@ -189,8 +189,10 @@
return;
}
+ var initiatorSourceCodeLocation = this._initiatorSourceCodeLocationFromPayload(initiator);
+
// This is a new request, make a new resource and add it to the right frame.
- resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, request.url, type, request.method, request.headers, request.postData, timestamp, null, null);
+ resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, request.url, type, request.method, request.headers, request.postData, timestamp, null, null, initiatorSourceCodeLocation);
// Associate the resource with the requestIdentifier so it can be found in future loading events.
this._resourceRequestIdentifierMap[requestIdentifier] = resource;
@@ -215,7 +217,7 @@
resource.markAsCached();
},
- resourceRequestWasServedFromMemoryCache: function(requestIdentifier, frameIdentifier, loaderIdentifier, cachedResourcePayload, timestamp)
+ resourceRequestWasServedFromMemoryCache: function(requestIdentifier, frameIdentifier, loaderIdentifier, cachedResourcePayload, timestamp, initiator)
{
// Called from WebInspector.NetworkObserver.
@@ -225,8 +227,10 @@
console.assert(!(requestIdentifier in this._resourceRequestIdentifierMap));
+ var initiatorSourceCodeLocation = this._initiatorSourceCodeLocationFromPayload(initiator);
+
var response = cachedResourcePayload.response;
- var resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, cachedResourcePayload.url, cachedResourcePayload.type, null, null, timestamp, null, null);
+ var resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, cachedResourcePayload.url, cachedResourcePayload.type, null, null, timestamp, null, null, initiatorSourceCodeLocation);
resource.markAsCached();
resource.updateForResponse(cachedResourcePayload.url, response.mimeType, cachedResourcePayload.type, response.headers, response.status, response.statusText, timestamp);
resource.markAsFinished(timestamp);
@@ -375,7 +379,7 @@
// Private
- _addNewResourceToFrame: function(requestIdentifier, frameIdentifier, loaderIdentifier, url, type, requestMethod, requestHeaders, requestData, timestamp, frameName, frameSecurityOrigin)
+ _addNewResourceToFrame: function(requestIdentifier, frameIdentifier, loaderIdentifier, url, type, requestMethod, requestHeaders, requestData, timestamp, frameName, frameSecurityOrigin, initiatorSourceCodeLocation)
{
console.assert(!this._waitingForMainFrameResourceTreePayload);
if (this._waitingForMainFrameResourceTreePayload)
@@ -391,12 +395,12 @@
else if (frame.provisionalMainResource && frame.provisionalMainResource.url ="" url && frame.provisionalLoaderIdentifier === loaderIdentifier)
resource = frame.provisionalMainResource;
else {
- resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, timestamp);
+ resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, timestamp, initiatorSourceCodeLocation);
this._addResourceToFrame(frame, resource);
}
} else {
// This is a new request for a new frame, which is always the main resource.
- resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, timestamp);
+ resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, timestamp, initiatorSourceCodeLocation);
frame = new WebInspector.Frame(frameIdentifier, frameName, frameSecurityOrigin, loaderIdentifier, resource);
this._frameIdentifierMap[frame.id] = frame;
@@ -436,6 +440,51 @@
frame.addResource(resource);
},
+ _initiatorSourceCodeLocationFromPayload: function(initiatorPayload)
+ {
+ if (!initiatorPayload)
+ return null;
+
+ var url = ""
+ var lineNumber = NaN;
+ var columnNumber = 0;
+
+ if (initiatorPayload.stackTrace && initiatorPayload.stackTrace.length) {
+ var stackTracePayload = initiatorPayload.stackTrace;
+ for (var i = 0; i < stackTracePayload.length; ++i) {
+ var callFramePayload = stackTracePayload[i];
+ if (!callFramePayload.url || callFramePayload.url ="" "[native code]")
+ continue;
+
+ url = ""
+
+ // The lineNumber is 1-based, but we expect 0-based.
+ lineNumber = callFramePayload.lineNumber - 1;
+
+ columnNumber = callFramePayload.columnNumber;
+
+ break;
+ }
+ } else if (initiatorPayload.url) {
+ url = ""
+
+ // The lineNumber is 1-based, but we expect 0-based.
+ lineNumber = initiatorPayload.lineNumber - 1;
+ }
+
+ if (!url || isNaN(lineNumber) || lineNumber < 0)
+ return null;
+
+ var sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
+ if (!sourceCode)
+ sourceCode = WebInspector.debuggerManager.scriptsForURL(url)[0];
+
+ if (!sourceCode)
+ return null;
+
+ return sourceCode.createSourceCodeLocation(lineNumber, columnNumber);
+ },
+
_processMainFrameResourceTreePayload: function(error, mainFramePayload)
{
console.assert(this._waitingForMainFrameResourceTreePayload);
Modified: trunk/Source/WebInspectorUI/UserInterface/NetworkObserver.js (156283 => 156284)
--- trunk/Source/WebInspectorUI/UserInterface/NetworkObserver.js 2013-09-23 19:27:15 UTC (rev 156283)
+++ trunk/Source/WebInspectorUI/UserInterface/NetworkObserver.js 2013-09-23 19:27:38 UTC (rev 156284)
@@ -35,7 +35,7 @@
requestWillBeSent: function(requestId, frameId, loaderId, documentURL, request, timestamp, initiator, redirectResponse, type)
{
- WebInspector.frameResourceManager.resourceRequestWillBeSent(requestId, frameId, loaderId, request, type, redirectResponse, timestamp);
+ WebInspector.frameResourceManager.resourceRequestWillBeSent(requestId, frameId, loaderId, request, type, redirectResponse, timestamp, initiator);
},
requestServedFromCache: function(requestId)
@@ -65,7 +65,7 @@
requestServedFromMemoryCache: function(requestId, frameId, loaderId, documentURL, timestamp, initiator, resource)
{
- WebInspector.frameResourceManager.resourceRequestWasServedFromMemoryCache(requestId, frameId, loaderId, resource, timestamp);
+ WebInspector.frameResourceManager.resourceRequestWasServedFromMemoryCache(requestId, frameId, loaderId, resource, timestamp, initiator);
},
webSocketWillSendHandshakeRequest: function(requestId, timestamp, request)
Modified: trunk/Source/WebInspectorUI/UserInterface/Resource.js (156283 => 156284)
--- trunk/Source/WebInspectorUI/UserInterface/Resource.js 2013-09-23 19:27:15 UTC (rev 156283)
+++ trunk/Source/WebInspectorUI/UserInterface/Resource.js 2013-09-23 19:27:38 UTC (rev 156284)
@@ -23,7 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-WebInspector.Resource = function(url, mimeType, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp)
+WebInspector.Resource = function(url, mimeType, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp, initiatorSourceCodeLocation)
{
WebInspector.SourceCode.call(this);
@@ -42,6 +42,7 @@
this._requestHeaders = requestHeaders || {};
this._responseHeaders = {};
this._parentFrame = null;
+ this._initiatorSourceCodeLocation = initiatorSourceCodeLocation || null;
this._requestSentTimestamp = requestSentTimestamp || NaN;
this._responseReceivedTimestamp = NaN;
this._lastRedirectReceivedTimestamp = NaN;
@@ -201,6 +202,11 @@
return WebInspector.displayNameForURL(this._url, this.urlComponents);
},
+ get initiatorSourceCodeLocation()
+ {
+ return this._initiatorSourceCodeLocation;
+ },
+
get type()
{
return this._type;
Modified: trunk/Source/WebInspectorUI/UserInterface/ResourceDetailsSidebarPanel.js (156283 => 156284)
--- trunk/Source/WebInspectorUI/UserInterface/ResourceDetailsSidebarPanel.js 2013-09-23 19:27:15 UTC (rev 156283)
+++ trunk/Source/WebInspectorUI/UserInterface/ResourceDetailsSidebarPanel.js 2013-09-23 19:27:38 UTC (rev 156284)
@@ -44,15 +44,18 @@
this._locationQueryStringRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Query String"));
this._locationFragmentRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Fragment"));
this._locationFilenameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Filename"));
+ this._initiatorRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Initiator"));
var firstGroup = [this._locationFullURLRow];
var secondGroup = [this._locationSchemeRow, this._locationHostRow, this._locationPortRow, this._locationPathRow,
this._locationQueryStringRow, this._locationFragmentRow, this._locationFilenameRow];
+ var thirdGroup = [this._initiatorRow];
this._fullURLGroup = new WebInspector.DetailsSectionGroup(firstGroup);
this._locationURLComponentsGroup = new WebInspector.DetailsSectionGroup(secondGroup);
+ this._initiatorGroup = new WebInspector.DetailsSectionGroup(thirdGroup);
- this._locationSection = new WebInspector.DetailsSection("resource-location", WebInspector.UIString("Location"), [this._fullURLGroup, this._locationURLComponentsGroup]);
+ this._locationSection = new WebInspector.DetailsSection("resource-location", WebInspector.UIString("Location"), [this._fullURLGroup, this._locationURLComponentsGroup, this._initiatorGroup]);
this._queryParametersRow = new WebInspector.DetailsSectionDataGridRow(null, WebInspector.UIString("No Query Parameters"));
this._queryParametersSection = new WebInspector.DetailsSection("resource-query-parameters", WebInspector.UIString("Query Parameters"));
@@ -200,7 +203,10 @@
var urlComponents = this._resource.urlComponents;
if (urlComponents.scheme) {
- this._locationSection.groups = [this._fullURLGroup, this._locationURLComponentsGroup];
+ if (this._resource.initiatorSourceCodeLocation)
+ this._locationSection.groups = [this._fullURLGroup, this._locationURLComponentsGroup, this._initiatorGroup];
+ else
+ this._locationSection.groups = [this._fullURLGroup, this._locationURLComponentsGroup];
this._locationSchemeRow.value = urlComponents.scheme ? urlComponents.scheme : null;
this._locationHostRow.value = urlComponents.host ? urlComponents.host : null;
@@ -209,9 +215,16 @@
this._locationQueryStringRow.value = urlComponents.queryString ? urlComponents.queryString.insertWordBreakCharacters() : null;
this._locationFragmentRow.value = urlComponents.fragment ? urlComponents.fragment.insertWordBreakCharacters() : null;
this._locationFilenameRow.value = urlComponents.lastPathComponent ? urlComponents.lastPathComponent.insertWordBreakCharacters() : null;
- } else
- this._locationSection.groups = [this._fullURLGroup];
+ } else {
+ if (this._resource.initiatorSourceCodeLocation)
+ this._locationSection.groups = [this._fullURLGroup, this._initiatorGroup];
+ else
+ this._locationSection.groups = [this._fullURLGroup];
+ }
+ if (this._resource.initiatorSourceCodeLocation)
+ this._initiatorRow.value = WebInspector.createSourceCodeLocationLink(this._resource.initiatorSourceCodeLocation, true);
+
if (urlComponents.queryString) {
// Ensure the "Query Parameters" section is displayed, right after the "Request & Response" section.
this.element.insertBefore(this._queryParametersSection.element, this._requestAndResponseSection.element.nextSibling);