v8/test/inspector/debugger/framework-break.js
kozyatinskiy ac50c79a3e [inspector] implemented blackboxing inside v8
V8 has internal mechanism to ignore steps and breaks inside internal scripts, in this CL it's reused for blackboxing implementation.
Advantages:
- much faster blackboxing implementation (before we at least wrap and collect current call stack for each step),
- get rid of StepFrame action and potential pause in blackboxed code after N StepFrame steps,
- simplification of debugger agent logic.
Disadvtanges:
- currently when user was paused in blackboxed code (e.g. on breakpoint) and then makes step action, debugger ignores blackboxed state of the script and allows to use step actions as usual - this behavior is regressed, we still able to support it on frontend side.

Current state and proposed changes for blackboxing: https://docs.google.com/document/d/1hnzaXPAN8_QC5ENxIgxgMNDbXLraM_OXT73rAyijTF8/edit?usp=sharing

BUG=v8:5842
R=yangguo@chromium.org,dgozman@chromium.org,alph@chromium.org

Review-Url: https://codereview.chromium.org/2633803002
Cr-Commit-Position: refs/heads/master@{#42614}
2017-01-24 01:50:25 +00:00

190 lines
6.2 KiB
JavaScript

// 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.
print('Checks that breaks in framework code correctly processed.');
InspectorTest.addScript(
`
function frameworkAssert() {
console.assert(false);
}
function throwCaughtError() {
try {
throw new Error();
} catch (e) {
}
}
function throwUncaughtError() {
throw new Error();
}
function breakpoint() {
return 239;
}
function debuggerStatement() {
debugger;
}
function syncDOMBreakpoint() {
breakProgram('', '');
}
function asyncDOMBreakpoint() {
return 42;
}
function throwCaughtSyntaxError() {
try {
eval('}');
} catch (e) {
}
}
function throwFromJSONParse() {
try {
JSON.parse('ping');
} catch (e) {
}
}
//# sourceURL=framework.js`,
7, 26);
InspectorTest.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.log('');
Protocol.Debugger.resume();
});
Protocol.Debugger.enable();
Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
InspectorTest.runTestSuite([
function testConsoleAssert(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'frameworkAssert()//# sourceURL=framework.js'}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'frameworkAssert()//# sourceURL=user.js'}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
},
function testCaughtException(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwCaughtError()//# sourceURL=framework.js'}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwCaughtError()//# sourceURL=user.js'}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
},
function testUncaughtException(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwUncaughtError()//# sourceURL=framework.js'}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwUncaughtError()//# sourceURL=user.js'}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
},
function testBreakpoint(next) {
Protocol.Debugger.setBreakpointByUrl({lineNumber: 24, url: 'framework.js'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'breakpoint()//# sourceURL=framework.js'}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'breakpoint()//# sourceURL=user.js'}))
.then(next);
},
function testDebuggerStatement(next) {
InspectorTest.log('> all frames in framework:');
Protocol.Runtime
.evaluate({expression: 'debuggerStatement()//# sourceURL=framework.js'})
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'debuggerStatement()//# sourceURL=user.js'}))
.then(next);
},
function testSyncDOMBreakpoint(next) {
InspectorTest.log('> all frames in framework:');
Protocol.Runtime
.evaluate({expression: 'syncDOMBreakpoint()//# sourceURL=framework.js'})
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'syncDOMBreakpoint()//# sourceURL=user.js'}))
.then(next);
},
function testAsyncDOMBreakpoint(next) {
schedulePauseOnNextStatement('', '');
InspectorTest.log('> all frames in framework:');
Protocol.Runtime
.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'})
.then(() => cancelPauseOnNextStatement())
.then(
() => Protocol.Runtime.evaluate(
{expression: '42//# sourceURL=user.js'}))
.then(() => schedulePauseOnNextStatement('', ''))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'}))
.then(next);
},
function testCaughtSyntaxError(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(() => Protocol.Runtime.evaluate({
expression: 'throwCaughtSyntaxError()//# sourceURL=framework.js'
}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwCaughtSyntaxError()//# sourceURL=user.js'}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
},
function testCaughtJSONParseError(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwFromJSONParse()//# sourceURL=framework.js'}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwFromJSONParse()//# sourceURL=user.js'}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
}
]);