11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled();
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst RESTARTS = 10;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
121cb0ef41Sopenharmony_ciconst startCLI = require('../common/debugger');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Using `restart` should result in only one "Connect/For help" message.
151cb0ef41Sopenharmony_ci{
161cb0ef41Sopenharmony_ci  const script = fixtures.path('debugger', 'three-lines.js');
171cb0ef41Sopenharmony_ci  const cli = startCLI(['--port=0', script]);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  const listeningRegExp = /Debugger listening on/g;
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  async function onWaitForInitialBreak() {
221cb0ef41Sopenharmony_ci    try {
231cb0ef41Sopenharmony_ci      await cli.waitForInitialBreak();
241cb0ef41Sopenharmony_ci      await cli.waitForPrompt();
251cb0ef41Sopenharmony_ci      assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci      for (let i = 0; i < RESTARTS; i++) {
281cb0ef41Sopenharmony_ci        await cli.stepCommand('restart');
291cb0ef41Sopenharmony_ci        assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
301cb0ef41Sopenharmony_ci      }
311cb0ef41Sopenharmony_ci    } finally {
321cb0ef41Sopenharmony_ci      await cli.quit();
331cb0ef41Sopenharmony_ci    }
341cb0ef41Sopenharmony_ci  }
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  onWaitForInitialBreak();
371cb0ef41Sopenharmony_ci}
38