Now using vm module in node instead of process.binding.Script (deprecated in newer versions of node)
parent
27eea93d6f
commit
1a3b5f2893
|
@ -36,7 +36,7 @@ var _handler = null;
|
||||||
*
|
*
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
var _console = console;
|
var _console = ( typeof console !== 'undefined' ) ? console : undefined;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,14 +29,15 @@
|
||||||
|
|
||||||
var common = require( './common' ),
|
var common = require( './common' ),
|
||||||
assert = require( 'assert' ),
|
assert = require( 'assert' ),
|
||||||
|
vm = require( 'vm' ),
|
||||||
Class = common.require( 'class' ),
|
Class = common.require( 'class' ),
|
||||||
Script = process.binding( 'evals' ).Script,
|
|
||||||
|
|
||||||
// sandbox in which combined script will be run
|
// sandbox in which combined script will be run
|
||||||
sandbox = {
|
sandbox = vm.createContext( {
|
||||||
// stub document.write() so we don't blow up
|
// stub document.write() so we don't blow up
|
||||||
document: { write: function() {} },
|
document: { write: function() {} },
|
||||||
};
|
runTests: null,
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
var file = 'ease-full.js';
|
var file = 'ease-full.js';
|
||||||
|
@ -69,8 +70,7 @@ data = "delete Object.defineProperty;" +
|
||||||
;
|
;
|
||||||
|
|
||||||
// run the script (if this fails to compile, the generated code is invalid)
|
// run the script (if this fails to compile, the generated code is invalid)
|
||||||
var cmb_script = new Script( data );
|
vm.runInNewContext( data, sandbox );
|
||||||
cmb_script.runInNewContext( sandbox );
|
|
||||||
|
|
||||||
// cross your fingers
|
// cross your fingers
|
||||||
sandbox.easejs.runTests();
|
sandbox.easejs.runTests();
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
var common = require( './common' ),
|
var common = require( './common' ),
|
||||||
assert = require( 'assert' ),
|
assert = require( 'assert' ),
|
||||||
|
vm = require( 'vm' ),
|
||||||
Class = common.require( 'class' ),
|
Class = common.require( 'class' ),
|
||||||
Script = process.binding( 'evals' ).Script,
|
|
||||||
|
|
||||||
// sandbox in which combined script will be run
|
// sandbox in which combined script will be run
|
||||||
sandbox = {
|
sandbox = {
|
||||||
|
@ -60,8 +60,7 @@ while ( i-- )
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the script (if this fails to compile, the generated code is invalid)
|
// run the script (if this fails to compile, the generated code is invalid)
|
||||||
var cmb_script = new Script( data );
|
vm.runInNewContext( data, sandbox );
|
||||||
cmb_script.runInNewContext( sandbox );
|
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
sandbox.require,
|
sandbox.require,
|
||||||
|
|
|
@ -30,6 +30,8 @@ var common = require( './common' ),
|
||||||
warning = Warning( Error( 'gninraw' ) )
|
warning = Warning( Error( 'gninraw' ) )
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if ( typeof console === 'undefined' ) console = undefined;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The log warning handler should log warnings to the console
|
* The log warning handler should log warnings to the console
|
||||||
|
|
|
@ -27,6 +27,8 @@ var common = require( './common' ),
|
||||||
warn = common.require( 'warn' )
|
warn = common.require( 'warn' )
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if ( typeof console === 'undefined' ) console = undefined;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default warning handler should be the 'log' handler. This is a friendly
|
* The default warning handler should be the 'log' handler. This is a friendly
|
||||||
|
|
Loading…
Reference in New Issue