Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: allow opening inspector when NODE_V8_COVERAGE is set #46113

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo<Value>& args) {

void IsEnabled(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
args.GetReturnValue().Set(InspectorEnabled(env));
args.GetReturnValue().Set(env->inspector_agent()->IsListening());
}

void Open(const FunctionCallbackInfo<Value>& args) {
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/inspector-open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const assert = require('assert');
const inspector = require('inspector');


assert.strictEqual(inspector.url(), undefined);
inspector.open(0, undefined, false);
assert(inspector.url().startsWith('ws://'));
assert.throws(() => {
inspector.open(0, undefined, false);
}, {
code: 'ERR_INSPECTOR_ALREADY_ACTIVATED'
});
inspector.close();
assert.strictEqual(inspector.url(), undefined);
21 changes: 21 additions & 0 deletions test/parallel/test-inspector-open-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');

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

tmpdir.refresh();


let output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')]);
assert.strictEqual(output.status, 0);

output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')], {
env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path },
});
assert.strictEqual(output.status, 0);