Bug 1188697 - Update the tree's copy of the mozilla/source-map library; r=jryans

This update contains a fix for loadSourceError in the debugger when a source map
has an absolute sourceRoot and one or more of its sources are absolute rather
than relative to the sourceRoot.
This commit is contained in:
Nick Fitzgerald 2015-08-07 13:49:16 -07:00
Родитель 06cb78aa75
Коммит 57aecb0801
3 изменённых файлов: 65 добавлений и 6 удалений

Просмотреть файл

@ -848,7 +848,7 @@ define('source-map/util', ['require', 'exports', 'module' , ], function(require,
}
path = url.path;
}
var isAbsolute = (path.charAt(0) === '/');
var isAbsolute = exports.isAbsolute(path);
var parts = path.split(/\/+/);
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
@ -943,6 +943,10 @@ define('source-map/util', ['require', 'exports', 'module' , ], function(require,
}
exports.join = join;
exports.isAbsolute = function (aPath) {
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
};
/**
* Make a path relative to a URL or another path.
*
@ -1617,10 +1621,20 @@ define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'sou
throw new Error('Unsupported version: ' + version);
}
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
sources = sources.map(util.normalize);
sources = sources
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
.map(util.normalize)
// Always ensure that absolute sources are internally stored relative to
// the source root, if the source root is absolute. Not doing this would
// be particularly problematic when the source root is a prefix of the
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
.map(function (source) {
return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
? util.relative(sourceRoot, source)
: source;
});
// Pass `true` below to allow duplicate names and sources. While source maps
// are intended to be compressed and deduplicated, the TypeScript compiler

Просмотреть файл

@ -466,7 +466,7 @@ define('lib/source-map/util', ['require', 'exports', 'module' , ], function(requ
}
path = url.path;
}
var isAbsolute = (path.charAt(0) === '/');
var isAbsolute = exports.isAbsolute(path);
var parts = path.split(/\/+/);
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
@ -561,6 +561,10 @@ define('lib/source-map/util', ['require', 'exports', 'module' , ], function(requ
}
exports.join = join;
exports.isAbsolute = function (aPath) {
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
};
/**
* Make a path relative to a URL or another path.
*

Просмотреть файл

@ -1086,6 +1086,47 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
"SourceMapConsumer from it should not throw");
};
exports['test sources where their prefix is the source root: issue #199'] = function (assert, util) {
var testSourceMap = {
"version": 3,
"sources": ["/source/app/app/app.js"],
"names": ["System"],
"mappings": "AAAAA",
"file": "app/app.js",
"sourcesContent": ["'use strict';"],
"sourceRoot":"/source/"
};
var consumer = new SourceMapConsumer(testSourceMap);
function consumerHasSource(s) {
assert.ok(consumer.sourceContentFor(s));
}
consumer.sources.forEach(consumerHasSource);
testSourceMap.sources.forEach(consumerHasSource);
};
exports['test sources where their prefix is the source root and the source root is a url: issue #199'] = function (assert, util) {
var testSourceMap = {
"version": 3,
"sources": ["http://example.com/source/app/app/app.js"],
"names": ["System"],
"mappings": "AAAAA",
"sourcesContent": ["'use strict';"],
"sourceRoot":"http://example.com/source/"
};
var consumer = new SourceMapConsumer(testSourceMap);
function consumerHasSource(s) {
assert.ok(consumer.sourceContentFor(s));
}
consumer.sources.forEach(consumerHasSource);
testSourceMap.sources.forEach(consumerHasSource);
};
});
function run_test() {
runSourceMapTests('test/source-map/test-source-map-consumer', do_throw);