node/deps/v8/test/inspector/debugger/break-on-exception.js
Michaël Zasso 3dc8c3bed4 deps: update V8 to 5.9.211.32
PR-URL: https://github.com/nodejs/node/pull/13263
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2017-06-07 10:33:31 +02:00

72 lines
2.3 KiB
JavaScript

// Copyright 2016 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.
InspectorTest.log("Check that inspector correctly change break on exception state.");
InspectorTest.addScript(`
function scheduleUncaughtException()
{
setTimeout(throwUncaughtException, 0);
}
function throwUncaughtException()
{
throw new Error();
}
function throwCaughtException()
{
throw new Error();
}`);
Protocol.Debugger.onPaused(message => {
InspectorTest.log("paused in " + message.params.callFrames[0].functionName);
Protocol.Debugger.resume();
});
Protocol.Runtime.enable();
InspectorTest.runTestSuite([
function noBreakOnExceptionAfterEnabled(next)
{
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({ state: "all" });
Protocol.Debugger.disable();
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" })
.then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" }))
.then(() => Protocol.Debugger.disable())
.then(next);
},
function breakOnUncaughtException(next)
{
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({ state: "uncaught" });
Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" })
.then(() => Protocol.Runtime.onceExceptionThrown())
.then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" }))
.then(() => Protocol.Debugger.disable())
.then(next);
},
function breakOnCaughtException(next)
{
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({ state: "all" });
Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" })
.then(() => Protocol.Runtime.onceExceptionThrown())
.then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" }))
.then(() => Protocol.Debugger.disable())
.then(next);
},
function noBreakInEvaluateInSilentMode(next)
{
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({ state: "all" })
.then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()", silent: true }))
.then(() => Protocol.Debugger.disable())
.then(next);
}
]);