11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst { NodeInstance } = require('../common/inspector-helper.js'); 91cb0ef41Sopenharmony_ciconst { pathToFileURL } = require('url'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst script = fixtures.path('throws_error.js'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciasync function testBreakpointOnStart(session) { 141cb0ef41Sopenharmony_ci console.log('[test]', 151cb0ef41Sopenharmony_ci 'Verifying debugger stops on start (--inspect-brk option)'); 161cb0ef41Sopenharmony_ci const commands = [ 171cb0ef41Sopenharmony_ci { 'method': 'Runtime.enable' }, 181cb0ef41Sopenharmony_ci { 'method': 'Debugger.enable' }, 191cb0ef41Sopenharmony_ci { 'method': 'Debugger.setPauseOnExceptions', 201cb0ef41Sopenharmony_ci 'params': { 'state': 'none' } }, 211cb0ef41Sopenharmony_ci { 'method': 'Debugger.setAsyncCallStackDepth', 221cb0ef41Sopenharmony_ci 'params': { 'maxDepth': 0 } }, 231cb0ef41Sopenharmony_ci { 'method': 'Profiler.enable' }, 241cb0ef41Sopenharmony_ci { 'method': 'Profiler.setSamplingInterval', 251cb0ef41Sopenharmony_ci 'params': { 'interval': 100 } }, 261cb0ef41Sopenharmony_ci { 'method': 'Debugger.setBlackboxPatterns', 271cb0ef41Sopenharmony_ci 'params': { 'patterns': [] } }, 281cb0ef41Sopenharmony_ci { 'method': 'Runtime.runIfWaitingForDebugger' }, 291cb0ef41Sopenharmony_ci ]; 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci await session.send(commands); 321cb0ef41Sopenharmony_ci await session.waitForBreakOnLine(21, pathToFileURL(script).toString()); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ciasync function runTest() { 371cb0ef41Sopenharmony_ci const child = new NodeInstance(undefined, undefined, script); 381cb0ef41Sopenharmony_ci const session = await child.connectInspectorSession(); 391cb0ef41Sopenharmony_ci await testBreakpointOnStart(session); 401cb0ef41Sopenharmony_ci await session.runToCompletion(); 411cb0ef41Sopenharmony_ci assert.strictEqual((await child.expectShutdown()).exitCode, 1); 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_cirunTest().then(common.mustCall()); 45