1+ import '../common/index.mjs' ;
12import tmpdir from '../common/tmpdir.js' ;
23import assert from 'node:assert/strict' ;
34import { once } from 'node:events' ;
@@ -13,23 +14,23 @@ function convertScriptSourceToDataUrl(script) {
1314 return new URL ( `data:text/javascript,${ encodeURIComponent ( script ) } ` ) ;
1415}
1516
16- describe ( " Worker threads should not be able to access internal modules" , ( ) => {
17+ describe ( ' Worker threads should not be able to access internal modules' , ( ) => {
1718 before ( ( ) => tmpdir . refresh ( ) ) ;
1819
19- test ( " worker instantiated with module file path" , async ( ) => {
20+ test ( ' worker instantiated with module file path' , async ( ) => {
2021 const moduleFilepath = tmpdir . resolve ( 'test-worker-internal-modules.mjs' ) ;
2122 await fs . writeFile ( moduleFilepath , accessInternalsSource ) ;
22- const w = new Worker ( moduleFilepath )
23- await assert . rejects ( once ( w , " exit" ) )
24- } )
23+ const w = new Worker ( moduleFilepath ) ;
24+ await assert . rejects ( once ( w , ' exit' ) , { code : 'ERR_UNKNOWN_BUILTIN_MODULE' } ) ;
25+ } ) ;
2526
26- test ( " worker instantiated with module source" , async ( ) => {
27- const w = new Worker ( accessInternalsSource , { eval : true } )
28- await assert . rejects ( once ( w , " exit" ) )
29- } )
27+ test ( ' worker instantiated with module source' , async ( ) => {
28+ const w = new Worker ( accessInternalsSource , { eval : true } ) ;
29+ await assert . rejects ( once ( w , ' exit' ) , { code : 'ERR_UNKNOWN_BUILTIN_MODULE' } ) ;
30+ } ) ;
3031
31- test ( " worker instantiated with data: URL" , async ( ) => {
32- const w = new Worker ( convertScriptSourceToDataUrl ( accessInternalsSource ) )
33- await assert . rejects ( once ( w , " exit" ) )
34- } )
35- } )
32+ test ( ' worker instantiated with data: URL' , async ( ) => {
33+ const w = new Worker ( convertScriptSourceToDataUrl ( accessInternalsSource ) ) ;
34+ await assert . rejects ( once ( w , ' exit' ) , { code : 'ERR_UNKNOWN_BUILTIN_MODULE' } ) ;
35+ } ) ;
36+ } ) ;
0 commit comments