Diff
Modified: trunk/LayoutTests/ChangeLog (121536 => 121537)
--- trunk/LayoutTests/ChangeLog 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/LayoutTests/ChangeLog 2012-06-29 09:32:59 UTC (rev 121537)
@@ -1,3 +1,26 @@
+2012-06-28 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Resource content is not loaded if Resource.requestContent method is called before network request is finished.
+ https://bugs.webkit.org/show_bug.cgi?id=90153
+
+ Reviewed by Yury Semikhatsky.
+
+ Resource.requestContent() now checks that request (if there is one) was already loaded before requesting content from PageAgent.
+ Drive-by: Removed unneeded legacy request._resource field.
+
+ * http/tests/inspector/network/network-request-revision-content.html:
+ * http/tests/inspector/resource-tree/resource-request-content-while-loading-expected.txt: Added.
+ * http/tests/inspector/resource-tree/resource-request-content-while-loading.html: Added.
+ * http/tests/inspector/resources-test.js:
+ (initialize_ResourceTest.InspectorTest.runAfterResourcesAreFinished.checkResources):
+ (initialize_ResourceTest.InspectorTest.runAfterResourcesAreFinished):
+ (initialize_ResourceTest.InspectorTest.showResource.showResourceCallback):
+ (initialize_ResourceTest.InspectorTest.showResource):
+ (initialize_ResourceTest.InspectorTest.resourceMatchingURL.visit):
+ (initialize_ResourceTest.InspectorTest.resourceMatchingURL):
+ (initialize_ResourceTest):
+ * inspector/debugger/raw-source-code.html:
+
2012-06-27 Vsevolod Vlasov <[email protected]>
Web Inspector: IDBObjectStore.autoIncrement flag not exposed
Modified: trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html (121536 => 121537)
--- trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html 2012-06-29 09:32:59 UTC (rev 121537)
@@ -18,7 +18,7 @@
function step2(msg)
{
var request = WebInspector.panels.network.requests[WebInspector.panels.network.requests.length - 1];
- resource = request.resource();
+ resource = WebInspector.resourceForURL(request.url);
resource.addRevision("");
resource.history[0].requestContent(step3);
}
Added: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading-expected.txt (0 => 121537)
--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading-expected.txt 2012-06-29 09:32:59 UTC (rev 121537)
@@ -0,0 +1,9 @@
+Tests resource content is correctly loaded if Resource.requestContent was called before network request was finished.
+
+Bug 90153
+Resource url: http://127.0.0.1:8000/inspector/resource-tree/resources/styles-initial.css
+Resource content: html {
+ background-color: green;
+}
+
+
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading.html (0 => 121537)
--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading.html 2012-06-29 09:32:59 UTC (rev 121537)
@@ -0,0 +1,45 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<link rel="stylesheet" href=""
+<script>
+function test()
+{
+ var contentWasRequested = false;
+ var resource;
+ InspectorTest.addSniffer(WebInspector.ResourceTreeFrame.prototype, "_addRequest", requestAdded, true);
+ InspectorTest.addSniffer(PageAgent, "getResourceContent", pageAgentGetResourceContentCalled, true);
+ InspectorTest.reloadPage(function() {});
+
+ function requestAdded(request)
+ {
+ if (request.url.indexOf("styles-initial") === -1)
+ return;
+ resource = InspectorTest.resourceMatchingURL("styles-initial");
+ if (!resource || !resource.request || contentWasRequested)
+ return;
+ resource.requestContent(contentLoaded);
+ contentWasRequested = true;
+ }
+
+ function pageAgentGetResourceContentCalled()
+ {
+ InspectorTest.assertTrue(resource.request.finished);
+ }
+
+ function contentLoaded(content)
+ {
+ InspectorTest.addResult("Resource url: " + resource.url);
+ InspectorTest.addResult("Resource content: " + content);
+ InspectorTest.completeTest();
+ }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests resource content is correctly loaded if Resource.requestContent was called before network request was finished.</p>
+<a href="" 90153</a>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-while-loading.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/http/tests/inspector/resources-test.js (121536 => 121537)
--- trunk/LayoutTests/http/tests/inspector/resources-test.js 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/LayoutTests/http/tests/inspector/resources-test.js 2012-06-29 09:32:59 UTC (rev 121537)
@@ -41,13 +41,10 @@
function checkResources()
{
- WebInspector.resourceTreeModel.forAllResources(visit);
- function visit(resource)
- {
- for (url in resourceURLsMap) {
- if (resource.url.indexOf(url) !== -1)
- delete resourceURLsMap[url];
- }
+ for (url in resourceURLsMap) {
+ var resource = InspectorTest.resourceMatchingURL(url);
+ if (resource)
+ delete resourceURLsMap[url];
}
if (!Object.keys(resourceURLsMap).length) {
WebInspector.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, checkResources);
@@ -72,21 +69,31 @@
function showResourceCallback()
{
- WebInspector.resourceTreeModel.forAllResources(visit);
- function visit(resource)
- {
- if (resource.url.indexOf(resourceURL) !== -1) {
- WebInspector.panels.resources.showResource(resource, 1);
- var sourceFrame = WebInspector.panels.resources._resourceViewForResource(resource);
- if (sourceFrame.loaded)
- callbackWrapper(sourceFrame);
- else
- InspectorTest.addSniffer(sourceFrame, "onTextViewerContentLoaded", callbackWrapper.bind(null, sourceFrame));
- return true;
- }
- }
+ var resource = InspectorTest.resourceMatchingURL(resourceURL);
+ if (!resource)
+ return;
+ WebInspector.panels.resources.showResource(resource, 1);
+ var sourceFrame = WebInspector.panels.resources._resourceViewForResource(resource);
+ if (sourceFrame.loaded)
+ callbackWrapper(sourceFrame);
+ else
+ InspectorTest.addSniffer(sourceFrame, "onTextViewerContentLoaded", callbackWrapper.bind(null, sourceFrame));
}
InspectorTest.runAfterResourcesAreFinished([resourceURL], showResourceCallback);
}
+InspectorTest.resourceMatchingURL = function(resourceURL, callback)
+{
+ var result = null;
+ WebInspector.resourceTreeModel.forAllResources(visit);
+ function visit(resource)
+ {
+ if (resource.url.indexOf(resourceURL) !== -1) {
+ result = resource;
+ return true;
+ }
+ }
+ return result;
}
+
+}
Modified: trunk/LayoutTests/inspector/debugger/raw-source-code.html (121536 => 121537)
--- trunk/LayoutTests/inspector/debugger/raw-source-code.html 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/LayoutTests/inspector/debugger/raw-source-code.html 2012-06-29 09:32:59 UTC (rev 121537)
@@ -59,7 +59,7 @@
{
var resource = null;
if (request && request.finished) {
- resource = request.resource();
+ resource = WebInspector.resourceForURL(request.url)
request = null;
}
var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, request, compilerSourceMapping);
Modified: trunk/Source/WebCore/ChangeLog (121536 => 121537)
--- trunk/Source/WebCore/ChangeLog 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/Source/WebCore/ChangeLog 2012-06-29 09:32:59 UTC (rev 121537)
@@ -1,3 +1,18 @@
+2012-06-28 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Resource content is not loaded if Resource.requestContent method is called before network request is finished.
+ https://bugs.webkit.org/show_bug.cgi?id=90153
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: http/tests/inspector/resource-tree/resource-request-content-while-loading.html
+
+ * inspector/front-end/NetworkRequest.js:
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource):
+ (WebInspector.Resource.prototype.requestContent):
+ (WebInspector.Resource.prototype._requestFinished):
+
2012-06-29 Sheriff Bot <[email protected]>
Unreviewed, rolling out r121529.
Modified: trunk/Source/WebCore/inspector/front-end/NetworkRequest.js (121536 => 121537)
--- trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2012-06-29 09:32:59 UTC (rev 121537)
@@ -802,22 +802,6 @@
},
/**
- * @param {WebInspector.Resource} resource
- */
- setResource: function(resource)
- {
- this._resource = resource;
- },
-
- /**
- * @return {WebInspector.Resource}
- */
- resource: function()
- {
- return this._resource;
- },
-
- /**
* @return {Object}
*/
frames: function()
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (121536 => 121537)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-06-29 09:17:07 UTC (rev 121536)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-06-29 09:32:59 UTC (rev 121537)
@@ -42,8 +42,6 @@
WebInspector.Resource = function(request, url, documentURL, frameId, loaderId, type, mimeType, isHidden)
{
this._request = request;
- if (this._request)
- this._request.setResource(this);
this.url = ""
this._documentURL = documentURL;
this._frameId = frameId;
@@ -56,6 +54,8 @@
/** @type {?string} */ this._content;
/** @type {boolean} */ this._contentEncoded;
this._pendingContentCallbacks = [];
+ if (this._request && !this._request.finished)
+ this._request.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._requestFinished, this);
}
WebInspector.Resource._domainModelBindings = [];
@@ -400,7 +400,8 @@
}
this._pendingContentCallbacks.push(callback);
- this._innerRequestContent();
+ if (!this._request || this._request.finished)
+ this._innerRequestContent();
},
canonicalMimeType: function()
@@ -457,6 +458,15 @@
return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content;
},
+
+ _requestFinished: function()
+ {
+ this._request.removeEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._requestFinished, this);
+ if (this._pendingContentCallbacks.length)
+ this._innerRequestContent();
+ },
+
+
_innerRequestContent: function()
{
if (this._contentRequested)