5
5
const common = require ( '../common' ) ;
6
6
common . skipIfInspectorDisabled ( ) ;
7
7
8
- const { ifError , strictEqual } = require ( 'assert' ) ;
9
- const { createContext , runInNewContext } = require ( 'vm' ) ;
8
+ const assert = require ( 'assert' ) ;
9
+ const vm = require ( 'vm' ) ;
10
10
const { Session } = require ( 'inspector' ) ;
11
11
12
12
const session = new Session ( ) ;
@@ -31,18 +31,18 @@ async function testContextCreatedAndDestroyed() {
31
31
// "Administrator: Windows PowerShell[42]" because of a GetConsoleTitle()
32
32
// quirk. Not much we can do about either, just verify that it contains
33
33
// the PID.
34
- strictEqual ( name . includes ( `[${ process . pid } ]` ) , true ) ;
34
+ assert . strictEqual ( name . includes ( `[${ process . pid } ]` ) , true ) ;
35
35
} else {
36
36
let expects = `${ process . argv0 } [${ process . pid } ]` ;
37
37
if ( ! common . isMainThread ) {
38
38
expects = `Worker[${ require ( 'worker_threads' ) . threadId } ]` ;
39
39
}
40
- strictEqual ( expects , name ) ;
40
+ assert . strictEqual ( expects , name ) ;
41
41
}
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 ) ) ;
46
46
}
47
47
48
48
{
@@ -53,23 +53,23 @@ async function testContextCreatedAndDestroyed() {
53
53
session . once ( 'Runtime.executionContextDestroyed' ,
54
54
( notification ) => contextDestroyed = notification ) ;
55
55
56
- runInNewContext ( '1 + 1' ) ;
56
+ vm . runInNewContext ( '1 + 1' ) ;
57
57
58
58
const contextCreated = await vmContextCreatedPromise ;
59
59
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 ) ) ;
66
66
67
67
// GC is unpredictable...
68
68
while ( ! contextDestroyed )
69
69
global . gc ( ) ;
70
70
71
- strictEqual ( contextDestroyed . params . executionContextId , id ,
72
- JSON . stringify ( contextDestroyed ) ) ;
71
+ assert . strictEqual ( contextDestroyed . params . executionContextId , id ,
72
+ JSON . stringify ( contextDestroyed ) ) ;
73
73
}
74
74
75
75
{
@@ -80,19 +80,19 @@ async function testContextCreatedAndDestroyed() {
80
80
session . once ( 'Runtime.executionContextDestroyed' ,
81
81
( notification ) => contextDestroyed = notification ) ;
82
82
83
- runInNewContext ( '1 + 1' , { } , {
83
+ vm . runInNewContext ( '1 + 1' , { } , {
84
84
contextName : 'Custom context' ,
85
85
contextOrigin : 'https://origin.example'
86
86
} ) ;
87
87
88
88
const contextCreated = await vmContextCreatedPromise ;
89
89
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 ) ) ;
96
96
97
97
// GC is unpredictable...
98
98
while ( ! contextDestroyed )
@@ -107,16 +107,16 @@ async function testContextCreatedAndDestroyed() {
107
107
session . once ( 'Runtime.executionContextDestroyed' ,
108
108
( notification ) => contextDestroyed = notification ) ;
109
109
110
- createContext ( { } , { origin : 'https://nodejs.org' } ) ;
110
+ vm . createContext ( { } , { origin : 'https://nodejs.org' } ) ;
111
111
112
112
const contextCreated = await vmContextCreatedPromise ;
113
113
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 ) ) ;
120
120
121
121
// GC is unpredictable...
122
122
while ( ! contextDestroyed )
@@ -131,14 +131,14 @@ async function testContextCreatedAndDestroyed() {
131
131
session . once ( 'Runtime.executionContextDestroyed' ,
132
132
( notification ) => contextDestroyed = notification ) ;
133
133
134
- createContext ( { } , { name : 'Custom context 2' } ) ;
134
+ vm . createContext ( { } , { name : 'Custom context 2' } ) ;
135
135
136
136
const contextCreated = await vmContextCreatedPromise ;
137
137
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 ) ) ;
142
142
143
143
// GC is unpredictable...
144
144
while ( ! contextDestroyed )
@@ -151,7 +151,7 @@ async function testBreakpointHit() {
151
151
session . post ( 'Debugger.enable' , assert . ifError ) ;
152
152
153
153
const pausedPromise = notificationPromise ( 'Debugger.paused' ) ;
154
- runInNewContext ( 'debugger' , { } ) ;
154
+ vm . runInNewContext ( 'debugger' , { } ) ;
155
155
await pausedPromise ;
156
156
}
157
157
0 commit comments