Skip to content

Commit cb73fed

Browse files
eugeneoBridgeAR
authored andcommitted
inspector, test: verify reported console message
Many Inspector protocol clients rely on the top frame reported for the console messages. This test makes sure correct location is reported. PR-URL: #25455 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b524a7b commit cb73fed

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
8+
const common = require('../common');
9+
common.skipIfInspectorDisabled();
10+
11+
const assert = require('assert');
12+
const { Session } = require('inspector');
13+
const { basename } = require('path');
14+
15+
function logMessage() {
16+
console.log('Log a message');
17+
}
18+
19+
const session = new Session();
20+
let topFrame;
21+
session.once('Runtime.consoleAPICalled', (notification) => {
22+
topFrame = (notification.params.stackTrace.callFrames[0]);
23+
});
24+
session.connect();
25+
session.post('Runtime.enable');
26+
27+
logMessage(); // Triggers Inspector notification
28+
29+
session.disconnect();
30+
assert.strictEqual(basename(topFrame.url), basename(__filename));
31+
assert.strictEqual(topFrame.lineNumber, 15);

0 commit comments

Comments
 (0)