11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Verify that the line containing console.log is reported as a top stack frame
41cb0ef41Sopenharmony_ci// of the consoleAPICalled notification.
51cb0ef41Sopenharmony_ci// Changing this will break many Inspector protocol clients, including
61cb0ef41Sopenharmony_ci// debuggers that use that value for navigating from console messages to code.
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst common = require('../common');
91cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled();
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst assert = require('assert');
121cb0ef41Sopenharmony_ciconst { Session } = require('inspector');
131cb0ef41Sopenharmony_ciconst { basename } = require('path');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cifunction logMessage() {
161cb0ef41Sopenharmony_ci  console.log('Log a message');
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst session = new Session();
201cb0ef41Sopenharmony_cilet topFrame;
211cb0ef41Sopenharmony_cisession.once('Runtime.consoleAPICalled', (notification) => {
221cb0ef41Sopenharmony_ci  topFrame = (notification.params.stackTrace.callFrames[0]);
231cb0ef41Sopenharmony_ci});
241cb0ef41Sopenharmony_cisession.connect();
251cb0ef41Sopenharmony_cisession.post('Runtime.enable');
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cilogMessage();  // Triggers Inspector notification
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_cisession.disconnect();
301cb0ef41Sopenharmony_ciassert.strictEqual(basename(topFrame.url), basename(__filename));
311cb0ef41Sopenharmony_ciassert.strictEqual(topFrame.lineNumber, 15);
32