blob: 7e148bd4d0b94f0d63b542d656dfea4552a9d144 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
'use strict';
require('../common');
var assert = require('assert');
var vm = require('vm');
var spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
const code = 'while(true);';
const ctx = vm.createContext();
vm.runInContext(code, ctx, { timeout: 1 });
} else {
var proc = spawn(process.execPath, process.argv.slice(1).concat('child'));
var err = '';
proc.stderr.on('data', function(data) {
err += data;
});
process.on('exit', function() {
assert.ok(/Script execution timed out/.test(err));
});
}
|