node/test/sequential/test-inspector-async-call-stack-abort.js
Anna Henningsen aec34473a7
test: remove usage of process.binding()
Prefer `internalBinding` or other equivalents over `process.binding()`
(except in tests checking `process.binding()` itself).

PR-URL: https://github.com/nodejs/node/pull/26304
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-07 17:43:21 +01:00

38 lines
1.3 KiB
JavaScript

// Check that abrupt termination when async call stack recording is enabled
// does not segfault the process.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
const { strictEqual } = require('assert');
const eyecatcher = 'nou, houdoe he?';
if (process.argv[2] === 'child') {
common.disableCrashOnUnhandledRejection();
const { Session } = require('inspector');
const { promisify } = require('util');
const { internalBinding } = require('internal/test/binding');
const { registerAsyncHook } = internalBinding('inspector');
(async () => {
let enabled = 0;
registerAsyncHook(() => ++enabled, () => {});
const session = new Session();
session.connect();
session.post = promisify(session.post);
await session.post('Debugger.enable');
strictEqual(enabled, 0);
await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 });
strictEqual(enabled, 1);
throw new Error(eyecatcher);
})();
} else {
const { spawnSync } = require('child_process');
const options = { encoding: 'utf8' };
const proc = spawnSync(
process.execPath, ['--expose-internals', __filename, 'child'], options);
strictEqual(proc.status, 0);
strictEqual(proc.signal, null);
strictEqual(proc.stderr.includes(eyecatcher), true);
}