framework-nested-scheduled-break.js 1.69 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 nested scheduled break in framework code.');
6

7
contextGroup.addScript(`
8
function frameworkCall(callback) {
9
  inspector.callWithScheduledBreak(doFrameworkWork.bind(null, callback),
10 11 12 13 14
    'top-framework-scheduled-break',
    JSON.stringify({ data: 'data for top-framework-scheduled-break' }));
}

function doFrameworkWork(callback) {
15
  inspector.callWithScheduledBreak(doFrameworkBreak, 'should-not-be-a-reason', '');
16 17 18 19
  callback();
}

function doFrameworkBreak() {
20
  inspector.breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' }));
21 22 23 24
}

//# sourceURL=framework.js`, 7, 26);

25
contextGroup.addScript(`
26
function testFunction() {
27
  inspector.callWithScheduledBreak(frameworkCall.bind(null, callback),
28 29 30 31
    'top-scheduled-break', '');
}

function callback() {
32
  inspector.breakProgram('user-break', JSON.stringify({ data: 'data for user-break' }));
33 34 35 36 37
  return 42;
}

//# sourceURL=user.js`, 25, 26);

38
session.setupScriptMap();
39 40 41
Protocol.Debugger.onPaused(message => {
  InspectorTest.log('break reason: ' + message.params.reason);
  InspectorTest.log('break aux data: ' + JSON.stringify(message.params.data || {}, null, '  '));
42
  session.logCallFrames(message.params.callFrames);
43 44 45 46 47 48 49
  InspectorTest.log('');
  Protocol.Debugger.resume();
});
Protocol.Debugger.enable()
  .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}))
  .then(() => Protocol.Runtime.evaluate({ expression: 'testFunction()//# sourceURL=expr.js'}))
  .then(InspectorTest.completeTest);