1// Flags: --expose-internals 2'use strict'; 3const common = require('../common'); 4 5common.skipIfInspectorDisabled(); 6 7const { validateSnapshotNodes } = require('../common/heap'); 8const inspector = require('inspector'); 9 10const snapshotNode = { 11 children: [ 12 { node_name: 'Node / InspectorSession', edge_name: 'session' }, 13 ], 14}; 15 16// Starts with no JSBindingsConnection (or 1 if coverage enabled). 17{ 18 const expected = []; 19 if (process.env.NODE_V8_COVERAGE) { 20 expected.push(snapshotNode); 21 } 22 validateSnapshotNodes('Node / JSBindingsConnection', expected); 23} 24 25// JSBindingsConnection should be added. 26{ 27 const session = new inspector.Session(); 28 session.connect(); 29 const expected = [ 30 { 31 children: [ 32 { node_name: 'Node / InspectorSession', edge_name: 'session' }, 33 { node_name: 'Connection', edge_name: 'native_to_javascript' }, 34 (edge) => edge.name === 'callback' && 35 (edge.to.type === undefined || // embedded graph 36 edge.to.type === 'closure'), // snapshot 37 ], 38 }, 39 ]; 40 if (process.env.NODE_V8_COVERAGE) { 41 expected.push(snapshotNode); 42 } 43 validateSnapshotNodes('Node / JSBindingsConnection', expected); 44} 45