Changeset 179713 in webkit


Ignore:
Timestamp:
Feb 5, 2015 2:47:40 PM (9 years ago)
Author:
jonowells@apple.com
Message:

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.

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r179701 r179713  
     12015-02-04  Jono Wells  <jonowells@apple.com>
     2
     3        Web Inspector: REGRESSION: Inline SourceMap resources show empty content when opened.
     4        https://bugs.webkit.org/show_bug.cgi?id=141225
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Change WebInspector.SourceMapResource.prototype.requestContentFromBackend to correctly and consistently handle
     9        calls to NetworkAgent. The helper function sourceMapResourceLoaded will now properly handle parameters as a single
     10        payload, including manual calls in the case where the source map content is in a data URI. Also
     11        WebInspector.SourceCode.prototype._processContent now properly handles an error string used for displaying
     12        resource loading error messages in the resource content view.
     13
     14        * UserInterface/Models/Resource.js: drive-by style fix.
     15
     16        * UserInterface/Models/SourceCode.js:
     17        (WebInspector.SourceCode.prototype._processContent):
     18        Properly handle error string.
     19
     20        * UserInterface/Models/SourceMapResource.js:
     21        (WebInspector.SourceMapResource.prototype.requestContentFromBackend):
     22        (WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoaded):
     23        Formerly sourceMapResourceLoadError, now handles parameters from the NetworkAgent correctly.
     24
     25        (WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoadError):
     26        This function now handles NetworkAgent errors only.
     27
    1282015-02-05  Brian J. Burg  <burg@cs.washington.edu>
    229
  • trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js

    r178970 r179713  
    681681
    682682        if (this._failed)
    683             return Promise.resolve({ error: WebInspector.UIString("An error occurred trying to load the resource.") });
     683            return Promise.resolve({error: WebInspector.UIString("An error occurred trying to load the resource.")});
    684684
    685685        if (!this._finishThenRequestContentPromise) {
  • trunk/Source/WebInspectorUI/UserInterface/Models/SourceCode.js

    r178970 r179713  
    192192        // Different backend APIs return one of `content, `body`, or `scriptSource`.
    193193        var content = parameters.content || parameters.body || parameters.scriptSource;
     194        var error = parameters.error;
    194195        var base64Encoded = parameters.base64Encoded;
    195196
     
    202203
    203204        return Promise.resolve({
     205            error: error,
    204206            sourceCode: this,
    205207            content: content,
  • trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js

    r177791 r179713  
    5050WebInspector.SourceMapResource.prototype = {
    5151    constructor: WebInspector.SourceMapResource,
     52    __proto__: WebInspector.Resource.prototype,
    5253
    5354    // Public
     
    8586            // FIXME: We don't know the MIME-type for inline content. Guess by analyzing the content?
    8687            // Returns a promise.
    87             return sourceMapResourceLoaded.call(this, null, inlineContent, this.mimeType, 200);
     88            return sourceMapResourceLoaded.call(this, {content: inlineContent, mimeType: this.mimeType, status: 200});
    8889        }
    8990
    90         function sourceMapResourceLoadError(error, body, mimeType, statusCode)
     91        function sourceMapResourceNotAvailable(error, content, mimeType, statusCode)
    9192        {
    9293            this.markAsFailed();
    9394            return Promise.resolve({
    94                 error: error,
    95                 content: body.content,
     95                error: WebInspector.UIString("An error occurred trying to load the resource."),
     96                content: content,
    9697                mimeType: mimeType,
    9798                statusCode: statusCode
     
    99100        }
    100101
    101         function sourceMapResourceLoaded(body, mimeType, statusCode)
     102        function sourceMapResourceLoadError(error)
    102103        {
     104            // There was an error calling NetworkAgent.loadResource.
     105            console.error(error || "There was an unknown error calling NetworkAgent.loadResource.");
     106            this.markAsFailed();
     107            return Promise.resolve({error: WebInspector.UIString("An error occurred trying to load the resource.")});
     108        }
     109
     110        function sourceMapResourceLoaded(parameters)
     111        {
     112            var {error, content, mimeType, statusCode} = parameters;
     113
    103114            const base64encoded = false;
    104115
    105             if (statusCode >= 400)
    106                 return sourceMapResourceLoadError(error, body, mimeType, statusCode);
     116            if (statusCode >= 400 || error)
     117                return sourceMapResourceNotAvailable(error, content, mimeType, statusCode);
    107118
    108119            // FIXME: Add support for picking the best MIME-type. Right now the file extension is the best bet.
     
    112123
    113124            return Promise.resolve({
    114                 content: body.content,
     125                content: content,
    115126                mimeType: mimeType,
    116127                base64encoded: base64encoded,
     
    119130        }
    120131
    121         if (!NetworkAgent.loadResource) {
    122             sourceMapResourceLoaded.call(this, "error: no NetworkAgent.loadResource");
    123             return Promise.reject(new Error("No NetworkAgent.loadResource"));
    124         }
     132        if (!NetworkAgent.loadResource)
     133            return sourceMapResourceLoadError.call(this);
    125134
    126135        var frameIdentifier = null;
     
    164173    }
    165174};
    166 
    167 WebInspector.SourceMapResource.prototype.__proto__ = WebInspector.Resource.prototype;
Note: See TracChangeset for help on using the changeset viewer.