From a813c8393ca7cc86c99ed3b51ee7421823ee68bb Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Wed, 10 Apr 2013 16:05:35 +0300 Subject: [PATCH] Backout 50b1fc3ef560 (bug 849069) on suspicion of leaks --- .../devtools/debugger/test/binary_search.js | 3 +- .../devtools/debugger/test/binary_search.map | 3 +- .../debugger/server/dbg-script-actors.js | 59 ++++++------------- .../devtools/debugger/tests/unit/head_dbg.js | 25 -------- .../unit/source-map-data/sourcemapped.coffee | 6 -- .../unit/source-map-data/sourcemapped.map | 10 ---- .../debugger/tests/unit/sourcemapped.js | 16 ----- .../debugger/tests/unit/test_source-01.js | 10 +++- .../debugger/tests/unit/test_sourcemaps-04.js | 48 --------------- .../debugger/tests/unit/test_sourcemaps-05.js | 48 --------------- .../devtools/debugger/tests/unit/xpcshell.ini | 6 -- toolkit/devtools/sourcemap/SourceMap.jsm | 30 +--------- .../devtools/sourcemap/tests/unit/Utils.jsm | 48 ++------------- .../tests/unit/test_source_map_consumer.js | 42 +------------ 14 files changed, 42 insertions(+), 312 deletions(-) delete mode 100644 toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee delete mode 100644 toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map delete mode 100644 toolkit/devtools/debugger/tests/unit/sourcemapped.js delete mode 100644 toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js delete mode 100644 toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js diff --git a/browser/devtools/debugger/test/binary_search.js b/browser/devtools/debugger/test/binary_search.js index aa3dff3bc827..ce77903e1b07 100644 --- a/browser/devtools/debugger/test/binary_search.js +++ b/browser/devtools/debugger/test/binary_search.js @@ -24,6 +24,7 @@ }).call(this); +// TODO bug 849069: this should just be "binary_search.map", not a full path. /* -//@ sourceMappingURL=binary_search.map +//@ sourceMappingURL=http://example.com/browser/browser/devtools/debugger/test/binary_search.map */ diff --git a/browser/devtools/debugger/test/binary_search.map b/browser/devtools/debugger/test/binary_search.map index c5aaeab2f011..a86e74783f11 100644 --- a/browser/devtools/debugger/test/binary_search.map +++ b/browser/devtools/debugger/test/binary_search.map @@ -1,9 +1,8 @@ { "version": 3, "file": "binary_search.js", - "sourceRoot": "", "sources": [ - "binary_search.coffee" + "http://example.com/browser/browser/devtools/debugger/test/binary_search.coffee" ], "names": [], "mappings": ";AACA;CAAA;CAAA,CAAA,CAAuB,EAAA,CAAjB,GAAkB,IAAxB;CAEE,OAAA,UAAA;CAAA,EAAQ,CAAR,CAAA;CAAA,EACQ,CAAR,CAAa,CAAL;CADR,EAEQ,CAAR,CAAA;CAEA,EAA0C,CAAR,CAAtB,MAAN;CAGJ,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,CAAR,CAAQ,GAAR;QAAA;CACA,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,EAAR,GAAA;QADA;CAAA,EAIQ,CAAI,CAAZ,CAAA;CAXF,IAIA;CAUA,GAAA,CAAS;CAAT,YAA8B;MAA9B;AAA0C,CAAD,YAAA;MAhBpB;CAAvB,EAAuB;CAAvB" diff --git a/toolkit/devtools/debugger/server/dbg-script-actors.js b/toolkit/devtools/debugger/server/dbg-script-actors.js index 354d9cdfec9f..d54c1bd7aec2 100644 --- a/toolkit/devtools/debugger/server/dbg-script-actors.js +++ b/toolkit/devtools/debugger/server/dbg-script-actors.js @@ -525,9 +525,7 @@ ThreadActor.prototype = { originalLine) return locationPromise.then(function (aLocation) { let line = aLocation.line; - if (this.dbg.findScripts({ url: aLocation.url }).length == 0 || - line < 0 || - line == null) { + if (this.dbg.findScripts({ url: aLocation.url }).length == 0 || line < 0) { return { error: "noScript" }; } @@ -2421,13 +2419,16 @@ ThreadSources.prototype = { } return this.sourceMap(aScript) - .then((aSourceMap) => [this.source(s) for (s of aSourceMap.sources)]) - .then(null, (e) => { + .then(function (aSourceMap) { + return [ + this.source(s) for (s of aSourceMap.sources) + ]; + }.bind(this), function (e) { reportError(e); - delete this._sourceMaps[this._normalize(aScript.sourceMapURL, aScript.url)]; + delete this._sourceMaps[aScript.sourceMapURL]; delete this._sourceMapsByGeneratedSource[aScript.url]; return [this.source(aScript.url)]; - }) + }.bind(this)) .then(function (aSources) { return aSources.filter(isNotNull); }); @@ -2441,16 +2442,14 @@ ThreadSources.prototype = { return this._sourceMapsByGeneratedSource[aScript.url]; } dbg_assert(aScript.sourceMapURL); - let sourceMapURL = this._normalize(aScript.sourceMapURL, - aScript.url); - let map = this._fetchSourceMap(sourceMapURL) - .then((aSourceMap) => { + let map = this._fetchSourceMap(aScript.sourceMapURL) + .then(function (aSourceMap) { for (let s of aSourceMap.sources) { this._generatedUrlsByOriginalUrl[s] = aScript.url; this._sourceMapsByOriginalSource[s] = resolve(aSourceMap); } return aSourceMap; - }); + }.bind(this)); this._sourceMapsByGeneratedSource[aScript.url] = map; return map; }, @@ -2458,21 +2457,14 @@ ThreadSources.prototype = { /** * Fetch the source map located at the given url. */ - _fetchSourceMap: function TS__fetchSourceMap(aAbsSourceMapURL) { - if (aAbsSourceMapURL in this._sourceMaps) { - return this._sourceMaps[aAbsSourceMapURL]; + _fetchSourceMap: function TS__featchSourceMap(aSourceMapURL) { + if (aSourceMapURL in this._sourceMaps) { + return this._sourceMaps[aSourceMapURL]; } else { - let promise = fetch(aAbsSourceMapURL).then((rawSourceMap) => { - let map = new SourceMapConsumer(rawSourceMap); - let base = aAbsSourceMapURL.replace(/\/[^\/]+$/, '/'); - if (base.indexOf("data:") !== 0) { - map.sourceRoot = map.sourceRoot - ? this._normalize(map.sourceRoot, base) - : base; - } - return map; + let promise = fetch(aSourceMapURL).then(function (rawSourceMap) { + return new SourceMapConsumer(rawSourceMap); }); - this._sourceMaps[aAbsSourceMapURL] = promise; + this._sourceMaps[aSourceMapURL] = promise; return promise; } }, @@ -2515,7 +2507,7 @@ ThreadSources.prototype = { getGeneratedLocation: function TS_getGeneratedLocation(aSourceUrl, aLine) { if (aSourceUrl in this._sourceMapsByOriginalSource) { return this._sourceMapsByOriginalSource[aSourceUrl] - .then((aSourceMap) => { + .then(function (aSourceMap) { let { line } = aSourceMap.generatedPositionFor({ source: aSourceUrl, line: aLine, @@ -2525,7 +2517,7 @@ ThreadSources.prototype = { url: this._generatedUrlsByOriginalUrl[aSourceUrl], line: line }; - }); + }.bind(this)); } // No source map @@ -2535,19 +2527,6 @@ ThreadSources.prototype = { }); }, - /** - * Normalize multiple relative paths towards the base paths on the right. - */ - _normalize: function TS__normalize(...aURLs) { - dbg_assert(aURLs.length > 1); - let base = Services.io.newURI(aURLs.pop(), null, null); - let url; - while ((url = aURLs.pop())) { - base = Services.io.newURI(url, null, base); - } - return base.spec; - }, - iter: function TS_iter() { for (let url in this._sourceActors) { yield this._sourceActors[url]; diff --git a/toolkit/devtools/debugger/tests/unit/head_dbg.js b/toolkit/devtools/debugger/tests/unit/head_dbg.js index 69207ed93589..525ae7e46552 100644 --- a/toolkit/devtools/debugger/tests/unit/head_dbg.js +++ b/toolkit/devtools/debugger/tests/unit/head_dbg.js @@ -175,14 +175,6 @@ function finishClient(aClient) }); } -/** - * Takes a relative file path and returns the absolute file url for it. - */ -function getFileUrl(aName) { - let file = do_get_file(aName); - return Services.io.newFileURI(file).spec; -} - /** * Returns the full path of the file with the specified name in a * platform-independent and URL-like form. @@ -198,20 +190,3 @@ function getFilePath(aName) } return path.slice(filePrePath.length); } - -Cu.import("resource://gre/modules/NetUtil.jsm"); - -/** - * Returns the full text contents of the given file. - */ -function readFile(aFileName) { - let f = do_get_file(aFileName); - let s = Cc["@mozilla.org/network/file-input-stream;1"] - .createInstance(Ci.nsIFileInputStream); - s.init(f, -1, -1, false); - try { - return NetUtil.readInputStreamToString(s, s.available()); - } finally { - s.close(); - } -} diff --git a/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee b/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee deleted file mode 100644 index 73a400a219d9..000000000000 --- a/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.coffee +++ /dev/null @@ -1,6 +0,0 @@ -foo = (n) -> - return "foo" + i for i in [0...n] - -[first, second, third] = foo(3) - -debugger \ No newline at end of file diff --git a/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map b/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map deleted file mode 100644 index dcee3c33c393..000000000000 --- a/toolkit/devtools/debugger/tests/unit/source-map-data/sourcemapped.map +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 3, - "file": "sourcemapped.js", - "sourceRoot": "", - "sources": [ - "sourcemapped.coffee" - ], - "names": [], - "mappings": ";AAAA;CAAA,KAAA,yBAAA;CAAA;CAAA,CAAA,CAAA,MAAO;CACL,IAAA,GAAA;AAAA,CAAA,EAAA,MAA0B,qDAA1B;CAAA,EAAe,EAAR,QAAA;CAAP,IADI;CAAN,EAAM;;CAAN,CAGA,CAAyB,IAAA;;CAEzB,UALA;CAAA" -} \ No newline at end of file diff --git a/toolkit/devtools/debugger/tests/unit/sourcemapped.js b/toolkit/devtools/debugger/tests/unit/sourcemapped.js deleted file mode 100644 index 7dbcb2d14939..000000000000 --- a/toolkit/devtools/debugger/tests/unit/sourcemapped.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by CoffeeScript 1.6.1 -(function() { - var first, foo, second, third, _ref; - - foo = function(n) { - var i, _i; - for (i = _i = 0; 0 <= n ? _i < n : _i > n; i = 0 <= n ? ++_i : --_i) { - return "foo" + i; - } - }; - - _ref = foo(3), first = _ref[0], second = _ref[1], third = _ref[2]; - - debugger; - -}).call(this); diff --git a/toolkit/devtools/debugger/tests/unit/test_source-01.js b/toolkit/devtools/debugger/tests/unit/test_source-01.js index 684e38f44d85..a1fd94e4c484 100644 --- a/toolkit/devtools/debugger/tests/unit/test_source-01.js +++ b/toolkit/devtools/debugger/tests/unit/test_source-01.js @@ -10,6 +10,8 @@ var gThreadClient; // and that they can communicate over the protocol to fetch the source text for // a given script. +Cu.import("resource://gre/modules/NetUtil.jsm"); + function run_test() { initTestDebuggerServer(); @@ -58,9 +60,15 @@ function test_source() do_check_true(!aResponse.error); do_check_true(!!aResponse.source); - do_check_eq(readFile("test_source-01.js"), + let f = do_get_file("test_source-01.js", false); + let s = Cc["@mozilla.org/network/file-input-stream;1"] + .createInstance(Ci.nsIFileInputStream); + s.init(f, -1, -1, false); + + do_check_eq(NetUtil.readInputStreamToString(s, s.available()), aResponse.source); + s.close(); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js b/toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js deleted file mode 100644 index af61f6c48962..000000000000 --- a/toolkit/devtools/debugger/tests/unit/test_sourcemaps-04.js +++ /dev/null @@ -1,48 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Check that absolute source map urls work. - */ - -var gDebuggee; -var gClient; -var gThreadClient; - -Components.utils.import('resource:///modules/devtools/SourceMap.jsm'); - -function run_test() -{ - initTestDebuggerServer(); - gDebuggee = addTestGlobal("test-source-map"); - gClient = new DebuggerClient(DebuggerServer.connectPipe()); - gClient.connect(function() { - attachTestGlobalClientAndResume(gClient, "test-source-map", function(aResponse, aThreadClient) { - gThreadClient = aThreadClient; - test_absolute_source_map(); - }); - }); - do_test_pending(); -} - -function test_absolute_source_map() -{ - gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); - - do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1, - "The new source should be a coffee file."); - do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1, - "The new source should not be a js file."); - - finishClient(gClient); - }); - - code = readFile("sourcemapped.js") - + "\n//@ sourceMappingURL=" + getFileUrl("source-map-data/sourcemapped.map"); - - Components.utils.evalInSandbox(code, gDebuggee, "1.8", - getFileUrl("sourcemapped.js"), 1); -} diff --git a/toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js b/toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js deleted file mode 100644 index 352fab415435..000000000000 --- a/toolkit/devtools/debugger/tests/unit/test_sourcemaps-05.js +++ /dev/null @@ -1,48 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Check that relative source map urls work. - */ - -var gDebuggee; -var gClient; -var gThreadClient; - -Components.utils.import('resource:///modules/devtools/SourceMap.jsm'); - -function run_test() -{ - initTestDebuggerServer(); - gDebuggee = addTestGlobal("test-source-map"); - gClient = new DebuggerClient(DebuggerServer.connectPipe()); - gClient.connect(function() { - attachTestGlobalClientAndResume(gClient, "test-source-map", function(aResponse, aThreadClient) { - gThreadClient = aThreadClient; - test_relative_source_map(); - }); - }); - do_test_pending(); -} - -function test_relative_source_map() -{ - gClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); - - do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1, - "The new source should be a coffee file."); - do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1, - "The new source should not be a js file."); - - finishClient(gClient); - }); - - code = readFile("sourcemapped.js") - + "\n//@ sourceMappingURL=source-map-data/sourcemapped.map"; - - Components.utils.evalInSandbox(code, gDebuggee, "1.8", - getFileUrl("sourcemapped.js"), 1); -} diff --git a/toolkit/devtools/debugger/tests/unit/xpcshell.ini b/toolkit/devtools/debugger/tests/unit/xpcshell.ini index a273cdff5944..bdf4d89ad351 100644 --- a/toolkit/devtools/debugger/tests/unit/xpcshell.ini +++ b/toolkit/devtools/debugger/tests/unit/xpcshell.ini @@ -81,12 +81,6 @@ reason = bug 820380 [test_sourcemaps-01.js] [test_sourcemaps-02.js] [test_sourcemaps-03.js] -[test_sourcemaps-04.js] -skip-if = toolkit == "gonk" -reason = bug 820380 -[test_sourcemaps-05.js] -skip-if = toolkit == "gonk" -reason = bug 820380 [test_objectgrips-01.js] [test_objectgrips-02.js] [test_objectgrips-03.js] diff --git a/toolkit/devtools/sourcemap/SourceMap.jsm b/toolkit/devtools/sourcemap/SourceMap.jsm index 05139f7969d9..b8f9bd4258a3 100644 --- a/toolkit/devtools/sourcemap/SourceMap.jsm +++ b/toolkit/devtools/sourcemap/SourceMap.jsm @@ -470,34 +470,10 @@ define('source-map/util', ['require', 'exports', 'module' , ], function(require, } exports.getArg = getArg; - var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/; - - function urlParse(aUrl) { - var match = aUrl.match(urlRegexp); - if (!match) { - return null; - } - return { - scheme: match[1], - auth: match[3], - host: match[4], - port: match[6], - path: match[7] - }; - } - function join(aRoot, aPath) { - var url; - - if (aPath.match(urlRegexp)) { - return aPath; - } - - if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) { - return aRoot.replace(url.path, '') + aPath; - } - - return aRoot.replace(/\/$/, '') + '/' + aPath; + return aPath.charAt(0) === '/' + ? aPath + : aRoot.replace(/\/$/, '') + '/' + aPath; } exports.join = join; diff --git a/toolkit/devtools/sourcemap/tests/unit/Utils.jsm b/toolkit/devtools/sourcemap/tests/unit/Utils.jsm index d78371f3757b..ceb12e0141d3 100644 --- a/toolkit/devtools/sourcemap/tests/unit/Utils.jsm +++ b/toolkit/devtools/sourcemap/tests/unit/Utils.jsm @@ -145,21 +145,9 @@ define('test/source-map/util', ['require', 'exports', 'module' , 'lib/source-ma assert.equal(origMapping.column, originalColumn, 'Incorrect column, expected ' + JSON.stringify(originalColumn) + ', got ' + JSON.stringify(origMapping.column)); - - var expectedSource; - - if (originalSource && map.sourceRoot && originalSource.indexOf(map.sourceRoot) === 0) { - expectedSource = originalSource; - } else if (originalSource) { - expectedSource = map.sourceRoot - ? util.join(map.sourceRoot, originalSource) - : originalSource; - } else { - expectedSource = null; - } - - assert.equal(origMapping.source, expectedSource, - 'Incorrect source, expected ' + JSON.stringify(expectedSource) + assert.equal(origMapping.source, + originalSource ? util.join(map._sourceRoot, originalSource) : null, + 'Incorrect source, expected ' + JSON.stringify(originalSource) + ', got ' + JSON.stringify(origMapping.source)); } @@ -250,34 +238,10 @@ define('lib/source-map/util', ['require', 'exports', 'module' , ], function(requ } exports.getArg = getArg; - var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/; - - function urlParse(aUrl) { - var match = aUrl.match(urlRegexp); - if (!match) { - return null; - } - return { - scheme: match[1], - auth: match[3], - host: match[4], - port: match[6], - path: match[7] - }; - } - function join(aRoot, aPath) { - var url; - - if (aPath.match(urlRegexp)) { - return aPath; - } - - if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) { - return aRoot.replace(url.path, '') + aPath; - } - - return aRoot.replace(/\/$/, '') + '/' + aPath; + return aPath.charAt(0) === '/' + ? aPath + : aRoot.replace(/\/$/, '') + '/' + aPath; } exports.join = join; diff --git a/toolkit/devtools/sourcemap/tests/unit/test_source_map_consumer.js b/toolkit/devtools/sourcemap/tests/unit/test_source_map_consumer.js index 515287004df1..3b7a59e7e11d 100644 --- a/toolkit/devtools/sourcemap/tests/unit/test_source_map_consumer.js +++ b/toolkit/devtools/sourcemap/tests/unit/test_source_map_consumer.js @@ -251,46 +251,8 @@ define("test/source-map/test-source-map-consumer", ["require", "exports", "modul map = new SourceMapConsumer(map.toString()); var sources = map.sources; - assert.equal(sources.length, 1); - assert.equal(sources[0], 'http://www.example.com/original.js'); - }; - - exports['test github issue #43'] = function (assert, util) { - var map = new SourceMapGenerator({ - sourceRoot: 'http://example.com', - file: 'foo.js' - }); - map.addMapping({ - original: { line: 1, column: 1 }, - generated: { line: 2, column: 2 }, - source: 'http://cdn.example.com/original.js' - }); - map = new SourceMapConsumer(map.toString()); - - var sources = map.sources; - assert.equal(sources.length, 1, - 'Should only be one source.'); - assert.equal(sources[0], 'http://cdn.example.com/original.js', - 'Should not be joined with the sourceRoot.'); - }; - - exports['test absolute path, but same host sources'] = function (assert, util) { - var map = new SourceMapGenerator({ - sourceRoot: 'http://example.com/foo/bar', - file: 'foo.js' - }); - map.addMapping({ - original: { line: 1, column: 1 }, - generated: { line: 2, column: 2 }, - source: '/original.js' - }); - map = new SourceMapConsumer(map.toString()); - - var sources = map.sources; - assert.equal(sources.length, 1, - 'Should only be one source.'); - assert.equal(sources[0], 'http://example.com/original.js', - 'Source should be relative the host of the source root.'); + assert.equal(map.sources.length, 1); + assert.equal(map.sources[0], 'http://www.example.com/original.js'); }; });