File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,12 @@ function setupGlobalVariables() {
408408 enumerable : false ,
409409 configurable : true
410410 } ) ;
411- global . process = process ;
411+ Object . defineProperty ( global , 'process' , {
412+ value : process ,
413+ enumerable : false ,
414+ writable : true ,
415+ configurable : true
416+ } ) ;
412417 const util = NativeModule . require ( 'util' ) ;
413418
414419 function makeGetter ( name ) {
@@ -445,7 +450,12 @@ function setupGlobalVariables() {
445450 // and exposes it on `internal/buffer`.
446451 NativeModule . require ( 'internal/buffer' ) ;
447452
448- global . Buffer = NativeModule . require ( 'buffer' ) . Buffer ;
453+ Object . defineProperty ( global , 'Buffer' , {
454+ value : NativeModule . require ( 'buffer' ) . Buffer ,
455+ enumerable : false ,
456+ writable : true ,
457+ configurable : true
458+ } ) ;
449459 process . domain = null ;
450460 process . _exiting = false ;
451461}
Original file line number Diff line number Diff line change @@ -217,12 +217,10 @@ function platformTimeout(ms) {
217217}
218218
219219let knownGlobals = [
220- Buffer ,
221220 clearImmediate ,
222221 clearInterval ,
223222 clearTimeout ,
224223 global ,
225- process ,
226224 setImmediate ,
227225 setInterval ,
228226 setTimeout
Original file line number Diff line number Diff line change @@ -27,6 +27,41 @@ const common = require('../common');
2727const fixtures = require ( '../common/fixtures' ) ;
2828
2929const assert = require ( 'assert' ) ;
30+ const { builtinModules } = require ( 'module' ) ;
31+
32+ // Load all modules to actually cover most code parts.
33+ builtinModules . forEach ( ( moduleName ) => {
34+ if ( ! moduleName . includes ( '/' ) ) {
35+ try {
36+ // This could throw for e.g., crypto if the binary is not compiled
37+ // accordingly.
38+ require ( moduleName ) ;
39+ } catch { }
40+ }
41+ } ) ;
42+
43+ {
44+ const expected = [
45+ 'global' ,
46+ 'clearImmediate' ,
47+ 'clearInterval' ,
48+ 'clearTimeout' ,
49+ 'setImmediate' ,
50+ 'setInterval' ,
51+ 'setTimeout'
52+ ] ;
53+ if ( global . DTRACE_HTTP_SERVER_RESPONSE ) {
54+ expected . unshift (
55+ 'DTRACE_HTTP_SERVER_RESPONSE' ,
56+ 'DTRACE_HTTP_SERVER_REQUEST' ,
57+ 'DTRACE_HTTP_CLIENT_RESPONSE' ,
58+ 'DTRACE_HTTP_CLIENT_REQUEST' ,
59+ 'DTRACE_NET_STREAM_END' ,
60+ 'DTRACE_NET_SERVER_CONNECTION'
61+ ) ;
62+ }
63+ assert . deepStrictEqual ( new Set ( Object . keys ( global ) ) , new Set ( expected ) ) ;
64+ }
3065
3166common . allowGlobals ( 'bar' , 'foo' ) ;
3267
You can’t perform that action at this time.
0 commit comments