11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled();
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
71cb0ef41Sopenharmony_ciconst startCLI = require('../common/debugger');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst assert = require('assert');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifunction delay(ms) {
121cb0ef41Sopenharmony_ci  return new Promise((resolve) => setTimeout(resolve, ms));
131cb0ef41Sopenharmony_ci}
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// Profiles.
161cb0ef41Sopenharmony_ci{
171cb0ef41Sopenharmony_ci  const cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')]);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  function onFatal(error) {
201cb0ef41Sopenharmony_ci    cli.quit();
211cb0ef41Sopenharmony_ci    throw error;
221cb0ef41Sopenharmony_ci  }
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  try {
251cb0ef41Sopenharmony_ci    (async () => {
261cb0ef41Sopenharmony_ci      await cli.waitForInitialBreak();
271cb0ef41Sopenharmony_ci      await cli.waitForPrompt();
281cb0ef41Sopenharmony_ci      await cli.command('exec console.profile()');
291cb0ef41Sopenharmony_ci      assert.match(cli.output, /undefined/);
301cb0ef41Sopenharmony_ci      await cli.command('exec console.profileEnd()');
311cb0ef41Sopenharmony_ci      await delay(250);
321cb0ef41Sopenharmony_ci      assert.match(cli.output, /undefined/);
331cb0ef41Sopenharmony_ci      assert.match(cli.output, /Captured new CPU profile\./);
341cb0ef41Sopenharmony_ci      await cli.quit();
351cb0ef41Sopenharmony_ci    })()
361cb0ef41Sopenharmony_ci        .then(common.mustCall());
371cb0ef41Sopenharmony_ci  } catch (error) {
381cb0ef41Sopenharmony_ci    return onFatal(error);
391cb0ef41Sopenharmony_ci  }
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci}
42