aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorb-fuze <b-fuze.root@live.com>2018-03-31 07:26:40 -0400
committerAlex Lam S.L <alexlamsl@gmail.com>2018-03-31 20:26:40 +0900
commit8adfc29f914efd2af62638491b6c3034e1cc8712 (patch)
tree8857313f6c50f96972ea274f16bb1565a2a59f2c /test/mocha
parent02f47e1713cb413ac0d2602039c18292f43db863 (diff)
downloadtracifyjs-8adfc29f914efd2af62638491b6c3034e1cc8712.tar.gz
tracifyjs-8adfc29f914efd2af62638491b6c3034e1cc8712.zip
Don't load source map until the JS source is fully received (#3040)
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/cli.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 7f0bd79f..7385e477 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -1,9 +1,9 @@
var assert = require("assert");
var exec = require("child_process").exec;
-var readFileSync = require("fs").readFileSync;
+var fs = require("fs");
function read(path) {
- return readFileSync(path, "utf8");
+ return fs.readFileSync(path, "utf8");
}
describe("bin/uglifyjs", function () {
@@ -106,6 +106,35 @@ describe("bin/uglifyjs", function () {
done();
});
});
+ it("Should not load source map before finish reading from STDIN", function(done) {
+ var mapFile = "tmp/input.js.map";
+ try {
+ fs.mkdirSync("./tmp");
+ } catch (e) {
+ if (e.code != "EEXIST") throw e;
+ }
+ try {
+ fs.unlinkSync(mapFile);
+ } catch (e) {
+ if (e.code != "ENOENT") throw e;
+ }
+ var command = [
+ uglifyjscmd,
+ "--source-map", "content=" + mapFile,
+ "--source-map", "url=inline"
+ ].join(" ");
+
+ var child = exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, read("test/input/pr-3040/expect.js"));
+ done();
+ });
+ setTimeout(function() {
+ fs.writeFileSync(mapFile, read("test/input/pr-3040/input.js.map"));
+ child.stdin.end(read("test/input/pr-3040/input.js"));
+ }, 1000);
+ });
it("Should work with --keep-fnames (mangle only)", function (done) {
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m';