mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 885597 - absolute urls not working with sourcesContent and source maps in file:// urls; r=dcamp
This commit is contained in:
parent
1dfc9dd271
commit
9a78048baa
@ -315,9 +315,9 @@ define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'sou
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the original source content. The only argument is
|
||||
* the url of the original source file. Returns null if no
|
||||
* original source content is availible.
|
||||
* Returns the original source content. The only argument is the url of the
|
||||
* original source file. Returns null if no original source content is
|
||||
* availible.
|
||||
*/
|
||||
SourceMapConsumer.prototype.sourceContentFor =
|
||||
function SourceMapConsumer_sourceContentFor(aSource) {
|
||||
@ -335,10 +335,21 @@ define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'sou
|
||||
|
||||
var url;
|
||||
if (this.sourceRoot
|
||||
&& (url = util.urlParse(this.sourceRoot))
|
||||
&& (!url.path || url.path == "/")
|
||||
&& this._sources.has("/" + aSource)) {
|
||||
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
||||
&& (url = util.urlParse(this.sourceRoot))) {
|
||||
// XXX: file:// URIs and absolute paths lead to unexpected behavior for
|
||||
// many users. We can help them out when they expect file:// URIs to
|
||||
// behave like it would if they were running a local HTTP server. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
||||
var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
||||
if (url.scheme == "file"
|
||||
&& this._sources.has(fileUriAbsPath)) {
|
||||
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
||||
}
|
||||
|
||||
if ((!url.path || url.path == "/")
|
||||
&& this._sources.has("/" + aSource)) {
|
||||
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
||||
@ -1193,7 +1204,7 @@ define('source-map/source-map-generator', ['require', 'exports', 'module' , 'so
|
||||
var result = '';
|
||||
var mapping;
|
||||
|
||||
// The mappings must be guarenteed to be in sorted order before we start
|
||||
// The mappings must be guaranteed to be in sorted order before we start
|
||||
// serializing them or else the generated line numbers (which are defined
|
||||
// via the ';' separators) will be all messed up. Note: it might be more
|
||||
// performant to maintain the sorting as we insert them, rather than as we
|
||||
|
@ -308,6 +308,21 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
|
||||
assert.equal(map.sourceContentFor("/a"), "foo");
|
||||
};
|
||||
|
||||
exports['test bug 885597'] = function (assert, util) {
|
||||
var map = new SourceMapConsumer({
|
||||
"version": 3,
|
||||
"file": "foo.js",
|
||||
"sourceRoot": "file:///Users/AlGore/Invented/The/Internet/",
|
||||
"sources": ["/a"],
|
||||
"names": [],
|
||||
"mappings": "AACA",
|
||||
"sourcesContent": ["foo"]
|
||||
});
|
||||
|
||||
var s = map.sources[0];
|
||||
assert.equal(map.sourceContentFor(s), "foo");
|
||||
};
|
||||
|
||||
});
|
||||
function run_test() {
|
||||
runSourceMapTests('test/source-map/test-source-map-consumer', do_throw);
|
||||
|
Loading…
Reference in New Issue
Block a user