-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dfe77a
commit 407ae89
Showing
5 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { spawnPromisified } from '../common/index.mjs'; | ||
import { describe, it } from 'node:test'; | ||
import { strictEqual } from 'node:assert'; | ||
|
||
|
||
describe('--disable-global', { concurrency: true }, () => { | ||
it('disables one global', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-global', 'navigator', | ||
'--eval', 'console.log(typeof navigator)', | ||
]); | ||
|
||
strictEqual(stderr, ''); | ||
strictEqual(stdout, 'undefined\n'); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
|
||
it('disables all the globals in the supported list', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-global', 'CustomEvent', | ||
'--disable-global', 'fetch', | ||
'--disable-global', 'navigator', | ||
'--disable-global', 'WebSocket', | ||
'--print', | ||
`[ | ||
'CustomEvent', | ||
'fetch', 'FormData', 'Headers', 'Request', 'Response', | ||
'navigator', | ||
'WebSocket', | ||
].filter(name => typeof globalThis[name] !== 'undefined')`, | ||
]); | ||
|
||
strictEqual(stderr, ''); | ||
strictEqual(stdout, '[]\n'); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
|
||
it('is case insensitive', async () => { | ||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ | ||
'--disable-global', 'customevent', | ||
'--disable-global', 'websocket', | ||
'--print', | ||
`[ | ||
'CustomEvent', | ||
'WebSocket', | ||
].filter(name => typeof globalThis[name] !== 'undefined')`, | ||
]); | ||
|
||
strictEqual(stderr, ''); | ||
strictEqual(stdout, '[]\n'); | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
}); | ||
}); |