forked from nwjs/nw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocha_test.js
More file actions
56 lines (40 loc) · 1.13 KB
/
mocha_test.js
File metadata and controls
56 lines (40 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var path = require('path');
var app_test = require('./nw_test_app');
var server = global.server;
var cb;
describe('new-instance', function() {
after(function() {
server.removeListener('connection', cb);
});
it('new window has different pid', function(done) {
this.timeout(0);
var result = false;
var times = 0;
var pid1, pid2;
var child = app_test.createChildProcess({
execPath: process.execPath,
appPath: path.join(global.tests_dir, 'new-instance'),
no_connect: true,
});
server.on('connection', cb = function(socket){
socket.setEncoding('utf8');
socket.on('error', function(er) {
console.log(er);
})
socket.on('data', function(data) {
if (times == 0) {
pid1 = data;
times += 1;
} else {
pid2 = data;
if (pid1 != pid2) {
done();
} else {
done('they are in the same process');
}
child.app.kill();
} // if (times == 0)
});
}); // server.on('connection', cb = function(socket)
})
})