2017-01-24 01:50:25 +00:00
|
|
|
// 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.
|
2017-01-26 20:57:03 +00:00
|
|
|
// Flags: --allow-natives-syntax
|
2017-01-24 01:50:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that breaks in framework code correctly processed.');
|
2017-01-24 01:50:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(`
|
2017-01-24 01:50:25 +00:00
|
|
|
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() {
|
2017-04-21 23:41:07 +00:00
|
|
|
inspector.breakProgram('', '');
|
2017-01-24 01:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function asyncDOMBreakpoint() {
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
|
|
|
|
function throwCaughtSyntaxError() {
|
|
|
|
try {
|
|
|
|
eval('}');
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function throwFromJSONParse() {
|
|
|
|
try {
|
|
|
|
JSON.parse('ping');
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:57:03 +00:00
|
|
|
function throwInlinedUncaughtError() {
|
|
|
|
function inlinedWrapper() {
|
|
|
|
throwUserException();
|
|
|
|
}
|
2019-05-02 15:23:48 +00:00
|
|
|
%PrepareFunctionForOptimization(inlinedWrapper);
|
2017-01-26 20:57:03 +00:00
|
|
|
%OptimizeFunctionOnNextCall(inlinedWrapper);
|
|
|
|
inlinedWrapper();
|
|
|
|
}
|
|
|
|
|
2017-01-26 21:32:53 +00:00
|
|
|
function syncDOMBreakpointWithInlinedUserFrame() {
|
|
|
|
function inlinedWrapper() {
|
|
|
|
userFunction();
|
|
|
|
}
|
2019-05-02 15:23:48 +00:00
|
|
|
%PrepareFunctionForOptimization(inlinedWrapper);
|
2017-01-26 21:32:53 +00:00
|
|
|
%OptimizeFunctionOnNextCall(inlinedWrapper);
|
|
|
|
inlinedWrapper();
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:57:03 +00:00
|
|
|
//# sourceURL=framework.js`, 8, 26);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(`
|
2017-01-26 20:57:03 +00:00
|
|
|
function throwUserException() {
|
|
|
|
throw new Error();
|
|
|
|
}
|
2017-01-26 21:32:53 +00:00
|
|
|
|
|
|
|
function userFunction() {
|
|
|
|
syncDOMBreakpoint();
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:57:03 +00:00
|
|
|
//# sourceURL=user.js`, 64, 26)
|
2017-01-24 01:50:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
session.setupScriptMap();
|
2017-01-24 01:50:25 +00:00
|
|
|
Protocol.Debugger.onPaused(message => {
|
2017-05-19 00:35:45 +00:00
|
|
|
session.logCallFrames(message.params.callFrames);
|
2017-01-24 01:50:25 +00:00
|
|
|
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(
|
2017-01-26 20:57:03 +00:00
|
|
|
{expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'}))
|
|
|
|
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
|
2017-01-24 01:50:25 +00:00
|
|
|
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
|
|
|
|
.then(
|
|
|
|
() => Protocol.Runtime.evaluate(
|
2017-01-26 20:57:03 +00:00
|
|
|
{expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=user.js\', 0)'}))
|
|
|
|
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
|
2017-01-24 01:50:25 +00:00
|
|
|
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
2017-01-26 20:57:03 +00:00
|
|
|
function testUncaughtExceptionWithInlinedFrame(next) {
|
|
|
|
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
|
|
|
|
.then(() => InspectorTest.log('> mixed top frame in framework:'))
|
|
|
|
.then(
|
|
|
|
() => Protocol.Runtime.evaluate(
|
|
|
|
{expression: 'setTimeout(\'throwInlinedUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'}))
|
|
|
|
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
2017-01-24 01:50:25 +00:00
|
|
|
function testBreakpoint(next) {
|
2017-01-26 20:57:03 +00:00
|
|
|
Protocol.Debugger.setBreakpointByUrl({lineNumber: 25, url: 'framework.js'})
|
2017-01-24 01:50:25 +00:00
|
|
|
.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);
|
|
|
|
},
|
|
|
|
|
2017-01-26 21:32:53 +00:00
|
|
|
function testSyncDOMBreakpointWithInlinedUserFrame(next) {
|
|
|
|
InspectorTest.log('> mixed, top frame in framework:');
|
|
|
|
Protocol.Runtime
|
|
|
|
.evaluate({expression: 'syncDOMBreakpointWithInlinedUserFrame()//# sourceURL=framework.js'})
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
2017-01-24 01:50:25 +00:00
|
|
|
function testAsyncDOMBreakpoint(next) {
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.schedulePauseOnNextStatement('', '');
|
2017-01-24 01:50:25 +00:00
|
|
|
InspectorTest.log('> all frames in framework:');
|
|
|
|
Protocol.Runtime
|
|
|
|
.evaluate(
|
|
|
|
{expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'})
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => contextGroup.cancelPauseOnNextStatement())
|
2017-01-24 01:50:25 +00:00
|
|
|
.then(
|
|
|
|
() => Protocol.Runtime.evaluate(
|
|
|
|
{expression: '42//# sourceURL=user.js'}))
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => contextGroup.schedulePauseOnNextStatement('', ''))
|
2017-01-24 01:50:25 +00:00
|
|
|
.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);
|
|
|
|
}
|
|
|
|
]);
|