Skip to content

Commit

Permalink
src: fix permission inspector crash
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed Jun 8, 2024
1 parent 2693f09 commit 7573b6b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ void SetConsoleExtensionInstaller(const FunctionCallbackInfo<Value>& info) {

void CallAndPauseOnStart(const FunctionCallbackInfo<v8::Value>& args) {
Environment* env = Environment::GetCurrent(args);
THROW_IF_INSUFFICIENT_PERMISSIONS(env,
permission::PermissionScope::kInspector,
"PauseOnNextJavascriptStatement");
CHECK_GT(args.Length(), 1);
CHECK(args[0]->IsFunction());
SlicedArguments call_args(args, /* start */ 2);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/permission/inspector-brk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('done');
23 changes: 23 additions & 0 deletions test/parallel/test-permission-inspector-brk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const fixtures = require('../common/fixtures');
const file = fixtures.path('permission', 'inspector-brk.js');

common.skipIfWorker();
common.skipIfInspectorDisabled();

const { status, stderr } = spawnSync(
process.execPath,
[
'--experimental-permission',
'--allow-fs-read=*',
'--inspect-brk',
file,
],
);

assert.strictEqual(status, 1);
assert.match(stderr.toString(), /Error: Access to this API has been restricted/);

0 comments on commit 7573b6b

Please sign in to comment.