summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/destructuring.js
blob: e46e0e499823a139c34b52f19093c60392eac6b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let {session, contextGroup, Protocol} =
  InspectorTest.start('Tests breakable locations in destructuring.');

let source = `
function testFunction() {
  function func() {
    return [1, 2];
  }

  var [a, b] = func();
}
//# sourceURL=test.js`;

contextGroup.addScript(source);
session.setupScriptMap();

InspectorTest.runAsyncTestSuite([
  async function testBreakLocations() {
    Protocol.Debugger.enable();
    let {params:{scriptId}} = await Protocol.Debugger.onceScriptParsed();
    let {result:{locations}} = await Protocol.Debugger.getPossibleBreakpoints({
      start: {lineNumber: 0, columnNumber : 0, scriptId}});
    await session.logBreakLocations(locations);
  },

  async function testSetBreakpoint() {
    const SOURCE_LOCATIONS = [
      {lineNumber: 6, columnNumber: 0},
      {lineNumber: 6, columnNumber: 7},
      {lineNumber: 6, columnNumber: 10},
      {lineNumber: 6, columnNumber: 15},
    ];
    for (const {lineNumber, columnNumber} of SOURCE_LOCATIONS) {
      const url = 'test.js';
      InspectorTest.log(`Setting breakpoint at ${url}:${lineNumber}:${columnNumber}`);
      const {result: {breakpointId, locations}} = await Protocol.Debugger.setBreakpointByUrl({
        lineNumber, columnNumber, url
      });
      locations.forEach(location => session.logSourceLocation(location));
      await Protocol.Debugger.removeBreakpoint({breakpointId});
    }
  }
]);