node/test/parallel/test-permission-net-websocket.js
Rafael Gonzaga 462c74181d
src,permission: add --allow-net permission
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/58517
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2025-06-17 12:35:23 +00:00

18 lines
576 B
JavaScript

// Flags: --permission --allow-fs-read=*
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('no crypto');
}
const wsUrl = 'ws://nodejs.org';
const ws = new WebSocket(wsUrl);
ws.addEventListener('open', common.mustNotCall('WebSocket connection should be blocked'));
// WebSocket implementation doesn't expose the Node.js specific errors
// so ERR_ACCESS_DENIED won't be "caught" explicitly.
// For now, let's just assert the error
// TODO(rafaelgss): make this test more comprehensive
ws.addEventListener('error', common.mustCall());