framework-precise-ranges.js 2.23 KB
Newer Older
1 2 3 4
// 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.

5
let {session, contextGroup, Protocol} = InspectorTest.start('Checks framework debugging with blackboxed ranges.');
6

7
contextGroup.addScript(
8 9 10 11 12 13 14 15 16 17 18 19 20
    `
function foo() {
  return boo();
}
function boo() {
  return 42;
}
function testFunction() {
  foo();
}
//# sourceURL=test.js`,
    7, 26);

21
session.setupScriptMap();
22
Protocol.Debugger.onPaused(message => {
23
  session.logCallFrames(message.params.callFrames);
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
  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) {
67
  contextGroup.schedulePauseOnNextStatement('', '');
68 69 70 71 72 73 74 75 76 77 78
  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};
}