• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6// Test that example code in doc/api/inspector.md continues to work with the V8
7// experimental API.
8
9const assert = require('assert');
10const inspector = require('inspector');
11const session = new inspector.Session();
12
13session.connect();
14
15const chunks = [];
16
17session.on('HeapProfiler.addHeapSnapshotChunk', (m) => {
18  chunks.push(m.params.chunk);
19});
20
21session.post('HeapProfiler.takeHeapSnapshot', null, common.mustSucceed((r) => {
22  assert.deepStrictEqual(r, {});
23  session.disconnect();
24
25  const profile = JSON.parse(chunks.join(''));
26  assert(profile.snapshot.meta);
27  assert(profile.snapshot.node_count > 0);
28  assert(profile.snapshot.edge_count > 0);
29}));
30