@@ -50,10 +50,12 @@ async.each(['vm', 'vm2'], (vmtype, cb) => {
50
50
} ) ;
51
51
52
52
it ( 'prevents asynchronus execution with Promises' , ( ) => {
53
- expect ( ( ) => xeval ( `() => {
53
+ const f = xeval ( `() => {
54
54
return new Promise((resolve, reject) => resolve())
55
55
.then(function(value) { while(true); })
56
- }` ) ) . to . throw ( 'Promises not supported' ) ;
56
+ }` ) ;
57
+ expect ( typeof f ) . to . equal ( 'function' ) ;
58
+ expect ( f ) . to . throw ( 'Promises not supported' ) ;
57
59
} ) ;
58
60
59
61
it ( 'prevents direct usage of built-in modules and globals' , ( ) => {
@@ -63,8 +65,9 @@ async.each(['vm', 'vm2'], (vmtype, cb) => {
63
65
} ) ;
64
66
65
67
it ( 'prevents requiring modules' , ( ) => {
66
- expect ( xeval ( '() => require("console").log("Hi")' ) ) . to . throw (
67
- 'require is not defined' ) ;
68
+ const f = xeval ( '() => require("console").log("Hi")' ) ;
69
+ expect ( typeof f ) . to . equal ( 'function' ) ;
70
+ expect ( f ) . to . throw ( 'require is not defined' ) ;
68
71
} ) ;
69
72
70
73
vm2it ( 'prevents escaping via this.constructor.constructor' , ( ) => {
@@ -87,7 +90,9 @@ async.each(['vm', 'vm2'], (vmtype, cb) => {
87
90
} ) ;
88
91
89
92
it ( 'rejects arguments.callee' , ( ) => {
90
- expect ( xeval ( 'function (x) { return arguments.callee; }' ) ) . to . throw (
93
+ const f = xeval ( 'function (x) { return arguments.callee; }' ) ;
94
+ expect ( typeof f ) . to . equal ( 'function' ) ;
95
+ expect ( f ) . to . throw (
91
96
'\'caller\', \'callee\', and \'arguments\' properties ' +
92
97
'may not be accessed on strict mode functions or the arguments ' +
93
98
'objects for calls to them' ) ;
0 commit comments