forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-inspector-async-hook-setup-at-inspect-brk.js
49 lines (43 loc) · 1.61 KB
/
test-inspector-async-hook-setup-at-inspect-brk.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
const script = `
setTimeout(() => {
debugger;
process.exitCode = 55;
}, 50);
`;
async function skipBreakpointAtStart(session) {
await session.waitForBreakOnLine(1, '[eval]');
await session.send({ 'method': 'Debugger.resume' });
}
async function checkAsyncStackTrace(session) {
console.error('[test]', 'Verify basic properties of asyncStackTrace');
const paused = await session.waitForBreakOnLine(2, '[eval]');
assert(paused.params.asyncStackTrace,
`${Object.keys(paused.params)} contains "asyncStackTrace" property`);
assert(paused.params.asyncStackTrace.description, 'Timeout');
assert(paused.params.asyncStackTrace.callFrames
.some((frame) => frame.url === 'node:internal/process/execution'));
}
async function runTests() {
const instance = new NodeInstance(undefined, script);
const session = await instance.connectInspectorSession();
await session.send([
{ 'method': 'Runtime.enable' },
{ 'method': 'Debugger.enable' },
{ 'method': 'Debugger.setAsyncCallStackDepth',
'params': { 'maxDepth': 10 } },
{ 'method': 'Debugger.setBlackboxPatterns',
'params': { 'patterns': [] } },
{ 'method': 'Runtime.runIfWaitingForDebugger' }
]);
await skipBreakpointAtStart(session);
await checkAsyncStackTrace(session);
await session.runToCompletion();
assert.strictEqual((await instance.expectShutdown()).exitCode, 55);
}
runTests().then(common.mustCall());