Changeset 103408 in webkit


Ignore:
Timestamp:
Dec 21, 2011 7:48:44 AM (12 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: fix source map url resolving.
https://bugs.webkit.org/show_bug.cgi?id=74305

Reviewed by Pavel Feldman.

Source/WebCore:

Also fix the bug with repeated source urls in mapping sections.

  • inspector/front-end/CompilerSourceMapping.js:

(WebInspector.ClosureCompilerSourceMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype.sources):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
(WebInspector.ClosureCompilerSourceMapping.prototype._resolveSourceMapURL):

  • inspector/front-end/DebuggerPresentationModel.js:

(WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):

  • inspector/front-end/utilities.js:

(String.prototype.asParsedURL):

LayoutTests:

  • http/tests/inspector/compiler-source-mapping-expected.txt:
  • http/tests/inspector/compiler-source-mapping.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103407 r103408  
     12011-12-12  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: fix source map url resolving.
     4        https://bugs.webkit.org/show_bug.cgi?id=74305
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * http/tests/inspector/compiler-source-mapping-expected.txt:
     9        * http/tests/inspector/compiler-source-mapping.html:
     10
    1112011-12-21  Renata Hodovan  <reni@webkit.org>
    212
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-expected.txt

    r101359 r103408  
    1010Running: testSections
    1111
     12Running: testResolveSourceMappingURL
     13
    1214Running: testLoad
    1315
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html

    r101359 r103408  
    9898                    "map": {
    9999                        "mappings":"AAAA,CAEC",
    100                         "sources":["source1.js"]
     100                        "sources":["source1.js", "source2.js"]
    101101                    }
    102102                }, {
     
    110110            var mapping = new WebInspector.ClosureCompilerSourceMapping();
    111111            mapping._parseMappingPayload(mappingPayload);
     112            InspectorTest.assertEquals(2, mapping.sources().length);
    112113            checkMapping(0, 0, "source1.js", 0, 0, mapping);
    113114            checkMapping(0, 1, "source1.js", 2, 1, mapping);
    114115            checkMapping(2, 10, "source2.js", 0, 0, mapping);
    115116            checkMapping(2, 11, "source2.js", 2, 1, mapping);
     117            next();
     118        },
     119
     120        function testResolveSourceMappingURL(next)
     121        {
     122            var func = WebInspector.ClosureCompilerSourceMapping.prototype._resolveSourceMapURL;
     123            InspectorTest.assertEquals("http://example.com/map.json", func("http://example.com/map.json", "http://example.com/script.js"));
     124            InspectorTest.assertEquals("http://example.com/map.json", func("/map.json", "http://example.com/script.js"));
     125            InspectorTest.assertEquals("http://example.com/scripts/../maps/map.json", func("../maps/map.json", "http://example.com/scripts/script.js"));
    116126            next();
    117127        },
  • trunk/Source/WebCore/ChangeLog

    r103407 r103408  
     12011-12-12  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: fix source map url resolving.
     4        https://bugs.webkit.org/show_bug.cgi?id=74305
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Also fix the bug with repeated source urls in mapping sections.
     9
     10        * inspector/front-end/CompilerSourceMapping.js:
     11        (WebInspector.ClosureCompilerSourceMapping):
     12        (WebInspector.ClosureCompilerSourceMapping.prototype.sources):
     13        (WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
     14        (WebInspector.ClosureCompilerSourceMapping.prototype._resolveSourceMapURL):
     15        * inspector/front-end/DebuggerPresentationModel.js:
     16        (WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):
     17        * inspector/front-end/utilities.js:
     18        (String.prototype.asParsedURL):
     19
    1202011-12-21  Renata Hodovan  <reni@webkit.org>
    221
  • trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js

    r102003 r103408  
    7373 * @constructor
    7474 * @param {string} sourceMappingURL
    75  */
    76 WebInspector.ClosureCompilerSourceMapping = function(sourceMappingURL)
     75 * @param {string} sourceURL
     76 */
     77WebInspector.ClosureCompilerSourceMapping = function(sourceMappingURL, scriptSourceOrigin)
    7778{
    7879    if (!WebInspector.ClosureCompilerSourceMapping.prototype._base64Map) {
     
    8384    }
    8485
    85     this._sourceMappingURL = sourceMappingURL;
    86     this._sources = [];
     86    this._sourceMappingURL = this._resolveSourceMapURL(sourceMappingURL, scriptSourceOrigin);
    8787    this._mappings = [];
    8888    this._reverseMappingsBySourceURL = {};
     
    132132    sources: function()
    133133    {
    134         return this._sources;
     134        var sources = [];
     135        for (var sourceURL in this._reverseMappingsBySourceURL)
     136            sources.push(sourceURL);
     137        return sources;
    135138    },
    136139
     
    186189    _parseMap: function(map, lineNumber, columnNumber)
    187190    {
    188         var sourceIndex = this._sources.length;
     191        var sourceIndex = 0;
    189192        var sourceLineNumber = 0;
    190193        var sourceColumnNumber = 0;
    191194        var nameIndex = 0;
    192195
     196        var sources = [];
    193197        for (var i = 0; i < map.sources.length; ++i) {
    194198            var url = this._canonicalizeURL(map.sourceRoot, map.sources[i]);
    195             this._sources.push(url);
    196             this._reverseMappingsBySourceURL[url] = [];
     199            sources.push(url);
     200            if (!this._reverseMappingsBySourceURL[url])
     201                this._reverseMappingsBySourceURL[url] = [];
    197202        }
    198203
    199204        var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(map.mappings);
    200         var sourceURL = this._sources[sourceIndex];
     205        var sourceURL = sources[sourceIndex];
    201206        var reverseMappings = this._reverseMappingsBySourceURL[sourceURL];
    202207
     
    219224                if (sourceIndexDelta) {
    220225                    sourceIndex += sourceIndexDelta;
    221                     sourceURL = this._sources[sourceIndex];
     226                    sourceURL = sources[sourceIndex];
    222227                    reverseMappings = this._reverseMappingsBySourceURL[sourceURL];
    223228                }
     
    261266    },
    262267
     268    _resolveSourceMapURL: function(sourceMappingURL, scriptSourceOrigin)
     269    {
     270        if (!sourceMappingURL || !scriptSourceOrigin)
     271            return sourceMappingURL;
     272
     273        if (sourceMappingURL.asParsedURL())
     274            return sourceMappingURL;
     275
     276        var origin = scriptSourceOrigin.asParsedURL();
     277        var baseURL = origin.scheme + "://" + origin.host + (origin.port ? ":" + origin.port : "");
     278        if (sourceMappingURL[0] === "/")
     279            return baseURL + sourceMappingURL;
     280        return baseURL + origin.firstPathComponents + sourceMappingURL;
     281    },
     282
    263283    _VLQ_BASE_SHIFT: 5,
    264284    _VLQ_BASE_MASK: (1 << 5) - 1,
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r103229 r103408  
    342342    setCompilerSourceMapping: function(uiSourceCode, sourceMappingURL)
    343343    {
    344         var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(sourceMappingURL);
     344        var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(sourceMappingURL, uiSourceCode.url);
    345345        uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
    346346    },
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r102450 r103408  
    470470        // Then take last path component.
    471471        var lastSlashIndex = path.lastIndexOf("/");
    472         if (lastSlashIndex !== -1)
     472        if (lastSlashIndex !== -1) {
     473            result.firstPathComponents = path.substring(0, lastSlashIndex + 1);
    473474            result.lastPathComponent = path.substring(lastSlashIndex + 1);
     475        }
    474476    }
    475477    return result;
Note: See TracChangeset for help on using the changeset viewer.