1
+ import '../common/index.mjs' ;
1
2
import tmpdir from '../common/tmpdir.js' ;
2
3
import assert from 'node:assert/strict' ;
3
4
import { once } from 'node:events' ;
@@ -13,23 +14,23 @@ function convertScriptSourceToDataUrl(script) {
13
14
return new URL ( `data:text/javascript,${ encodeURIComponent ( script ) } ` ) ;
14
15
}
15
16
16
- describe ( " Worker threads should not be able to access internal modules" , ( ) => {
17
+ describe ( ' Worker threads should not be able to access internal modules' , ( ) => {
17
18
before ( ( ) => tmpdir . refresh ( ) ) ;
18
19
19
- test ( " worker instantiated with module file path" , async ( ) => {
20
+ test ( ' worker instantiated with module file path' , async ( ) => {
20
21
const moduleFilepath = tmpdir . resolve ( 'test-worker-internal-modules.mjs' ) ;
21
22
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
+ } ) ;
25
26
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
+ } ) ;
30
31
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