1'use strict';
2
3// Verify that the line containing console.log is reported as a top stack frame
4// of the consoleAPICalled notification.
5// Changing this will break many Inspector protocol clients, including
6// debuggers that use that value for navigating from console messages to code.
7
8const common = require('../common');
9common.skipIfInspectorDisabled();
10
11const assert = require('assert');
12const { Session } = require('inspector');
13const { basename } = require('path');
14
15function logMessage() {
16  console.log('Log a message');
17}
18
19const session = new Session();
20let topFrame;
21session.once('Runtime.consoleAPICalled', (notification) => {
22  topFrame = (notification.params.stackTrace.callFrames[0]);
23});
24session.connect();
25session.post('Runtime.enable');
26
27logMessage();  // Triggers Inspector notification
28
29session.disconnect();
30assert.strictEqual(basename(topFrame.url), basename(__filename));
31assert.strictEqual(topFrame.lineNumber, 15);
32