forked from zhoutony/html5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto.js
More file actions
39 lines (32 loc) · 1.13 KB
/
crypto.js
File metadata and controls
39 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var test = require('tap').test;
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var vm = require('vm');
var concat = require('concat-stream');
var mkdirp = require('mkdirp');
var tmpdir = '/tmp/browserify-test/' + Math.random().toString(16).slice(2);
mkdirp.sync(tmpdir);
fs.writeFileSync(tmpdir + '/main.js', 'beep(require("crypto"))\n');
test('*-browserify libs from node_modules/', function (t) {
t.plan(2);
var bin = __dirname + '/../bin/cmd.js';
var ps = spawn(process.execPath, [ bin, 'main.js' ], { cwd : tmpdir });
ps.stderr.pipe(process.stderr, { end : false });
ps.on('exit', function (code) {
t.equal(code, 0);
});
ps.stdout.pipe(concat(function (src) {
var c = {
Int32Array: Int32Array,
ArrayBuffer: ArrayBuffer,
Uint8Array: Uint8Array,
DataView: DataView,
beep : function (c) {
t.equal(typeof c.createHash, 'function');
},
require: function () {}
};
vm.runInNewContext(src.toString('utf8'), c);
}));
});