55const common = require ( '../common' ) ;
66common . skipIfInspectorDisabled ( ) ;
77
8- const { ifError , strictEqual } = require ( 'assert' ) ;
9- const { createContext , runInNewContext } = require ( 'vm' ) ;
8+ const assert = require ( 'assert' ) ;
9+ const vm = require ( 'vm' ) ;
1010const { Session } = require ( 'inspector' ) ;
1111
1212const session = new Session ( ) ;
@@ -31,18 +31,18 @@ async function testContextCreatedAndDestroyed() {
3131 // "Administrator: Windows PowerShell[42]" because of a GetConsoleTitle()
3232 // quirk. Not much we can do about either, just verify that it contains
3333 // the PID.
34- strictEqual ( name . includes ( `[${ process . pid } ]` ) , true ) ;
34+ assert . strictEqual ( name . includes ( `[${ process . pid } ]` ) , true ) ;
3535 } else {
3636 let expects = `${ process . argv0 } [${ process . pid } ]` ;
3737 if ( ! common . isMainThread ) {
3838 expects = `Worker[${ require ( 'worker_threads' ) . threadId } ]` ;
3939 }
40- strictEqual ( expects , name ) ;
40+ assert . strictEqual ( expects , name ) ;
4141 }
42- strictEqual ( origin , '' ,
43- JSON . stringify ( contextCreated ) ) ;
44- strictEqual ( auxData . isDefault , true ,
45- JSON . stringify ( contextCreated ) ) ;
42+ assert . strictEqual ( origin , '' ,
43+ JSON . stringify ( contextCreated ) ) ;
44+ assert . strictEqual ( auxData . isDefault , true ,
45+ JSON . stringify ( contextCreated ) ) ;
4646 }
4747
4848 {
@@ -53,23 +53,23 @@ async function testContextCreatedAndDestroyed() {
5353 session . once ( 'Runtime.executionContextDestroyed' ,
5454 ( notification ) => contextDestroyed = notification ) ;
5555
56- runInNewContext ( '1 + 1' ) ;
56+ vm . runInNewContext ( '1 + 1' ) ;
5757
5858 const contextCreated = await vmContextCreatedPromise ;
5959 const { id, name, origin, auxData } = contextCreated . params . context ;
60- strictEqual ( name , 'VM Context 1' ,
61- JSON . stringify ( contextCreated ) ) ;
62- strictEqual ( origin , '' ,
63- JSON . stringify ( contextCreated ) ) ;
64- strictEqual ( auxData . isDefault , false ,
65- JSON . stringify ( contextCreated ) ) ;
60+ assert . strictEqual ( name , 'VM Context 1' ,
61+ JSON . stringify ( contextCreated ) ) ;
62+ assert . strictEqual ( origin , '' ,
63+ JSON . stringify ( contextCreated ) ) ;
64+ assert . strictEqual ( auxData . isDefault , false ,
65+ JSON . stringify ( contextCreated ) ) ;
6666
6767 // GC is unpredictable...
6868 while ( ! contextDestroyed )
6969 global . gc ( ) ;
7070
71- strictEqual ( contextDestroyed . params . executionContextId , id ,
72- JSON . stringify ( contextDestroyed ) ) ;
71+ assert . strictEqual ( contextDestroyed . params . executionContextId , id ,
72+ JSON . stringify ( contextDestroyed ) ) ;
7373 }
7474
7575 {
@@ -80,19 +80,19 @@ async function testContextCreatedAndDestroyed() {
8080 session . once ( 'Runtime.executionContextDestroyed' ,
8181 ( notification ) => contextDestroyed = notification ) ;
8282
83- runInNewContext ( '1 + 1' , { } , {
83+ vm . runInNewContext ( '1 + 1' , { } , {
8484 contextName : 'Custom context' ,
8585 contextOrigin : 'https://origin.example'
8686 } ) ;
8787
8888 const contextCreated = await vmContextCreatedPromise ;
8989 const { name, origin, auxData } = contextCreated . params . context ;
90- strictEqual ( name , 'Custom context' ,
91- JSON . stringify ( contextCreated ) ) ;
92- strictEqual ( origin , 'https://origin.example' ,
93- JSON . stringify ( contextCreated ) ) ;
94- strictEqual ( auxData . isDefault , false ,
95- JSON . stringify ( contextCreated ) ) ;
90+ assert . strictEqual ( name , 'Custom context' ,
91+ JSON . stringify ( contextCreated ) ) ;
92+ assert . strictEqual ( origin , 'https://origin.example' ,
93+ JSON . stringify ( contextCreated ) ) ;
94+ assert . strictEqual ( auxData . isDefault , false ,
95+ JSON . stringify ( contextCreated ) ) ;
9696
9797 // GC is unpredictable...
9898 while ( ! contextDestroyed )
@@ -107,16 +107,16 @@ async function testContextCreatedAndDestroyed() {
107107 session . once ( 'Runtime.executionContextDestroyed' ,
108108 ( notification ) => contextDestroyed = notification ) ;
109109
110- createContext ( { } , { origin : 'https://nodejs.org' } ) ;
110+ vm . createContext ( { } , { origin : 'https://nodejs.org' } ) ;
111111
112112 const contextCreated = await vmContextCreatedPromise ;
113113 const { name, origin, auxData } = contextCreated . params . context ;
114- strictEqual ( name , 'VM Context 2' ,
115- JSON . stringify ( contextCreated ) ) ;
116- strictEqual ( origin , 'https://nodejs.org' ,
117- JSON . stringify ( contextCreated ) ) ;
118- strictEqual ( auxData . isDefault , false ,
119- JSON . stringify ( contextCreated ) ) ;
114+ assert . strictEqual ( name , 'VM Context 2' ,
115+ JSON . stringify ( contextCreated ) ) ;
116+ assert . strictEqual ( origin , 'https://nodejs.org' ,
117+ JSON . stringify ( contextCreated ) ) ;
118+ assert . strictEqual ( auxData . isDefault , false ,
119+ JSON . stringify ( contextCreated ) ) ;
120120
121121 // GC is unpredictable...
122122 while ( ! contextDestroyed )
@@ -131,14 +131,14 @@ async function testContextCreatedAndDestroyed() {
131131 session . once ( 'Runtime.executionContextDestroyed' ,
132132 ( notification ) => contextDestroyed = notification ) ;
133133
134- createContext ( { } , { name : 'Custom context 2' } ) ;
134+ vm . createContext ( { } , { name : 'Custom context 2' } ) ;
135135
136136 const contextCreated = await vmContextCreatedPromise ;
137137 const { name, auxData } = contextCreated . params . context ;
138- strictEqual ( name , 'Custom context 2' ,
139- JSON . stringify ( contextCreated ) ) ;
140- strictEqual ( auxData . isDefault , false ,
141- JSON . stringify ( contextCreated ) ) ;
138+ assert . strictEqual ( name , 'Custom context 2' ,
139+ JSON . stringify ( contextCreated ) ) ;
140+ assert . strictEqual ( auxData . isDefault , false ,
141+ JSON . stringify ( contextCreated ) ) ;
142142
143143 // GC is unpredictable...
144144 while ( ! contextDestroyed )
@@ -151,7 +151,7 @@ async function testBreakpointHit() {
151151 session . post ( 'Debugger.enable' , assert . ifError ) ;
152152
153153 const pausedPromise = notificationPromise ( 'Debugger.paused' ) ;
154- runInNewContext ( 'debugger' , { } ) ;
154+ vm . runInNewContext ( 'debugger' , { } ) ;
155155 await pausedPromise ;
156156}
157157
0 commit comments