Diff
Modified: trunk/LayoutTests/ChangeLog (127901 => 127902)
--- trunk/LayoutTests/ChangeLog 2012-09-07 18:44:32 UTC (rev 127901)
+++ trunk/LayoutTests/ChangeLog 2012-09-07 18:51:37 UTC (rev 127902)
@@ -1,3 +1,16 @@
+2012-09-06 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: [REGRESSION] Content is not available for dynamically loaded script sometimes.
+ https://bugs.webkit.org/show_bug.cgi?id=95954
+
+ Reviewed by Yury Semikhatsky.
+
+ * http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache-expected.txt: Added.
+ * http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache.html: Added.
+ * http/tests/inspector/resource-tree/resources/dynamic-script.js: Added.
+ (foo):
+ * http/tests/inspector/resources-test.js:
+
2012-09-07 Dominic Mazzoni <dmazz...@google.com>
Unreviewed.
Added: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache-expected.txt (0 => 127902)
--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache-expected.txt 2012-09-07 18:51:37 UTC (rev 127902)
@@ -0,0 +1,12 @@
+Tests resource content is correctly loaded if Resource.requestContent was called before network request was finished.
+
+Bug 90153
+Adding dynamic script:
+Waiting for script request to finish:
+Clearing memory cache:
+Requesting content:
+Resource url: http://127.0.0.1:8000/inspector/resource-tree/resources/dynamic-script.js
+Resource content: function foo() {
+}
+
+
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache.html (0 => 127902)
--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache.html 2012-09-07 18:51:37 UTC (rev 127902)
@@ -0,0 +1,60 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<link rel="stylesheet" href=""
+<script>
+function createScriptTag()
+{
+ var scriptElement = document.createElement("script");
+ scriptElement.src = ""
+ document.head.appendChild(scriptElement);
+}
+
+function test()
+{
+ setTimeout(InspectorTest.completeTest.bind(InspectorTest), 1000);
+ InspectorTest.addResult("Adding dynamic script: ");
+ InspectorTest.evaluateInPage("createScriptTag()", step2);
+
+ function step2()
+ {
+ InspectorTest.addResult("Waiting for script request to finish: ");
+ InspectorTest.runAfterResourcesAreFinished(["dynamic-script.js"], step3)
+ }
+
+ function step3()
+ {
+ InspectorTest.addResult("Clearing memory cache: ");
+ NetworkAgent.setCacheDisabled(true, step4);
+ }
+
+ function step4()
+ {
+ NetworkAgent.setCacheDisabled(false, step5);
+ }
+
+ var resource;
+ function step5()
+ {
+ InspectorTest.addResult("Requesting content: ");
+ resource = InspectorTest.resourceMatchingURL("dynamic-script.js");
+ resource.requestContent(step6);
+ }
+
+ function step6(content)
+ {
+ InspectorTest.assertTrue(!!content, "No content available.");
+ 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-after-loading-and-clearing-cache.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector/resource-tree/resources/dynamic-script.js (0 => 127902)
--- trunk/LayoutTests/http/tests/inspector/resource-tree/resources/dynamic-script.js (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resources/dynamic-script.js 2012-09-07 18:51:37 UTC (rev 127902)
@@ -0,0 +1,2 @@
+function foo() {
+}
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-tree/resources/dynamic-script.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/http/tests/inspector/resources-test.js (127901 => 127902)
--- trunk/LayoutTests/http/tests/inspector/resources-test.js 2012-09-07 18:44:32 UTC (rev 127901)
+++ trunk/LayoutTests/http/tests/inspector/resources-test.js 2012-09-07 18:51:37 UTC (rev 127902)
@@ -82,7 +82,7 @@
InspectorTest.runAfterResourcesAreFinished([resourceURL], showResourceCallback);
}
-InspectorTest.resourceMatchingURL = function(resourceURL, callback)
+InspectorTest.resourceMatchingURL = function(resourceURL)
{
var result = null;
WebInspector.resourceTreeModel.forAllResources(visit);
Modified: trunk/Source/WebCore/ChangeLog (127901 => 127902)
--- trunk/Source/WebCore/ChangeLog 2012-09-07 18:44:32 UTC (rev 127901)
+++ trunk/Source/WebCore/ChangeLog 2012-09-07 18:51:37 UTC (rev 127902)
@@ -1,3 +1,20 @@
+2012-09-06 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: [REGRESSION] Content is not available for dynamically loaded script sometimes.
+ https://bugs.webkit.org/show_bug.cgi?id=95954
+
+ Reviewed by Yury Semikhatsky.
+
+ Resource now loads content from request when it is available.
+ Content was loaded from PageAgent before where it might be not available if the resource was already GCed.
+
+ Test: http/tests/inspector/resource-tree/resource-request-content-after-loading-and-clearing-cache.html
+
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource.prototype._innerRequestContent.contentLoaded):
+ (WebInspector.Resource.prototype._innerRequestContent.resourceContentLoaded):
+ (WebInspector.Resource.prototype._innerRequestContent):
+
2012-09-07 Adam Barth <aba...@webkit.org>
HTMLTokenizer should use the latest EfficientStrings hotness
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (127901 => 127902)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-09-07 18:44:32 UTC (rev 127901)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-09-07 18:51:37 UTC (rev 127902)
@@ -311,13 +311,12 @@
this._contentRequested = true;
/**
- * @param {?Protocol.Error} error
* @param {string} content
* @param {boolean} contentEncoded
*/
- function callback(error, content, contentEncoded)
+ function contentLoaded(content, contentEncoded)
{
- this._content = error ? null : content;
+ this._content = content;
this._contentEncoded = contentEncoded;
var callbacks = this._pendingContentCallbacks.slice();
for (var i = 0; i < callbacks.length; ++i)
@@ -325,7 +324,34 @@
this._pendingContentCallbacks.length = 0;
delete this._contentRequested;
}
- PageAgent.getResourceContent(this.frameId, this.url, callback.bind(this));
+
+ /**
+ * @param {?Protocol.Error} error
+ * @param {string} content
+ * @param {boolean} contentEncoded
+ */
+ function resourceContentLoaded(error, content, contentEncoded)
+ {
+ if (error)
+ console.error("Resource content request failed: " + error);
+ contentLoaded.call(this, error ? null : content, contentEncoded);
+ }
+
+ if (this.request) {
+ /**
+ * @param {string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function requestContentLoaded(content, contentEncoded, mimeType)
+ {
+ contentLoaded.call(this, content, contentEncoded);
+ }
+
+ this.request.requestContent(requestContentLoaded.bind(this));
+ return;
+ }
+ PageAgent.getResourceContent(this.frameId, this.url, resourceContentLoaded.bind(this));
},
/**