2023-07-26 18:32:03 +00:00
|
|
|
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
2023-05-07 16:22:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfWorker();
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
|
|
|
|
const { Session } = require('inspector');
|
|
|
|
const assert = require('assert');
|
2023-07-26 18:32:03 +00:00
|
|
|
const { spawnSync } = require('child_process');
|
2023-05-07 16:22:32 +00:00
|
|
|
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('no crypto');
|
|
|
|
|
|
|
|
{
|
|
|
|
assert.throws(() => {
|
|
|
|
const session = new Session();
|
|
|
|
session.connect();
|
|
|
|
}, common.expectsError({
|
|
|
|
code: 'ERR_ACCESS_DENIED',
|
|
|
|
permission: 'Inspector',
|
|
|
|
}));
|
|
|
|
}
|
2023-07-26 18:32:03 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
const { status, stderr } = spawnSync(
|
|
|
|
process.execPath,
|
|
|
|
[
|
|
|
|
'--experimental-permission',
|
|
|
|
'-e',
|
|
|
|
'(new (require("inspector")).Session()).connect()',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
assert.strictEqual(status, 1);
|
|
|
|
assert.match(stderr.toString(), /Error: Access to this API has been restricted/);
|
|
|
|
}
|