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 {
3636let expects = `${ process . argv0 } [${ process . pid } ]` ;
3737if ( ! common . isMainThread ) {
3838expects = `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(){
5353session . once ( 'Runtime.executionContextDestroyed' ,
5454( notification ) => contextDestroyed = notification ) ;
5555
56- runInNewContext ( '1 + 1' ) ;
56+ vm . runInNewContext ( '1 + 1' ) ;
5757
5858const contextCreated = await vmContextCreatedPromise ;
5959const { 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...
6868while ( ! contextDestroyed )
6969global . 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(){
8080session . once ( 'Runtime.executionContextDestroyed' ,
8181( notification ) => contextDestroyed = notification ) ;
8282
83- runInNewContext ( '1 + 1' , { } , {
83+ vm . runInNewContext ( '1 + 1' , { } , {
8484contextName : 'Custom context' ,
8585contextOrigin : 'https://origin.example'
8686} ) ;
8787
8888const contextCreated = await vmContextCreatedPromise ;
8989const { 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...
9898while ( ! contextDestroyed )
@@ -107,16 +107,16 @@ async function testContextCreatedAndDestroyed(){
107107session . once ( 'Runtime.executionContextDestroyed' ,
108108( notification ) => contextDestroyed = notification ) ;
109109
110- createContext ( { } , { origin : 'https://nodejs.org' } ) ;
110+ vm . createContext ( { } , { origin : 'https://nodejs.org' } ) ;
111111
112112const contextCreated = await vmContextCreatedPromise ;
113113const { 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...
122122while ( ! contextDestroyed )
@@ -131,14 +131,14 @@ async function testContextCreatedAndDestroyed(){
131131session . once ( 'Runtime.executionContextDestroyed' ,
132132( notification ) => contextDestroyed = notification ) ;
133133
134- createContext ( { } , { name : 'Custom context 2' } ) ;
134+ vm . createContext ( { } , { name : 'Custom context 2' } ) ;
135135
136136const contextCreated = await vmContextCreatedPromise ;
137137const { 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...
144144while ( ! contextDestroyed )
@@ -151,7 +151,7 @@ async function testBreakpointHit(){
151151session . post ( 'Debugger.enable' , assert . ifError ) ;
152152
153153const pausedPromise = notificationPromise ( 'Debugger.paused' ) ;
154- runInNewContext ( 'debugger' , { } ) ;
154+ vm . runInNewContext ( 'debugger' , { } ) ;
155155await pausedPromise ;
156156}
157157
0 commit comments