Web Inspector: REGRESSION: Inline SourceMap resources show empty content when opened.
authorjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Feb 2015 22:47:40 +0000 (22:47 +0000)
committerjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Feb 2015 22:47:40 +0000 (22:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141225

Reviewed by Timothy Hatcher.

Change WebInspector.SourceMapResource.prototype.requestContentFromBackend to correctly and consistently handle
calls to NetworkAgent. The helper function sourceMapResourceLoaded will now properly handle parameters as a single
payload, including manual calls in the case where the source map content is in a data URI. Also
WebInspector.SourceCode.prototype._processContent now properly handles an error string used for displaying
resource loading error messages in the resource content view.

* UserInterface/Models/Resource.js: drive-by style fix.

* UserInterface/Models/SourceCode.js:
(WebInspector.SourceCode.prototype._processContent):
Properly handle error string.

* UserInterface/Models/SourceMapResource.js:
(WebInspector.SourceMapResource.prototype.requestContentFromBackend):
(WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoaded):
Formerly sourceMapResourceLoadError, now handles parameters from the NetworkAgent correctly.

(WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoadError):
This function now handles NetworkAgent errors only.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179713 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Models/SourceCode.js
Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js

index e69457a..067a6ab 100644 (file)
@@ -1,3 +1,30 @@
+2015-02-04  Jono Wells  <jonowells@apple.com>
+
+        Web Inspector: REGRESSION: Inline SourceMap resources show empty content when opened.
+        https://bugs.webkit.org/show_bug.cgi?id=141225
+
+        Reviewed by Timothy Hatcher.
+
+        Change WebInspector.SourceMapResource.prototype.requestContentFromBackend to correctly and consistently handle
+        calls to NetworkAgent. The helper function sourceMapResourceLoaded will now properly handle parameters as a single
+        payload, including manual calls in the case where the source map content is in a data URI. Also
+        WebInspector.SourceCode.prototype._processContent now properly handles an error string used for displaying
+        resource loading error messages in the resource content view.
+
+        * UserInterface/Models/Resource.js: drive-by style fix.
+
+        * UserInterface/Models/SourceCode.js:
+        (WebInspector.SourceCode.prototype._processContent):
+        Properly handle error string.
+
+        * UserInterface/Models/SourceMapResource.js:
+        (WebInspector.SourceMapResource.prototype.requestContentFromBackend):
+        (WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoaded):
+        Formerly sourceMapResourceLoadError, now handles parameters from the NetworkAgent correctly.
+
+        (WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoadError):
+        This function now handles NetworkAgent errors only.
+
 2015-02-05  Brian J. Burg  <burg@cs.washington.edu>
 
         Web Inspector: eliminate some unnecessary layout/painting in timeline overview and ruler
index f68627e..bf22ba2 100644 (file)
@@ -680,7 +680,7 @@ WebInspector.Resource.prototype = {
             return WebInspector.SourceCode.prototype.requestContent.call(this);
 
         if (this._failed)
-            return Promise.resolve({ error: WebInspector.UIString("An error occurred trying to load the resource.") });
+            return Promise.resolve({error: WebInspector.UIString("An error occurred trying to load the resource.")});
 
         if (!this._finishThenRequestContentPromise) {
             var listener = new WebInspector.EventListener(this, true);
index c166239..f12d987 100644 (file)
@@ -191,6 +191,7 @@ WebInspector.SourceCode.prototype = {
     {
         // Different backend APIs return one of `content, `body`, or `scriptSource`.
         var content = parameters.content || parameters.body || parameters.scriptSource;
+        var error = parameters.error;
         var base64Encoded = parameters.base64Encoded;
 
         var revision = this.revisionForRequestedContent;
@@ -201,6 +202,7 @@ WebInspector.SourceCode.prototype = {
         delete this._ignoreRevisionContentDidChangeEvent;
 
         return Promise.resolve({
+            error: error,
             sourceCode: this,
             content: content,
             base64Encoded: base64Encoded
index 2968576..e225efe 100644 (file)
@@ -49,6 +49,7 @@ WebInspector.SourceMapResource = function(url, sourceMap)
 
 WebInspector.SourceMapResource.prototype = {
     constructor: WebInspector.SourceMapResource,
+    __proto__: WebInspector.Resource.prototype,
 
     // Public
 
@@ -84,26 +85,36 @@ WebInspector.SourceMapResource.prototype = {
             // Force inline content to be asynchronous to match the expected load pattern.
             // FIXME: We don't know the MIME-type for inline content. Guess by analyzing the content?
             // Returns a promise.
-            return sourceMapResourceLoaded.call(this, null, inlineContent, this.mimeType, 200);
+            return sourceMapResourceLoaded.call(this, {content: inlineContent, mimeType: this.mimeType, status: 200});
         }
 
-        function sourceMapResourceLoadError(error, body, mimeType, statusCode)
+        function sourceMapResourceNotAvailable(error, content, mimeType, statusCode)
         {
             this.markAsFailed();
             return Promise.resolve({
-                error: error,
-                content: body.content,
+                error: WebInspector.UIString("An error occurred trying to load the resource."),
+                content: content,
                 mimeType: mimeType,
                 statusCode: statusCode
             });
         }
 
-        function sourceMapResourceLoaded(body, mimeType, statusCode)
+        function sourceMapResourceLoadError(error)
         {
+            // There was an error calling NetworkAgent.loadResource.
+            console.error(error || "There was an unknown error calling NetworkAgent.loadResource.");
+            this.markAsFailed();
+            return Promise.resolve({error: WebInspector.UIString("An error occurred trying to load the resource.")});
+        }
+
+        function sourceMapResourceLoaded(parameters)
+        {
+            var {error, content, mimeType, statusCode} = parameters;
+
             const base64encoded = false;
 
-            if (statusCode >= 400)
-                return sourceMapResourceLoadError(error, body, mimeType, statusCode);
+            if (statusCode >= 400 || error)
+                return sourceMapResourceNotAvailable(error, content, mimeType, statusCode);
 
             // FIXME: Add support for picking the best MIME-type. Right now the file extension is the best bet.
             // The constructor set MIME-type based on the file extension and we ignore mimeType here.
@@ -111,17 +122,15 @@ WebInspector.SourceMapResource.prototype = {
             this.markAsFinished();
 
             return Promise.resolve({
-                content: body.content,
+                content: content,
                 mimeType: mimeType,
                 base64encoded: base64encoded,
                 statusCode: statusCode
             });
         }
 
-        if (!NetworkAgent.loadResource) {
-            sourceMapResourceLoaded.call(this, "error: no NetworkAgent.loadResource");
-            return Promise.reject(new Error("No NetworkAgent.loadResource"));
-        }
+        if (!NetworkAgent.loadResource)
+            return sourceMapResourceLoadError.call(this);
 
         var frameIdentifier = null;
         if (this._sourceMap.originalSourceCode instanceof WebInspector.Resource && this._sourceMap.originalSourceCode.parentFrame)
@@ -163,5 +172,3 @@ WebInspector.SourceMapResource.prototype = {
         return new WebInspector.SourceCodeTextRange(this._sourceMap.originalSourceCode, startSourceCodeLocation, endSourceCodeLocation);
     }
 };
-
-WebInspector.SourceMapResource.prototype.__proto__ = WebInspector.Resource.prototype;