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_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci// Debugger agent direct access.
111cb0ef41Sopenharmony_ci{
121cb0ef41Sopenharmony_ci  const cli = startCLI(['--port=0', fixtures.path('debugger/three-lines.js')]);
131cb0ef41Sopenharmony_ci  const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  async function testDebuggerLowLevel() {
161cb0ef41Sopenharmony_ci    try {
171cb0ef41Sopenharmony_ci      await cli.waitForInitialBreak();
181cb0ef41Sopenharmony_ci      await cli.waitForPrompt();
191cb0ef41Sopenharmony_ci      await cli.command('scripts');
201cb0ef41Sopenharmony_ci      const [, scriptId] = cli.output.match(scriptPattern);
211cb0ef41Sopenharmony_ci      await cli.command(
221cb0ef41Sopenharmony_ci        `Debugger.getScriptSource({ scriptId: '${scriptId}' })`
231cb0ef41Sopenharmony_ci      );
241cb0ef41Sopenharmony_ci      assert.match(
251cb0ef41Sopenharmony_ci        cli.output,
261cb0ef41Sopenharmony_ci        /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
271cb0ef41Sopenharmony_ci      assert.match(
281cb0ef41Sopenharmony_ci        cli.output,
291cb0ef41Sopenharmony_ci        /let x = 1;/);
301cb0ef41Sopenharmony_ci    } finally {
311cb0ef41Sopenharmony_ci      await cli.quit();
321cb0ef41Sopenharmony_ci    }
331cb0ef41Sopenharmony_ci  }
341cb0ef41Sopenharmony_ci  testDebuggerLowLevel();
351cb0ef41Sopenharmony_ci}
36