@@ -25,7 +25,7 @@ assert.strictEqual('lala', context.thing);
25
25
// Issue GH-227:
26
26
assert . throws ( function ( ) {
27
27
vm . runInNewContext ( '' , null , 'some.js' ) ;
28
- } , TypeError ) ;
28
+ } , / ^ T y p e E r r o r : s a n d b o x m u s t b e a n o b j e c t $ / ) ;
29
29
30
30
// Issue GH-1140:
31
31
console . error ( 'test runInContext signature' ) ;
@@ -41,9 +41,18 @@ assert.ok(gh1140Exception,
41
41
'expected exception from runInContext signature test' ) ;
42
42
43
43
// GH-558, non-context argument segfaults / raises assertion
44
- [ undefined , null , 0 , 0.0 , '' , { } , [ ] ] . forEach ( function ( e ) {
45
- assert . throws ( function ( ) { script . runInContext ( e ) ; } , TypeError ) ;
46
- assert . throws ( function ( ) { vm . runInContext ( '' , e ) ; } , TypeError ) ;
44
+ const nonContextualSandboxErrorMsg =
45
+ / ^ T y p e E r r o r : c o n t e x t i f i e d S a n d b o x a r g u m e n t m u s t b e a n o b j e c t \. $ / ;
46
+ const contextifiedSandboxErrorMsg =
47
+ / ^ T y p e E r r o r : s a n d b o x a r g u m e n t m u s t h a v e b e e n c o n v e r t e d t o a c o n t e x t \. $ / ;
48
+ [
49
+ [ undefined , nonContextualSandboxErrorMsg ] ,
50
+ [ null , nonContextualSandboxErrorMsg ] , [ 0 , nonContextualSandboxErrorMsg ] ,
51
+ [ 0.0 , nonContextualSandboxErrorMsg ] , [ '' , nonContextualSandboxErrorMsg ] ,
52
+ [ { } , contextifiedSandboxErrorMsg ] , [ [ ] , contextifiedSandboxErrorMsg ]
53
+ ] . forEach ( ( e ) => {
54
+ assert . throws ( ( ) => { script . runInContext ( e [ 0 ] ) ; } , e [ 1 ] ) ;
55
+ assert . throws ( ( ) => { vm . runInContext ( '' , e [ 0 ] ) ; } , e [ 1 ] ) ;
47
56
} ) ;
48
57
49
58
// Issue GH-693:
0 commit comments