Backed out changeset 95bec5828ef3 (bug 1136146) for devtools test failures CLOSED TREE

This commit is contained in:
Wes Kocher 2015-03-11 15:17:46 -07:00
parent 1d88bc3c03
commit b07b12b5bd
11 changed files with 1017 additions and 2436 deletions

View File

@ -79,7 +79,7 @@ function testSetBreakpointBlankLine() {
let sourceForm = getSourceForm(gSources, COFFEE_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
source.setBreakpoint({ line: 1 }, aResponse => {
source.setBreakpoint({ line: 3 }, aResponse => {
ok(!aResponse.error,
"Should be able to set a breakpoint in a coffee source file on a blank line.");
ok(aResponse.actualLocation,
@ -147,7 +147,7 @@ function testStepping() {
is(aPacket.frame.environment.bindings.variables.start.value, 0,
"'start' is 0.");
is(aPacket.frame.environment.bindings.variables.stop.value, 5,
"'stop' is 5.");
"'stop' hasn't been assigned to yet.");
is(aPacket.frame.environment.bindings.variables.pivot.value.type, "undefined",
"'pivot' hasn't been assigned to yet.");

View File

@ -45,11 +45,11 @@ function testSetBreakpoint() {
let sourceForm = getSourceForm(gSources, JS_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
source.setBreakpoint({ line: 30 }, aResponse => {
source.setBreakpoint({ line: 30, column: 21 }, aResponse => {
ok(!aResponse.error,
"Should be able to set a breakpoint in a js file.");
ok(!aResponse.actualLocation,
"Should be able to set a breakpoint on line 30.");
"Should be able to set a breakpoint on line 30 and column 10.");
gDebugger.gClient.addOneTimeListener("resumed", () => {
waitForCaretAndScopes(gPanel, 30).then(() => {

View File

@ -2593,7 +2593,7 @@ SourceActor.prototype = {
*/
_invertSourceMap: function ({ code, mappings }) {
const generator = new SourceMapGenerator({ file: this.url });
return DevToolsUtils.yieldingEach(mappings._array, m => {
return DevToolsUtils.yieldingEach(mappings, m => {
let mapping = {
generated: {
line: m.generatedLine,
@ -5719,8 +5719,7 @@ ThreadSources.prototype = {
} = map.generatedPositionFor({
source: originalSourceActor.url,
line: originalLine,
column: originalColumn == null ? 0 : originalColumn,
bias: SourceMapConsumer.LEAST_UPPER_BOUND
column: originalColumn == null ? Infinity : originalColumn
});
return new GeneratedLocation(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -126,113 +126,6 @@ define('test/source-map/util', ['require', 'exports', 'module' , 'lib/source-ma
sourceRoot: '',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
// This mapping is identical to above, but uses the indexed format instead.
exports.indexedTestMap = {
version: 3,
file: 'min.js',
sections: [
{
offset: {
line: 0,
column: 0
},
map: {
version: 3,
sources: [
"one.js"
],
sourcesContent: [
' ONE.foo = function (bar) {\n' +
' return baz(bar);\n' +
' };',
],
names: [
"bar",
"baz"
],
mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
file: "min.js",
sourceRoot: "/the/root"
}
},
{
offset: {
line: 1,
column: 0
},
map: {
version: 3,
sources: [
"two.js"
],
sourcesContent: [
' TWO.inc = function (n) {\n' +
' return n + 1;\n' +
' };'
],
names: [
"n"
],
mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
file: "min.js",
sourceRoot: "/the/root"
}
}
]
};
exports.indexedTestMapDifferentSourceRoots = {
version: 3,
file: 'min.js',
sections: [
{
offset: {
line: 0,
column: 0
},
map: {
version: 3,
sources: [
"one.js"
],
sourcesContent: [
' ONE.foo = function (bar) {\n' +
' return baz(bar);\n' +
' };',
],
names: [
"bar",
"baz"
],
mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
file: "min.js",
sourceRoot: "/the/root"
}
},
{
offset: {
line: 1,
column: 0
},
map: {
version: 3,
sources: [
"two.js"
],
sourcesContent: [
' TWO.inc = function (n) {\n' +
' return n + 1;\n' +
' };'
],
names: [
"n"
],
mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
file: "min.js",
sourceRoot: "/different/root"
}
}
]
};
exports.testMapWithSourcesContent = {
version: 3,
file: 'min.js',
@ -275,13 +168,12 @@ define('test/source-map/util', ['require', 'exports', 'module' , 'lib/source-ma
function assertMapping(generatedLine, generatedColumn, originalSource,
originalLine, originalColumn, name, bias, map, assert,
originalLine, originalColumn, name, map, assert,
dontTestGenerated, dontTestOriginal) {
if (!dontTestOriginal) {
var origMapping = map.originalPositionFor({
line: generatedLine,
column: generatedColumn,
bias: bias
column: generatedColumn
});
assert.equal(origMapping.name, name,
'Incorrect name, expected ' + JSON.stringify(name)
@ -314,8 +206,7 @@ define('test/source-map/util', ['require', 'exports', 'module' , 'lib/source-ma
var genMapping = map.generatedPositionFor({
source: originalSource,
line: originalLine,
column: originalColumn,
bias: bias
column: originalColumn
});
assert.equal(genMapping.line, generatedLine,
'Incorrect line, expected ' + JSON.stringify(generatedLine)
@ -630,7 +521,7 @@ define('lib/source-map/util', ['require', 'exports', 'module' , ], function(requ
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
cmp = strcmp(mappingA.name, mappingB.name);
if (cmp) {
return cmp;
}
@ -640,7 +531,7 @@ define('lib/source-map/util', ['require', 'exports', 'module' , ], function(requ
return cmp;
}
return strcmp(mappingA.name, mappingB.name);
return mappingA.generatedColumn - mappingB.generatedColumn;
};
exports.compareByOriginalPositions = compareByOriginalPositions;

View File

@ -19,10 +19,9 @@ define("test/source-map/test-base64-vlq", ["require", "exports", "module"], func
exports['test normal encoding and decoding'] = function (assert, util) {
var result = {};
for (var i = -255; i < 256; i++) {
var str = base64VLQ.encode(i);
base64VLQ.decode(str, 0, result);
base64VLQ.decode(base64VLQ.encode(i), result);
assert.equal(result.value, i);
assert.equal(result.rest, str.length);
assert.equal(result.rest, "");
}
};

View File

@ -20,7 +20,7 @@ define("test/source-map/test-binary-search", ["require", "exports", "module"], f
return a - b;
}
exports['test too high with default (glb) bias'] = function (assert, util) {
exports['test too high'] = function (assert, util) {
var needle = 30;
var haystack = [2,4,6,8,10,12,14,16,18,20];
@ -31,7 +31,7 @@ define("test/source-map/test-binary-search", ["require", "exports", "module"], f
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 20);
};
exports['test too low with default (glb) bias'] = function (assert, util) {
exports['test too low'] = function (assert, util) {
var needle = 1;
var haystack = [2,4,6,8,10,12,14,16,18,20];
@ -42,30 +42,6 @@ define("test/source-map/test-binary-search", ["require", "exports", "module"], f
assert.equal(binarySearch.search(needle, haystack, numberCompare), -1);
};
exports['test too high with lub bias'] = function (assert, util) {
var needle = 30;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.doesNotThrow(function () {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(binarySearch.search(needle, haystack, numberCompare,
binarySearch.LEAST_UPPER_BOUND), -1);
};
exports['test too low with lub bias'] = function (assert, util) {
var needle = 1;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.doesNotThrow(function () {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare,
binarySearch.LEAST_UPPER_BOUND)], 2);
};
exports['test exact search'] = function (assert, util) {
var needle = 4;
var haystack = [2,4,6,8,10,12,14,16,18,20];
@ -73,29 +49,13 @@ define("test/source-map/test-binary-search", ["require", "exports", "module"], f
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 4);
};
exports['test fuzzy search with default (glb) bias'] = function (assert, util) {
exports['test fuzzy search'] = function (assert, util) {
var needle = 19;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 18);
};
exports['test fuzzy search with lub bias'] = function (assert, util) {
var needle = 19;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare,
binarySearch.LEAST_UPPER_BOUND)], 20);
};
exports['test multiple matches'] = function (assert, util) {
var needle = 5;
var haystack = [1, 1, 2, 5, 5, 5, 13, 21];
assert.equal(binarySearch.search(needle, haystack, numberCompare,
binarySearch.LEAST_UPPER_BOUND), 3);
};
});
function run_test() {
runSourceMapTests('test/source-map/test-binary-search', do_throw);

View File

@ -56,55 +56,34 @@ define("test/source-map/test-dog-fooding", ["require", "exports", "module"], fun
var smc = new SourceMapConsumer(smg.toString());
// Exact
util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 0, null, null, smc, assert);
util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 0, null, null, smc, assert);
util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 0, null, null, smc, assert);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 0, null, null, smc, assert);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 5, 10, null, null, smc, assert);
util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 0, null, smc, assert);
util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 0, null, smc, assert);
util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 0, null, smc, assert);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 0, null, smc, assert);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 5, 10, null, smc, assert);
// Fuzzy
// Generated to original with default (glb) bias.
util.assertMapping(2, 0, null, null, null, null, null, smc, assert, true);
util.assertMapping(2, 9, '/wu/tang/gza.coffee', 1, 0, null, null, smc, assert, true);
util.assertMapping(3, 0, null, null, null, null, null, smc, assert, true);
util.assertMapping(3, 9, '/wu/tang/gza.coffee', 2, 0, null, null, smc, assert, true);
util.assertMapping(4, 0, null, null, null, null, null, smc, assert, true);
util.assertMapping(4, 9, '/wu/tang/gza.coffee', 3, 0, null, null, smc, assert, true);
util.assertMapping(5, 0, null, null, null, null, null, smc, assert, true);
util.assertMapping(5, 9, '/wu/tang/gza.coffee', 4, 0, null, null, smc, assert, true);
util.assertMapping(6, 0, null, null, null, null, null, smc, assert, true);
util.assertMapping(6, 9, null, null, null, null, null, smc, assert, true);
util.assertMapping(6, 13, '/wu/tang/gza.coffee', 5, 10, null, null, smc, assert, true);
// Generated to original
util.assertMapping(2, 0, null, null, null, null, smc, assert, true);
util.assertMapping(2, 9, '/wu/tang/gza.coffee', 1, 0, null, smc, assert, true);
util.assertMapping(3, 0, null, null, null, null, smc, assert, true);
util.assertMapping(3, 9, '/wu/tang/gza.coffee', 2, 0, null, smc, assert, true);
util.assertMapping(4, 0, null, null, null, null, smc, assert, true);
util.assertMapping(4, 9, '/wu/tang/gza.coffee', 3, 0, null, smc, assert, true);
util.assertMapping(5, 0, null, null, null, null, smc, assert, true);
util.assertMapping(5, 9, '/wu/tang/gza.coffee', 4, 0, null, smc, assert, true);
util.assertMapping(6, 0, null, null, null, null, smc, assert, true);
util.assertMapping(6, 9, null, null, null, null, smc, assert, true);
util.assertMapping(6, 13, '/wu/tang/gza.coffee', 5, 10, null, smc, assert, true);
// Generated to original with lub bias.
util.assertMapping(2, 0, '/wu/tang/gza.coffee', 1, 0, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(2, 9, null, null, null, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(3, 0, '/wu/tang/gza.coffee', 2, 0, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(3, 9, null, null, null, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(4, 0, '/wu/tang/gza.coffee', 3, 0, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(4, 9, null, null, null, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(5, 0, '/wu/tang/gza.coffee', 4, 0, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(5, 9, null, null, null, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(6, 0, '/wu/tang/gza.coffee', 5, 10, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(6, 9, '/wu/tang/gza.coffee', 5, 10, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
util.assertMapping(6, 13, null, null, null, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, true);
// Original to generated with default (glb) bias
util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 1, null, null, smc, assert, null, true);
util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 3, null, null, smc, assert, null, true);
util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 6, null, null, smc, assert, null, true);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 9, null, null, smc, assert, null, true);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 5, 9, null, null, smc, assert, null, true);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 6, 19, null, null, smc, assert, null, true);
// Original to generated with lub bias.
util.assertMapping(3, 2, '/wu/tang/gza.coffee', 1, 1, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
util.assertMapping(4, 2, '/wu/tang/gza.coffee', 2, 3, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 3, 6, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 4, 9, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 5, 9, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
util.assertMapping(null, null, '/wu/tang/gza.coffee', 6, 19, null, SourceMapConsumer.LEAST_UPPER_BOUND, smc, assert, null, true);
// Original to generated
util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 1, null, smc, assert, null, true);
util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 3, null, smc, assert, null, true);
util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 6, null, smc, assert, null, true);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 9, null, smc, assert, null, true);
util.assertMapping(5, 2, '/wu/tang/gza.coffee', 5, 9, null, smc, assert, null, true);
util.assertMapping(6, 12, '/wu/tang/gza.coffee', 6, 19, null, smc, assert, null, true);
};
});

View File

@ -15,8 +15,6 @@ Components.utils.import('resource://test/Utils.jsm');
define("test/source-map/test-source-map-consumer", ["require", "exports", "module"], function (require, exports, module) {
var SourceMapConsumer = require('source-map/source-map-consumer').SourceMapConsumer;
var IndexedSourceMapConsumer = require('source-map/source-map-consumer').IndexedSourceMapConsumer;
var BasicSourceMapConsumer = require('source-map/source-map-consumer').BasicSourceMapConsumer;
var SourceMapGenerator = require('source-map/source-map-generator').SourceMapGenerator;
exports['test that we can instantiate with a string or an object'] = function (assert, util) {
@ -28,18 +26,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
});
};
exports['test that the object returned from new SourceMapConsumer inherits from SourceMapConsumer'] = function (assert, util) {
assert.ok(new SourceMapConsumer(util.testMap) instanceof SourceMapConsumer);
}
exports['test that a BasicSourceMapConsumer is returned for sourcemaps without sections'] = function(assert, util) {
assert.ok(new SourceMapConsumer(util.testMap) instanceof BasicSourceMapConsumer);
};
exports['test that an IndexedSourceMapConsumer is returned for sourcemaps with sections'] = function(assert, util) {
assert.ok(new SourceMapConsumer(util.indexedTestMap) instanceof IndexedSourceMapConsumer);
};
exports['test that the `sources` field has the original sources'] = function (assert, util) {
var map;
var sources;
@ -50,18 +36,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
assert.equal(sources[1], '/the/root/two.js');
assert.equal(sources.length, 2);
map = new SourceMapConsumer(util.indexedTestMap);
sources = map.sources;
assert.equal(sources[0], '/the/root/one.js');
assert.equal(sources[1], '/the/root/two.js');
assert.equal(sources.length, 2);
map = new SourceMapConsumer(util.indexedTestMapDifferentSourceRoots);
sources = map.sources;
assert.equal(sources[0], '/the/root/one.js');
assert.equal(sources[1], '/different/root/two.js');
assert.equal(sources.length, 2);
map = new SourceMapConsumer(util.testMapNoSourceRoot);
sources = map.sources;
assert.equal(sources[0], 'one.js');
@ -127,107 +101,34 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
exports['test mapping tokens back exactly'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMap);
util.assertMapping(1, 1, '/the/root/one.js', 1, 1, null, null, map, assert);
util.assertMapping(1, 5, '/the/root/one.js', 1, 5, null, null, map, assert);
util.assertMapping(1, 9, '/the/root/one.js', 1, 11, null, null, map, assert);
util.assertMapping(1, 18, '/the/root/one.js', 1, 21, 'bar', null, map, assert);
util.assertMapping(1, 21, '/the/root/one.js', 2, 3, null, null, map, assert);
util.assertMapping(1, 28, '/the/root/one.js', 2, 10, 'baz', null, map, assert);
util.assertMapping(1, 32, '/the/root/one.js', 2, 14, 'bar', null, map, assert);
util.assertMapping(1, 1, '/the/root/one.js', 1, 1, null, map, assert);
util.assertMapping(1, 5, '/the/root/one.js', 1, 5, null, map, assert);
util.assertMapping(1, 9, '/the/root/one.js', 1, 11, null, map, assert);
util.assertMapping(1, 18, '/the/root/one.js', 1, 21, 'bar', map, assert);
util.assertMapping(1, 21, '/the/root/one.js', 2, 3, null, map, assert);
util.assertMapping(1, 28, '/the/root/one.js', 2, 10, 'baz', map, assert);
util.assertMapping(1, 32, '/the/root/one.js', 2, 14, 'bar', map, assert);
util.assertMapping(2, 1, '/the/root/two.js', 1, 1, null, null, map, assert);
util.assertMapping(2, 5, '/the/root/two.js', 1, 5, null, null, map, assert);
util.assertMapping(2, 9, '/the/root/two.js', 1, 11, null, null, map, assert);
util.assertMapping(2, 18, '/the/root/two.js', 1, 21, 'n', null, map, assert);
util.assertMapping(2, 21, '/the/root/two.js', 2, 3, null, null, map, assert);
util.assertMapping(2, 28, '/the/root/two.js', 2, 10, 'n', null, map, assert);
};
exports['test mapping tokens back exactly in indexed source map'] = function (assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
util.assertMapping(1, 1, '/the/root/one.js', 1, 1, null, null, map, assert);
util.assertMapping(1, 5, '/the/root/one.js', 1, 5, null, null, map, assert);
util.assertMapping(1, 9, '/the/root/one.js', 1, 11, null, null, map, assert);
util.assertMapping(1, 18, '/the/root/one.js', 1, 21, 'bar', null, map, assert);
util.assertMapping(1, 21, '/the/root/one.js', 2, 3, null, null, map, assert);
util.assertMapping(1, 28, '/the/root/one.js', 2, 10, 'baz', null, map, assert);
util.assertMapping(1, 32, '/the/root/one.js', 2, 14, 'bar', null, map, assert);
util.assertMapping(2, 1, '/the/root/two.js', 1, 1, null, null, map, assert);
util.assertMapping(2, 5, '/the/root/two.js', 1, 5, null, null, map, assert);
util.assertMapping(2, 9, '/the/root/two.js', 1, 11, null, null, map, assert);
util.assertMapping(2, 18, '/the/root/two.js', 1, 21, 'n', null, map, assert);
util.assertMapping(2, 21, '/the/root/two.js', 2, 3, null, null, map, assert);
util.assertMapping(2, 28, '/the/root/two.js', 2, 10, 'n', null, map, assert);
};
exports['test mapping tokens back exactly'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMap);
util.assertMapping(1, 1, '/the/root/one.js', 1, 1, null, null, map, assert);
util.assertMapping(1, 5, '/the/root/one.js', 1, 5, null, null, map, assert);
util.assertMapping(1, 9, '/the/root/one.js', 1, 11, null, null, map, assert);
util.assertMapping(1, 18, '/the/root/one.js', 1, 21, 'bar', null, map, assert);
util.assertMapping(1, 21, '/the/root/one.js', 2, 3, null, null, map, assert);
util.assertMapping(1, 28, '/the/root/one.js', 2, 10, 'baz', null, map, assert);
util.assertMapping(1, 32, '/the/root/one.js', 2, 14, 'bar', null, map, assert);
util.assertMapping(2, 1, '/the/root/two.js', 1, 1, null, null, map, assert);
util.assertMapping(2, 5, '/the/root/two.js', 1, 5, null, null, map, assert);
util.assertMapping(2, 9, '/the/root/two.js', 1, 11, null, null, map, assert);
util.assertMapping(2, 18, '/the/root/two.js', 1, 21, 'n', null, map, assert);
util.assertMapping(2, 21, '/the/root/two.js', 2, 3, null, null, map, assert);
util.assertMapping(2, 28, '/the/root/two.js', 2, 10, 'n', null, map, assert);
util.assertMapping(2, 1, '/the/root/two.js', 1, 1, null, map, assert);
util.assertMapping(2, 5, '/the/root/two.js', 1, 5, null, map, assert);
util.assertMapping(2, 9, '/the/root/two.js', 1, 11, null, map, assert);
util.assertMapping(2, 18, '/the/root/two.js', 1, 21, 'n', map, assert);
util.assertMapping(2, 21, '/the/root/two.js', 2, 3, null, map, assert);
util.assertMapping(2, 28, '/the/root/two.js', 2, 10, 'n', map, assert);
};
exports['test mapping tokens fuzzy'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMap);
// Finding original positions with default (glb) bias.
util.assertMapping(1, 20, '/the/root/one.js', 1, 21, 'bar', null, map, assert, true);
util.assertMapping(1, 30, '/the/root/one.js', 2, 10, 'baz', null, map, assert, true);
util.assertMapping(2, 12, '/the/root/two.js', 1, 11, null, null, map, assert, true);
// Finding original positions
util.assertMapping(1, 20, '/the/root/one.js', 1, 21, 'bar', map, assert, true);
util.assertMapping(1, 30, '/the/root/one.js', 2, 10, 'baz', map, assert, true);
util.assertMapping(2, 12, '/the/root/two.js', 1, 11, null, map, assert, true);
// Finding original positions with lub bias.
util.assertMapping(1, 16, '/the/root/one.js', 1, 21, 'bar', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
util.assertMapping(1, 26, '/the/root/one.js', 2, 10, 'baz', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
util.assertMapping(2, 6, '/the/root/two.js', 1, 11, null, SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
// Finding generated positions with default (glb) bias.
util.assertMapping(1, 18, '/the/root/one.js', 1, 22, 'bar', null, map, assert, null, true);
util.assertMapping(1, 28, '/the/root/one.js', 2, 13, 'baz', null, map, assert, null, true);
util.assertMapping(2, 9, '/the/root/two.js', 1, 16, null, null, map, assert, null, true);
// Finding generated positions with lub bias.
util.assertMapping(1, 18, '/the/root/one.js', 1, 20, 'bar', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
util.assertMapping(1, 28, '/the/root/one.js', 2, 7, 'baz', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
util.assertMapping(2, 9, '/the/root/two.js', 1, 6, null, SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
};
exports['test mapping tokens fuzzy in indexed source map'] = function (assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
// Finding original positions with default (glb) bias.
util.assertMapping(1, 20, '/the/root/one.js', 1, 21, 'bar', null, map, assert, true);
util.assertMapping(1, 30, '/the/root/one.js', 2, 10, 'baz', null, map, assert, true);
util.assertMapping(2, 12, '/the/root/two.js', 1, 11, null, null, map, assert, true);
// Finding original positions with lub bias.
util.assertMapping(1, 16, '/the/root/one.js', 1, 21, 'bar', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
util.assertMapping(1, 26, '/the/root/one.js', 2, 10, 'baz', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
util.assertMapping(2, 6, '/the/root/two.js', 1, 11, null, SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, true);
// Finding generated positions with default (glb) bias.
util.assertMapping(1, 18, '/the/root/one.js', 1, 22, 'bar', null, map, assert, null, true);
util.assertMapping(1, 28, '/the/root/one.js', 2, 13, 'baz', null, map, assert, null, true);
util.assertMapping(2, 9, '/the/root/two.js', 1, 16, null, null, map, assert, null, true);
// Finding generated positions with lub bias.
util.assertMapping(1, 18, '/the/root/one.js', 1, 20, 'bar', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
util.assertMapping(1, 28, '/the/root/one.js', 2, 7, 'baz', SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
util.assertMapping(2, 9, '/the/root/two.js', 1, 6, null, SourceMapConsumer.LEAST_UPPER_BOUND, map, assert, null, true);
// Finding generated positions
util.assertMapping(1, 18, '/the/root/one.js', 1, 22, 'bar', map, assert, null, true);
util.assertMapping(1, 28, '/the/root/one.js', 2, 13, 'baz', map, assert, null, true);
util.assertMapping(2, 9, '/the/root/two.js', 1, 16, null, map, assert, null, true);
};
exports['test mappings and end of lines'] = function (assert, util) {
@ -248,10 +149,10 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
var map = SourceMapConsumer.fromSourceMap(smg);
// When finding original positions, mappings end at the end of the line.
util.assertMapping(2, 1, null, null, null, null, null, map, assert, true)
util.assertMapping(2, 1, null, null, null, null, map, assert, true)
// When finding generated positions, mappings do not end at the end of the line.
util.assertMapping(1, 1, 'bar.js', 2, 1, null, null, map, assert, null, true);
util.assertMapping(1, 1, 'bar.js', 2, 1, null, map, assert, null, true);
};
exports['test creating source map consumers with )]}\' prefix'] = function (assert, util) {
@ -292,29 +193,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
});
};
exports['test eachMapping for indexed source maps'] = function(assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
var previousLine = -Infinity;
var previousColumn = -Infinity;
map.eachMapping(function (mapping) {
assert.ok(mapping.generatedLine >= previousLine);
if (mapping.source) {
assert.equal(mapping.source.indexOf(util.testMap.sourceRoot), 0);
}
if (mapping.generatedLine === previousLine) {
assert.ok(mapping.generatedColumn >= previousColumn);
previousColumn = mapping.generatedColumn;
}
else {
previousLine = mapping.generatedLine;
previousColumn = -Infinity;
}
});
};
exports['test iterating over mappings in a different order'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMap);
var previousLine = -Infinity;
@ -343,34 +221,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
}, null, SourceMapConsumer.ORIGINAL_ORDER);
};
exports['test iterating over mappings in a different order in indexed source maps'] = function (assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
var previousLine = -Infinity;
var previousColumn = -Infinity;
var previousSource = "";
map.eachMapping(function (mapping) {
assert.ok(mapping.source >= previousSource);
if (mapping.source === previousSource) {
assert.ok(mapping.originalLine >= previousLine);
if (mapping.originalLine === previousLine) {
assert.ok(mapping.originalColumn >= previousColumn);
previousColumn = mapping.originalColumn;
}
else {
previousLine = mapping.originalLine;
previousColumn = -Infinity;
}
}
else {
previousSource = mapping.source;
previousLine = -Infinity;
previousColumn = -Infinity;
}
}, null, SourceMapConsumer.ORIGINAL_ORDER);
};
exports['test that we can set the context for `this` in eachMapping'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMap);
var context = {};
@ -379,14 +229,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
}, context);
};
exports['test that we can set the context for `this` in eachMapping in indexed source maps'] = function (assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
var context = {};
map.eachMapping(function () {
assert.equal(this, context);
}, context);
};
exports['test that the `sourcesContent` field has the original sources'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMapWithSourcesContent);
var sourcesContent = map.sourcesContent;
@ -434,26 +276,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
}, Error);
};
exports['test that we can get the original source content for the sources on an indexed source map'] = function (assert, util) {
var map = new SourceMapConsumer(util.indexedTestMap);
var sources = map.sources;
assert.equal(map.sourceContentFor(sources[0]), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor(sources[1]), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.equal(map.sourceContentFor("one.js"), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor("two.js"), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.throws(function () {
map.sourceContentFor("");
}, Error);
assert.throws(function () {
map.sourceContentFor("/the/root/three.js");
}, Error);
assert.throws(function () {
map.sourceContentFor("three.js");
}, Error);
};
exports['test sourceRoot + generatedPositionFor'] = function (assert, util) {
var map = new SourceMapGenerator({
sourceRoot: 'foo/bar',
@ -722,20 +544,6 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul
'Source should be relative the host of the source root.');
};
exports['test indexed source map errors when sections are out of order by line'] = function(assert, util) {
// Make a deep copy of the indexedTestMap
var misorderedIndexedTestMap = JSON.parse(JSON.stringify(util.indexedTestMap));
misorderedIndexedTestMap.sections[0].offset = {
line: 2,
column: 0
};
assert.throws(function() {
new SourceMapConsumer(misorderedIndexedTestMap);
}, Error);
};
exports['test github issue #64'] = function (assert, util) {
var map = new SourceMapConsumer({
"version": 3,

View File

@ -103,27 +103,6 @@ define("test/source-map/test-source-map-generator", ["require", "exports", "modu
});
};
exports['test adding mappings with skipValidation'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated-foo.js',
sourceRoot: '.',
skipValidation: true
});
// Not enough info, caught by `util.getArgs`
assert.throws(function () {
map.addMapping({});
});
// Original file position, but no source. Not checked.
assert.doesNotThrow(function () {
map.addMapping({
generated: { line: 1, column: 1 },
original: { line: 1, column: 1 }
});
});
};
exports['test that the correct mappings are being generated'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'min.js',
@ -681,48 +660,6 @@ define("test/source-map/test-source-map-generator", ["require", "exports", "modu
});
};
exports['test applySourceMap with unexact match'] = function (assert, util) {
var map1 = new SourceMapGenerator({
file: 'bundled-source'
});
map1.addMapping({
generated: { line: 1, column: 4 },
original: { line: 1, column: 4 },
source: 'transformed-source'
});
map1.addMapping({
generated: { line: 2, column: 4 },
original: { line: 2, column: 4 },
source: 'transformed-source'
});
var map2 = new SourceMapGenerator({
file: 'transformed-source'
});
map2.addMapping({
generated: { line: 2, column: 0 },
original: { line: 1, column: 0 },
source: 'original-source'
});
var expectedMap = new SourceMapGenerator({
file: 'bundled-source'
});
expectedMap.addMapping({
generated: { line: 1, column: 4 },
original: { line: 1, column: 4 },
source: 'transformed-source'
});
expectedMap.addMapping({
generated: { line: 2, column: 4 },
original: { line: 1, column: 0 },
source: 'original-source'
});
map1.applySourceMap(new SourceMapConsumer(map2.toJSON()));
util.assertEqualMaps(assert, map1.toJSON(), expectedMap.toJSON());
};
});
function run_test() {
runSourceMapTests('test/source-map/test-source-map-generator', do_throw);