summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/framework-precise-ranges.js
blob: 4f76033a96973208198e87e020f4d4ea2f537c35 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2017 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('Checks framework debugging with blackboxed ranges.');

contextGroup.addScript(
    `
function foo() {
  return boo();
}
function boo() {
  return 42;
}
function testFunction() {
  foo();
}
//# sourceURL=test.js`,
    7, 26);

session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
  session.logCallFrames(message.params.callFrames);
  InspectorTest.log('');
  Protocol.Debugger.stepInto();
});
var scriptId;
Protocol.Debugger.onScriptParsed(message => {
  if (message.params.url === 'test.js') {
    scriptId = message.params.scriptId;
  }
});

Protocol.Debugger.enable()
    .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['expr\.js']}))
    .then(() => InspectorTest.runTestSuite(testSuite));

var testSuite = [
  function testEntireScript(next) {
    testPositions([position(0, 0)]).then(next);
  },
  function testFooNotBlackboxed(next) {
    testPositions([position(11, 0)]).then(next);
  },
  function testFooBlackboxed(next) {
    testPositions([position(8, 0), position(10, 3)]).then(next);
  },
  function testBooPartiallyBlackboxed1(next) {
    // first line is not blackboxed, second and third - blackboxed.
    testPositions([position(12, 0)]).then(next);
  },
  function testBooPartiallyBlackboxed2(next) {
    // first line is blackboxed, second - not, third - blackboxed.
    testPositions([
      position(11, 0), position(12, 0), position(13, 0)
    ]).then(next);
  },
  function testBooPartiallyBlackboxed3(next) {
    // first line is blackboxed, second and third - not.
    testPositions([
      position(11, 0), position(12, 0), position(14, 0)
    ]).then(next);
  }
];

function testPositions(positions) {
  contextGroup.schedulePauseOnNextStatement('', '');
  return Protocol.Debugger
      .setBlackboxedRanges({scriptId: scriptId, positions: positions})
      .then(InspectorTest.logMessage)
      .then(
          () => Protocol.Runtime.evaluate(
              {expression: 'testFunction()//# sourceURL=expr.js'}));
}

function position(line, column) {
  return {lineNumber: line, columnNumber: column};
}