debugger.js 1.84 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
(function() {
Camillo Bruni's avatar
Camillo Bruni committed
6

7 8 9 10 11 12 13
createSuite('Debugger.paused', 10000, DebuggerPaused, Setup, TearDown);
createSuite(
    'Debugger.getPossibleBreakpoints', 10000, DebuggerGetPossibleBreakpoints,
    SetupGetPossibleBreakpoints, TearDown);
createSuite(
    'AsyncStacksInstrumentation', 10000, AsyncStacksInstrumentation,
    SetupAsyncStacksInstrumentation, TearDown);
14

15 16 17 18 19
function Setup() {
  SendMessage('Debugger.enable');
  // Force lazy compilation of inspector related scripts.
  SendMessage('Runtime.evaluate', {expression: ''});
}
20

21 22 23
function TearDown() {
  SendMessage('Debugger.disable');
}
24

25 26 27
function DebuggerPaused() {
  for (var i = 0; i < 10; ++i) {
    debugger;
28
  }
29
}
30

31 32 33 34 35 36 37 38 39 40 41 42
let scriptId;
function SetupGetPossibleBreakpoints() {
  Setup();
  let expression = '';
  for (let i = 0; i < 20; ++i) {
    expression += `function foo${i}(){
        if (a) {
          return true;
        } else {
          return false;
        }
      }\n`;
Camillo Bruni's avatar
Camillo Bruni committed
43
  };
44 45 46 47
  listener = function(msg) {
    if (msg.method === 'Debugger.scriptParsed') {
      scriptId = msg.params.scriptId;
      listener = null;
48
    }
Camillo Bruni's avatar
Camillo Bruni committed
49 50
  };
  SendMessage('Runtime.evaluate', {expression});
51
}
52

53 54 55 56 57
function DebuggerGetPossibleBreakpoints() {
  SendMessage(
      'Debugger.getPossibleBreakpoints',
      {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}});
}
58

59 60 61 62
function SetupAsyncStacksInstrumentation() {
  Setup();
  SendMessage('Debugger.setAsyncCallStackDepth', {maxDepth: 1024});
}
63

64 65 66 67 68 69
function AsyncStacksInstrumentation() {
  var p = Promise.resolve();
  var nopCallback = () => undefined;
  var done = false;
  for (let i = 0; i < 1000; ++i) {
    p = p.then(nopCallback);
70
  }
71
  p = p.then(() => done = true);
72
  while (!done) %PerformMicrotaskCheckpoint();
73
}
Camillo Bruni's avatar
Camillo Bruni committed
74

75
})();